From 8c258ea35673745c5d849564aa841da68c13c685 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson <jon.johnson@ucsf.edu> Date: Tue, 19 Sep 2023 22:25:04 -0700 Subject: [PATCH] Percy Improvements I've removed some tests that we don't need and locked a few dates to prevent false positive failures. --- tests/acceptance/api-version-notice-test.js | 15 ++++++++------- tests/acceptance/dashboard/accessibility-test.js | 2 -- tests/acceptance/header-test.js | 10 +++++++++- tests/acceptance/user-test.js | 7 ++++++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/acceptance/api-version-notice-test.js b/tests/acceptance/api-version-notice-test.js index ce1e47b21c..6a536ac2eb 100644 --- a/tests/acceptance/api-version-notice-test.js +++ b/tests/acceptance/api-version-notice-test.js @@ -1,9 +1,6 @@ import { visit, waitFor } from '@ember/test-helpers'; import { module, test } from 'qunit'; -import { setupAuthentication } from 'ilios-common'; - -const url = '/'; - +import { setupAuthentication, freezeDateAt, unfreezeDate } from 'ilios-common'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { component } from 'ilios-common/page-objects/components/api-version-notice'; @@ -14,9 +11,14 @@ module('Acceptance | API Version Check', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { const school = this.server.create('school'); + freezeDateAt(new Date('9/19/2019')); await setupAuthentication({ school }); }); + hooks.afterEach(() => { + unfreezeDate(); + }); + test('No warning shows up when api versions match', async function (assert) { assert.expect(3); const { apiVersion } = this.owner.resolveRegistration('config:environment'); @@ -31,9 +33,8 @@ module('Acceptance | API Version Check', function (hooks) { }; }); - await visit(url); + await visit('/'); await waitFor('[data-test-load-finished]'); - await percySnapshot(assert); assert.ok(component.notMismatched); }); @@ -49,7 +50,7 @@ module('Acceptance | API Version Check', function (hooks) { }; }); - await visit(url); + await visit('/'); await waitFor('[data-test-load-finished]'); await percySnapshot(assert); assert.ok(component.mismatched); diff --git a/tests/acceptance/dashboard/accessibility-test.js b/tests/acceptance/dashboard/accessibility-test.js index c08639b0ec..a4f4f4c710 100644 --- a/tests/acceptance/dashboard/accessibility-test.js +++ b/tests/acceptance/dashboard/accessibility-test.js @@ -4,7 +4,6 @@ import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; import { setupAuthentication } from 'ilios-common'; -import percySnapshot from '@percy/ember'; module('Acceptance | dashboard accessibility', function (hooks) { setupApplicationTest(hooks); @@ -18,7 +17,6 @@ module('Acceptance | dashboard accessibility', function (hooks) { test('meets a11y standards in default view', async function (assert) { assert.expect(2); await visit('/dashboard/week'); - await percySnapshot(assert); assert.strictEqual(currentURL(), '/dashboard/week'); await a11yAudit(); assert.ok(true); diff --git a/tests/acceptance/header-test.js b/tests/acceptance/header-test.js index f07aab0dbb..d393ccb2aa 100644 --- a/tests/acceptance/header-test.js +++ b/tests/acceptance/header-test.js @@ -2,13 +2,21 @@ import { module, test } from 'qunit'; import { visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { setupAuthentication } from 'ilios-common'; +import { setupAuthentication, freezeDateAt, unfreezeDate } from 'ilios-common'; import percySnapshot from '@percy/ember'; module('Acceptance | header', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); + hooks.beforeEach(async function () { + freezeDateAt(new Date('9/19/2029')); + }); + + hooks.afterEach(() => { + unfreezeDate(); + }); + test('privileged users can view search', async function (assert) { assert.expect(1); this.server.get('application/config', function () { diff --git a/tests/acceptance/user-test.js b/tests/acceptance/user-test.js index 5a637c875a..74a5841937 100644 --- a/tests/acceptance/user-test.js +++ b/tests/acceptance/user-test.js @@ -1,6 +1,6 @@ import { click, fillIn, currentURL, triggerEvent, visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -import { setupAuthentication } from 'ilios-common'; +import { setupAuthentication, freezeDateAt, unfreezeDate } from 'ilios-common'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; @@ -12,6 +12,7 @@ module('Acceptance | User', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { + freezeDateAt(new Date('10/31/2002')); this.school = this.server.create('school'); const userObject = { id: 100, @@ -33,6 +34,10 @@ module('Acceptance | User', function (hooks) { await setupAuthentication(userObject); }); + hooks.afterEach(() => { + unfreezeDate(); + }); + test('can search for users', async function (assert) { assert.expect(4); this.server.createList('user', 20, { email: 'user@example.edu', school: this.school });