Skip to content

Commit 0a8736d

Browse files
authored
Add UI tests for BC Cancer notifications banner AB#17104 (#6801)
* Replace remaining references to dev-classic URL in Cypress tests
1 parent 30acc03 commit 0a8736d

3 files changed

Lines changed: 72 additions & 4 deletions

File tree

Apps/HealthGateway.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"id": "cypressBaseUrl",
113113
"description": "Choose your environment.",
114114
"options": [
115-
"https://dev-classic.healthgateway.gov.bc.ca",
115+
"https://dev.healthgateway.gov.bc.ca",
116116
"http://localhost:5002"
117117
]
118118
}

Testing/functional/tests/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Create a cypress.env.json and update with passwords or any other environment var
2323

2424
```bash
2525
{
26-
"baseUrl": "https://dev-classic.healthgateway.gov.bc.ca",
26+
"baseUrl": "https://dev.healthgateway.gov.bc.ca",
2727
"bcsc.password": "THE PASSWORD",
2828
"keycloak.password": "THE PASSWORD",
2929
"idir.password": "THE PASSWORD",
@@ -60,9 +60,9 @@ npx cypress open --e2e --browser chrome
6060

6161
Tip: If you encounter crashes or sluggish performance with npx cypress open, use CYPRESS_numTestsKeptInMemory=1 to reduce memory usage.
6262

63-
Note: This flag is only applicable for local testing (e.g., http://localhost:5002). It should not be used against deployed environments like https://dev-classic.healthgateway.gov.bc.ca.
63+
Note: This flag is only applicable for local testing (e.g., http://localhost:5002). It should not be used against deployed environments like https://dev.healthgateway.gov.bc.ca.
6464

65-
If you want to verify the tests against <https://dev-classic.healthgateway.gov.bc.ca> then do not set the CYPRESS_BASE_URL environment variable.
65+
If you want to verify the tests against <https://dev.healthgateway.gov.bc.ca> then do not set the CYPRESS_BASE_URL environment variable.
6666

6767
e2e: contains tests that will be run in the dev environment only.
6868
ui: contains tests that are either stubbed or cosmetic only and can be run in any environment

Testing/functional/tests/cypress/integration/ui/pages/home.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,72 @@ describe("Authenticated User - Home Page", () => {
168168
cy.get("[data-testid=noTimelineEntriesText]").should("be.visible");
169169
cy.get("[data-testid=timeline-record-count]").should("not.exist");
170170
});
171+
172+
it("Home - BC Cancer notifications banner shown if last login predates notifications implementation", () => {
173+
cy.configureSettings({});
174+
175+
cy.fixture("UserProfileService/userProfile.json").then((data) => {
176+
data.lastLoginDateTimes = [
177+
new Date().toISOString(),
178+
"2026-05-19T15:59:00Z", // previous login was before May 19, 2026 9:00AM Pacific Time
179+
];
180+
setupStandardFixtures({ userProfileBody: data });
181+
});
182+
183+
cy.login(
184+
Cypress.env("keycloak.username"),
185+
Cypress.env("keycloak.password"),
186+
AuthMethod.KeyCloak,
187+
homeUrl
188+
);
189+
190+
cy.get("[data-testid=bc-cancer-notifications-banner]").should(
191+
"be.visible"
192+
);
193+
});
194+
195+
it("Home - BC Cancer notifications banner hidden if last login is more recent", () => {
196+
cy.configureSettings({});
197+
198+
cy.fixture("UserProfileService/userProfile.json").then((data) => {
199+
data.lastLoginDateTimes = [
200+
new Date().toISOString(),
201+
"2026-05-19T16:01:00Z", // previous login was after May 19, 2026 9:00AM Pacific Time
202+
];
203+
setupStandardFixtures({ userProfileBody: data });
204+
});
205+
206+
cy.login(
207+
Cypress.env("keycloak.username"),
208+
Cypress.env("keycloak.password"),
209+
AuthMethod.KeyCloak,
210+
homeUrl
211+
);
212+
213+
cy.contains("#subject", "Home").should("exist");
214+
cy.get("[data-testid=bc-cancer-notifications-banner]").should(
215+
"not.exist"
216+
);
217+
});
218+
219+
it("Home - BC Cancer notifications banner hidden for new users", () => {
220+
cy.configureSettings({});
221+
222+
cy.fixture("UserProfileService/userProfile.json").then((data) => {
223+
data.lastLoginDateTimes = [new Date().toISOString()];
224+
setupStandardFixtures({ userProfileBody: data });
225+
});
226+
227+
cy.login(
228+
Cypress.env("keycloak.username"),
229+
Cypress.env("keycloak.password"),
230+
AuthMethod.KeyCloak,
231+
homeUrl
232+
);
233+
234+
cy.contains("#subject", "Home").should("exist");
235+
cy.get("[data-testid=bc-cancer-notifications-banner]").should(
236+
"not.exist"
237+
);
238+
});
171239
});

0 commit comments

Comments
 (0)