From 5b29b413e4b2d158738b6080a04001029a7e74f8 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Mon, 9 Sep 2024 10:08:21 -0700 Subject: [PATCH] Added check if using mock --- .../authenticated/admin/receiver-status.ts | 8 +-- .../receiver-status-page-user-flow.spec.ts | 70 +++++++++++++++++-- 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 297a9cf9d66..2f0673d9892 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -460,7 +460,6 @@ export class AdminReceiverStatusPage extends BasePage { this.timePeriodData[1]; const receiversStatusRows = this.receiverStatusRowsLocator; - const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); const expectedReceiverStatusRowTitle = this.getExpectedReceiverStatusRowTitle( @@ -469,20 +468,19 @@ export class AdminReceiverStatusPage extends BasePage { successRate, ); - expect(defaultReceiversStatusRowsCount).toBe(this.timePeriodData.length); + await expect(receiversStatusRows).toHaveCount(this.timePeriodData.length); await this.updateFilters({ receiverName, }); - const receiversStatusRowsCount = await receiversStatusRows.count(); - expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + await expect(receiversStatusRows).toHaveCount(1); await expect(expectedReceiverStatusRow).toBeVisible(); await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); await this.resetFilters(); - expect(defaultReceiversStatusRowsCount).toBe(this.timePeriodData.length); + await expect(receiversStatusRows).toHaveCount(this.timePeriodData.length); return true; } diff --git a/frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts b/frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts index 456a0f18318..35a4b1e98fc 100644 --- a/frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts +++ b/frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts @@ -175,16 +175,72 @@ test.describe("Admin Receiver Status Page", }, ); - test("receiver name", async ({ adminReceiverStatusPage }) => { - const result = await adminReceiverStatusPage.testReceiverName(); - expect(result).toBe(true); - }); + test("receiver name", async ({adminReceiverStatusPage, isMockDisabled}) => { + test.skip(!isMockDisabled, "Mocks are ENABLED, skipping 'receiver name' test"); + const {organizationName, receiverName, successRate} = + adminReceiverStatusPage.timePeriodData[1]; - test("result message", async ({adminReceiverStatusPage}) => { - const result = await adminReceiverStatusPage.testReceiverMessage(); - expect(result).toBe(true); + const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); + const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); + const expectedReceiverStatusRowTitle = + adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + organizationName, + receiverName, + successRate, + ); + + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); + + await adminReceiverStatusPage.updateFilters({ + receiverName, + }); + + const receiversStatusRowsCount = await receiversStatusRows.count(); + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + await expect(expectedReceiverStatusRow).toBeVisible(); + await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); + + await adminReceiverStatusPage.resetFilters(); + + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); }); + test("result message", async ({adminReceiverStatusPage, isMockDisabled}) => { + test.skip(!isMockDisabled, "Mocks are ENABLED, skipping 'result message' test"); + // get first entry's result from all-fail receiver's first day -> third time period + const receiverI = 0; + const dayI = 0; + const timePeriodI = 2; + const entryI = 0; + const {days} = adminReceiverStatusPage.timePeriodData[receiverI]; + const {connectionCheckResult} = days[dayI].timePeriods[timePeriodI].entries[entryI]; + + const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + + await adminReceiverStatusPage.updateFilters({ + resultMessage: connectionCheckResult, + }); + + for (const [i, {days}] of adminReceiverStatusPage.timePeriodData.entries()) { + const row = receiversStatusRows.nthCustom(i); + + for (const [i, {timePeriods}] of days.entries()) { + const rowDay = row.days.nthCustom(i); + + for (const [i] of timePeriods.entries()) { + const rowDayTimePeriod = rowDay.timePeriods.nth(i); + + await expect(rowDayTimePeriod).toHaveClass(/success-result-hidden/); + } + } + } + + await adminReceiverStatusPage.resetFilters(); + + // TODO: revisit after filters have been fixed per ticket #15737 + // await adminReceiverStatusPage.testReceiverStatusDisplay(); + }); test("success type", async ({ adminReceiverStatusPage }) => { const [failRow, ,] = adminReceiverStatusPage.timePeriodData;