emberobserver / client

http://emberobserver.com/
124 stars 65 forks source link

Use static data in tests to avoid Percy showing changes that aren't meaningful #201

Closed pgengler closed 3 years ago

pgengler commented 3 years ago

Fixes #146

This PR makes some tests (a subset of the ones that include percySnapshot calls) to use static/fixed data to avoid showing visual changes just because of a different date.

There were two tests that couldn't be fixed just by using static data: 1) Acceptance | admin review addon: Displays basic info about addon - the <AdminAddon/> component used {{moment-from-now}} to display a relative interval (relative to the current date/time) 2) Acceptance | canary test results: redirects to current day - the redirection from canary-test-results.index to canary-test-results.show is based on the current date, which is rendered in the page

To get these to stop changing in Percy I added a currentDate service; its date property normally returns the actual current date, but a setter is provided to override this, and these tests make use of that.

As part of that change I modified the <RelativeTime/> component (the other place in the code we were using {{moment-from-now}} to also make use of this service. (I also converted this component to be a Glimmer component in the process.)

codecov[bot] commented 3 years ago

Codecov Report

Merging #201 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #201   +/-   ##
=======================================
  Coverage   81.03%   81.03%           
=======================================
  Files         136      137    +1     
  Lines         970      970           
=======================================
  Hits          786      786           
  Misses        184      184           
Impacted Files Coverage Δ
app/components/relative-time.js 100.00% <100.00%> (ø)
app/routes/canary-test-results/index.js 100.00% <100.00%> (ø)
app/services/current-date.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2dd95a1...84b270c. Read the comment docs.