Use a regex pattern to avoid flaky timestamp spec (#12827)

This commit is contained in:
Jacob Herrington 2021-02-26 14:35:17 -06:00 committed by GitHub
parent 01d8818e9e
commit 7fa46683aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,9 +63,9 @@ RSpec.describe "User index", type: :system, stub_elasticsearch: true do
def shows_comment_timestamp
within("#substories .profile-comment-card .profile-comment-row:first-of-type") do
ts = comment.decorate.published_timestamp
timestamp_selector = ".comment-date time[datetime='#{ts}']"
expect(page).to have_selector(timestamp_selector)
iso8601_date_time = /^((\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z)$/
timestamp = page.find(".comment-date time")[:datetime]
expect(timestamp).to match(iso8601_date_time)
end
end
end