Spec Fix:Set Javascript Locale to Match Time.zone (#11025)

This commit is contained in:
Molly Struve 2020-10-26 08:51:32 -04:00 committed by GitHub
parent e4865a6072
commit 3884009f08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View file

@ -0,0 +1,10 @@
//= require timemachine.js
<% if Rails.env.test? %>
// Ensure that locale time in JavaScript matches the Timezone on
// our server during testing
timemachine.config({
dateString: '<%= Time.current.iso8601 %>',
tick: true
});
<% end %>

View file

@ -129,6 +129,7 @@
"sass-loader": "^10.0.3",
"style-loader": "^2.0.0",
"svgo": "1.3.2",
"timemachine": "^0.3.2",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {

View file

@ -29,10 +29,6 @@ RSpec.describe "Views an article", type: :system do
describe "when showing the date" do
it "shows the readable publish date", js: true do
visit article.path
# TODO: Molly investigating spec failures if this fails retry your build
puts "Readable Compare date #{article.displayable_published_at}"
puts find("article time")[:datetime]
puts find("article time")[:title]
expect(page).to have_selector("article time", text: article.readable_publish_date)
end
@ -55,8 +51,7 @@ RSpec.describe "Views an article", type: :system do
end
end
# TODO: Molly is investigating
xit "shows the identical readable publish dates in each page", js: true do
it "shows the identical readable publish dates in each page", js: true do
visit first_article.path
expect(page).to have_selector("article time", text: first_article.readable_publish_date)
expect(page).to have_selector(".crayons-card--secondary time", text: first_article.readable_publish_date)

View file

@ -16897,6 +16897,11 @@ thunky@^1.0.2:
resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d"
integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==
timemachine@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/timemachine/-/timemachine-0.3.2.tgz#83c594d0271c3608d5fab13636cd3b7c979ea2c5"
integrity sha512-JNKeKZXQJc8UC19JcIq0XziBud+fNNJfatZ57lwk+o1O9mpW2FmzWvRw7FTTOKuN6M0zsjGIlNi0O0QrF5WVRA==
timers-browserify@^2.0.4:
version "2.0.11"
resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.11.tgz#800b1f3eee272e5bc53ee465a04d0e804c31211f"