From e749436f7ea3f4508963c518fc46efbf2e6e910b Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Wed, 4 Sep 2024 11:21:51 -0700 Subject: [PATCH 01/13] 15262 - Fixed smoke tests --- .../authenticated/admin/receiver-status.ts | 5 +- .../admin/receiver-status-page.spec.ts | 92 +++++++++++-------- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index a937092350c..309c15d5f87 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -220,6 +220,8 @@ export class AdminReceiverStatusPage extends BasePage { } get receiverStatusRowsLocator() { + // const rows = this.statusContainer.locator("> .perreceiver-row"); + const rows = this.statusContainer.locator("> .grid-row"); return Object.assign(rows, { @@ -310,8 +312,7 @@ export class AdminReceiverStatusPage extends BasePage { if (!isRequestAwaitedBool) return undefined as void; const req = await p; - const reqUrl = req ? new URL(req.url()) : undefined; - return reqUrl; + return req ? new URL(req.url()) : undefined; } async updateFilterDateRange(start: Date, end: Date, inputMethod: "textbox" | "calendar" = "textbox") { diff --git a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts index f8f92d2615b..b2d0d929a4b 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts @@ -83,8 +83,8 @@ test.describe("Admin Receiver Status Page", () => { ); }); - test.describe("When there is no error", () => { - test.describe("Displays correctly", () => { + test.describe("When there is no error",() => { + test.describe("Displays correctly", () => { test.describe( "filters", { @@ -148,23 +148,23 @@ test.describe("Admin Receiver Status Page", () => { expect(result).toBe(true); }); }); - }); - test.describe("Footer", () => { - test("has footer and explicit scroll to footer and scroll to top", async ({ - adminReceiverStatusPage, - }) => { - await adminReceiverStatusPage.testFooter(); - }); + test.describe("Footer", + { + tag: "@smoke", + }, () => { + test("has footer and explicit scroll to footer and scroll to top", async ({ + adminReceiverStatusPage, + }) => { + await adminReceiverStatusPage.testFooter(); + }); + }); }); - test.describe("Functions correctly", () => { - test.describe("filters", () => { + test.describe("Functions correctly",() => { + test.describe("filters",() => { test.describe( "date range", - { - tag: "@smoke", - }, () => { test("works through calendar", async ({ adminReceiverStatusPage }) => { const { valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; @@ -219,6 +219,7 @@ test.describe("Admin Receiver Status Page", () => { adminReceiverStatusPage.timePeriodData[1]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); const expectedReceiverStatusRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( @@ -227,19 +228,20 @@ test.describe("Admin Receiver Status Page", () => { successRate, ); - await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); await adminReceiverStatusPage.updateFilters({ receiverName, }); - await expect(receiversStatusRows).toHaveCount(1); + const receiversStatusRowsCount = await receiversStatusRows.count(); + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); await expect(expectedReceiverStatusRow).toBeVisible(); await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); await adminReceiverStatusPage.resetFilters(); - await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); }); test("result message", async ({ adminReceiverStatusPage }) => { @@ -272,7 +274,7 @@ test.describe("Admin Receiver Status Page", () => { : /^((?!success-result-hidden).)*$/; const rowDayTimePeriod = rowDay.timePeriods.nth(i); - await expect(rowDayTimePeriod).toBeVisible(); + // await expect(rowDayTimePeriod).toBeVisible(); await expect(rowDayTimePeriod).toHaveClass(expectedClass); } } @@ -280,47 +282,57 @@ test.describe("Admin Receiver Status Page", () => { await adminReceiverStatusPage.resetFilters(); - await adminReceiverStatusPage.testReceiverStatusDisplay(); + // TODO: revisit after filters have been fixed per ticket #15737 + // await adminReceiverStatusPage.testReceiverStatusDisplay(); }); test("success type", async ({ adminReceiverStatusPage }) => { - const [failRow, , mixedRow] = adminReceiverStatusPage.timePeriodData; + const [failRow,] = adminReceiverStatusPage.timePeriodData; const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( failRow.organizationName, failRow.receiverName, failRow.successRate, ); - const mixedRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( - mixedRow.organizationName, - mixedRow.receiverName, - mixedRow.successRate, - ); + // const mixedRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + // mixedRow.organizationName, + // mixedRow.receiverName, + // mixedRow.successRate, + // ); const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); const expectedRow = receiversStatusRows.nthCustom(0); - await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); await adminReceiverStatusPage.updateFilters({ successType: "ALL_FAILURE", }); - await expect(receiversStatusRows).toHaveCount(1); + let receiversStatusRowsCount = await receiversStatusRows.count(); + + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); await expect(expectedRow.title).toHaveText(failRowTitle); await adminReceiverStatusPage.updateFilters({ successType: "MIXED_SUCCESS", }); - await expect(receiversStatusRows).toHaveCount(1); - await expect(expectedRow.title).toHaveText(mixedRowTitle); - - await adminReceiverStatusPage.resetFilters(); - - await expect(receiversStatusRows).toHaveCount(4); + receiversStatusRowsCount = await receiversStatusRows.count(); + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + // TODO: revisit after filters have been fixed per ticket #15737 + // await expect(expectedRow.title).toHaveText(mixedRowTitle); + + // await adminReceiverStatusPage.resetFilters(); + // receiversStatusRowsCount = await receiversStatusRows.count(); + // + // expect(receiversStatusRowsCount).toBe(defaultReceiversStatusRowsCount); }); }); test.describe("receiver statuses", () => { - test.describe("date range length changes", () => { + test.describe("date range length changes", + { + tag: "@smoke", + }, () => { test("increases", async ({ adminReceiverStatusPage }) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; const days = rows.nthCustom(0).days; @@ -352,8 +364,10 @@ test.describe("Admin Receiver Status Page", () => { }); }); + // TODO: revisit after filters have been fixed per ticket #15737 test("time period modals", async ({ adminReceiverStatusPage }) => { const overlay = adminReceiverStatusPage.filterFormInputs.dateRange.modalOverlay; + for (const [i, { days }] of adminReceiverStatusPage.timePeriodData.entries()) { const { days: daysLoc } = adminReceiverStatusPage.receiverStatusRowsLocator.nthCustom(i); @@ -393,6 +407,7 @@ test.describe("Admin Receiver Status Page", () => { } }); + // Cannot smoke test since some links are not valid in staging test("receiver org links", async ({ adminReceiverStatusPage }) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; @@ -400,8 +415,8 @@ test.describe("Admin Receiver Status Page", () => { const row = rows.nthCustom(i); const link = row.title.getByRole("link", { - name: organizationName, - }); + name: organizationName,exact: true + }).first(); const expectedUrl = adminReceiverStatusPage.getExpectedStatusOrganizationUrl(i); await expect(link).toBeVisible(); const p = adminReceiverStatusPage.page.route( @@ -426,7 +441,10 @@ test.describe("Admin Receiver Status Page", () => { } }); - test("receiver links", async ({ adminReceiverStatusPage }) => { + test("receiver links", + { + tag: "@smoke", + }, async ({ adminReceiverStatusPage }) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; for (const [i, { receiverName }] of adminReceiverStatusPage.timePeriodData.entries()) { From 844110d0ab8a7c6aab632a2dd7e6aed30f8f92d2 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Thu, 5 Sep 2024 14:03:17 -0700 Subject: [PATCH 02/13] Created receiver-status-page-user-flow.spec.ts and made tests as sanity checks. Moved spec files into correct folders. --- .../authenticated/admin/receiver-status.ts | 161 +++++++-- .../last-mile-failures-page.spec.ts | 6 +- .../{ => admin}/message-details-page.spec.ts | 16 +- .../message-id-search-page.spec.ts | 10 +- .../organization-settings-page.spec.ts | 6 +- .../admin/receiver-status-page.spec.ts | 260 ++++---------- .../receiver-status-page-user-flow.spec.ts | 337 ++++++++++++++++++ 7 files changed, 572 insertions(+), 224 deletions(-) rename frontend-react/e2e/spec/all/authenticated/{ => admin}/last-mile-failures-page.spec.ts (95%) rename frontend-react/e2e/spec/all/authenticated/{ => admin}/message-details-page.spec.ts (93%) rename frontend-react/e2e/spec/all/authenticated/{ => admin}/message-id-search-page.spec.ts (94%) rename frontend-react/e2e/spec/all/authenticated/{ => admin}/organization-settings-page.spec.ts (97%) create mode 100644 frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 309c15d5f87..9aef53e3b9a 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -1,13 +1,15 @@ -import { expect, Locator } from "@playwright/test"; -import { endOfDay, format, startOfDay, subDays } from "date-fns"; -import { RSReceiverStatus } from "../../../../src/hooks/api/UseReceiversConnectionStatus/UseReceiversConnectionStatus"; +import {expect, Locator} from "@playwright/test"; +import {endOfDay, format, startOfDay, subDays} from "date-fns"; +import type {RSOrganizationSettings} from "../../../../src/config/endpoints/settings"; +import {RSReceiverStatus} from "../../../../src/hooks/api/UseReceiversConnectionStatus/UseReceiversConnectionStatus"; import { createStatusTimePeriodData, - SUCCESS_RATE_CLASSNAME_MAP, + SUCCESS_RATE_CLASSNAME_MAP, SuccessRate, } from "../../../../src/pages/admin/receiver-dashboard/utils"; -import { DatePair, dateShortFormat } from "../../../../src/utils/DateTimeUtils"; -import { createMockGetReceiverStatus } from "../../../mocks/receiverStatus"; -import { BasePage, BasePageTestArgs, type ResponseHandlerEntry, type RouteHandlerFulfillEntry } from "../../BasePage"; +import {DatePair, dateShortFormat, durationFormatShort} from "../../../../src/utils/DateTimeUtils"; +import {formatDate} from "../../../../src/utils/misc"; +import {createMockGetReceiverStatus} from "../../../mocks/receiverStatus"; +import {BasePage, BasePageTestArgs, type ResponseHandlerEntry, type RouteHandlerFulfillEntry} from "../../BasePage"; export interface AdminReceiverStatusPageUpdateFiltersProps { dateRange?: { @@ -92,7 +94,7 @@ export class AdminReceiverStatusPage extends BasePage { this._receiverStatus = []; this._timePeriodData = []; - this.filterForm = this.page.getByRole("form", { name: "filter" }); + this.filterForm = this.page.getByRole("form", {name: "filter"}); const dateRangeOverlay = this.page.getByRole("dialog").locator(".usa-modal-overlay"); const dateRangeDefaultValue = [startOfDay(subDays(now, 2)), endOfDay(now)] as DatePair; this.filterFormInputs = { @@ -119,7 +121,7 @@ export class AdminReceiverStatusPage extends BasePage { modalEndButton: dateRangeOverlay.getByRole("button").nth(1), expectedDefaultValue: dateRangeDefaultValue, value: dateRangeDefaultValue, - valueDisplay: this.page.locator("span", { hasText: "🗓" }), + valueDisplay: this.page.locator("span", {hasText: "🗓"}), }, receiverName: { label: this.page.locator("label", { @@ -206,7 +208,7 @@ export class AdminReceiverStatusPage extends BasePage { const endDate = url.searchParams.get("end_date"); const range = startDate && endDate ? ([new Date(startDate), new Date(endDate)] as DatePair) : undefined; this._receiverStatus = data; - this._timePeriodData = range ? this.createTimePeriodData({ data, range }) : []; + this._timePeriodData = range ? this.createTimePeriodData({data, range}) : []; }, ]; } @@ -285,11 +287,11 @@ export class AdminReceiverStatusPage extends BasePage { } async updateFilters({ - dateRange, - receiverName, - resultMessage, - successType, - }: AdminReceiverStatusPageUpdateFiltersProps) { + dateRange, + receiverName, + resultMessage, + successType, + }: AdminReceiverStatusPageUpdateFiltersProps) { // API request will only fire if date ranges are different const isDateRangeDifferent = dateRange == null || this.getIsDateRangesDifferent(this.filterFormInputs.dateRange.value, dateRange.value); @@ -299,7 +301,7 @@ export class AdminReceiverStatusPage extends BasePage { : Promise.resolve(); if (dateRange && isDateRangeDifferent) { - const { value, inputMethod } = dateRange; + const {value, inputMethod} = dateRange; await this.updateFilterDateRange(...value, inputMethod); } if (receiverName != null && receiverName !== this.filterFormInputs.receiverName.value) @@ -386,13 +388,13 @@ export class AdminReceiverStatusPage extends BasePage { } getExpectedStatusOrganizationUrl(rowI: number) { - const { organizationName } = this.timePeriodData[rowI]; + const {organizationName} = this.timePeriodData[rowI]; return `/admin/orgsettings/org/${organizationName}`; } getExpectedStatusReceiverUrl(rowI: number) { - const { organizationName, receiverName } = this.timePeriodData[rowI]; + const {organizationName, receiverName} = this.timePeriodData[rowI]; return `/admin/orgreceiversettings/org/${organizationName}/receiver/${receiverName}/action/edit`; } @@ -401,7 +403,7 @@ export class AdminReceiverStatusPage extends BasePage { return a[0] !== b[0] && a[1] !== b[1]; } - async testReceiverStatusDisplay() { + async testReceiverStatusDisplay(isSmoke = false) { const [startDate, endDate] = this.filterFormInputs.dateRange.value; const statusRows = this.receiverStatusRowsLocator; await expect(statusRows).toHaveCount(new Set(this.receiverStatus?.map((r) => r.receiverId)).size); @@ -413,9 +415,9 @@ export class AdminReceiverStatusPage extends BasePage { ].join(" "); for (const [ i, - { days, successRate, organizationName, receiverName, successRateType }, + {days, successRate, organizationName, receiverName, successRateType}, ] of this.timePeriodData.entries()) { - const { title, display, days: daysLoc } = statusRows.nthCustom(i); + const {title, display, days: daysLoc} = statusRows.nthCustom(i); const expectedTitleText = this.getExpectedReceiverStatusRowTitle( organizationName, @@ -433,11 +435,11 @@ export class AdminReceiverStatusPage extends BasePage { await expect(daysLoc).toHaveCount(days.length); - for (const [i, { timePeriods }] of days.entries()) { + for (const [i, {timePeriods}] of days.entries()) { const daySlices = daysLoc.nthCustom(i).timePeriods; await expect(daySlices).toHaveCount(timePeriods.length); - for (const [i, { successRateType }] of timePeriods.entries()) { + for (const [i, {successRateType}] of timePeriods.entries()) { const sliceEle = daySlices.nth(i); const expectedClass = new RegExp(SUCCESS_RATE_CLASSNAME_MAP[successRateType]); @@ -445,6 +447,119 @@ export class AdminReceiverStatusPage extends BasePage { await expect(sliceEle).toHaveClass(expectedClass); } } + + if (isSmoke && i === 0) { + break; + } + } + + return true; + } + + async testReceiverOrgLinks(isSmoke = false) { + const rows = this.receiverStatusRowsLocator; + + for (const [i, {organizationName}] of this.timePeriodData.entries()) { + const row = rows.nthCustom(i); + + const link = row.title.getByRole("link", {name: organizationName, exact: true}).first(); + const expectedUrl = this.getExpectedStatusOrganizationUrl(i); + await expect(link).toBeVisible(); + const p = this.page.route( + `/api/settings/organizations/${organizationName}`, + (route) => + route.fulfill({ + json: { + description: "fake", + filters: [], + name: organizationName, + jurisdiction: "fake", + version: 0, + createdAt: "", + createdBy: "", + } satisfies RSOrganizationSettings, + }), + ); + await link.click(); + await expect(this.page).toHaveURL(expectedUrl); + await p; + await this.page.goBack(); + + if (isSmoke && i === 0) { + break; + } + } + + return true; + } + + async testReceiverTimePeriodModals(isSmoke = false) { + const overlay = this.filterFormInputs.dateRange.modalOverlay; + + for (const [i, {days}] of this.timePeriodData.entries()) { + const {days: daysLoc} = this.receiverStatusRowsLocator.nthCustom(i); + + for (const [dayI, day] of days.entries()) { + for (const [i, {successRateType, entries}] of day.timePeriods.entries()) { + // only first entry in time period is currently displayed + const { + organizationName, + organizationId, + receiverId, + receiverName, + connectionCheckSuccessful, + connectionCheckStartedAt, + connectionCheckCompletedAt, + connectionCheckResult, + } = entries[0] ?? {}; + const sliceEle = daysLoc.nthCustom(dayI).timePeriods.nth(i); + + const isModalExpectedVisible = successRateType !== SuccessRate.UNDEFINED; + + await sliceEle.click({force: true}); + await expect(overlay).toBeAttached({ + attached: isModalExpectedVisible, + }); + + if (isModalExpectedVisible) { + const expectedResultText = connectionCheckSuccessful ? "success" : "failed"; + const expectedModalText = `Results for connection verification checkOrg:${organizationName} (id: ${organizationId})Receiver:${receiverName} (id: ${receiverId})Result:${expectedResultText}Started At:${formatDate(connectionCheckStartedAt)}${connectionCheckStartedAt.toISOString()}Time to complete:${durationFormatShort(connectionCheckCompletedAt, connectionCheckStartedAt)}Result message:${connectionCheckResult}`; + + await expect(overlay).toBeVisible(); + await expect(overlay).toHaveText(expectedModalText); + + await overlay.press("Escape"); + } + } + } + + if (isSmoke && i === 0) { + break; + } + } + + return true; + } + + async testReceiverLinks(isSmoke = false) { + const rows = this.receiverStatusRowsLocator; + + for (const [i, {receiverName}] of this.timePeriodData.entries()) { + const row = rows.nthCustom(i); + + const link = row.title.getByRole("link", { + name: receiverName, + }); + await expect(link).toBeVisible(); + await link.click(); + await expect(this.page).toHaveURL( + this.getExpectedStatusReceiverUrl(i), + ); + await this.page.goBack(); + + if (isSmoke && i === 0) { + break; + } } return true; diff --git a/frontend-react/e2e/spec/all/authenticated/last-mile-failures-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/last-mile-failures-page.spec.ts similarity index 95% rename from frontend-react/e2e/spec/all/authenticated/last-mile-failures-page.spec.ts rename to frontend-react/e2e/spec/all/authenticated/admin/last-mile-failures-page.spec.ts index df8503376bb..ba01d3812c2 100644 --- a/frontend-react/e2e/spec/all/authenticated/last-mile-failures-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/last-mile-failures-page.spec.ts @@ -1,6 +1,6 @@ -import { tableRows } from "../../../helpers/utils"; -import { LastMileFailuresPage } from "../../../pages/authenticated/last-mile-failures"; -import { test as baseTest, expect } from "../../../test"; +import { tableRows } from "../../../../helpers/utils"; +import { LastMileFailuresPage } from "../../../../pages/authenticated/last-mile-failures"; +import { test as baseTest, expect } from "../../../../test"; export interface LastMileFailuresPageFixtures { lastMileFailuresPage: LastMileFailuresPage; diff --git a/frontend-react/e2e/spec/all/authenticated/message-details-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/message-details-page.spec.ts similarity index 93% rename from frontend-react/e2e/spec/all/authenticated/message-details-page.spec.ts rename to frontend-react/e2e/spec/all/authenticated/admin/message-details-page.spec.ts index 916b14b1096..2a101640d8c 100644 --- a/frontend-react/e2e/spec/all/authenticated/message-details-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/message-details-page.spec.ts @@ -1,12 +1,12 @@ import fs from "node:fs"; -import { parseFileLocation } from "../../../../src/utils/misc"; -import { tableRows } from "../../../helpers/utils"; -import { MOCK_GET_MESSAGE } from "../../../mocks/messages"; -import { MessageDetailsPage } from "../../../pages/authenticated/message-details"; -import { MessageIDSearchPage } from "../../../pages/authenticated/message-id-search"; -import { mockGetHistoryReportResponse } from "../../../pages/authenticated/report-details"; - -import { test as baseTest, expect } from "../../../test"; +import { parseFileLocation } from "../../../../../src/utils/misc"; +import { tableRows } from "../../../../helpers/utils"; +import { MOCK_GET_MESSAGE } from "../../../../mocks/messages"; +import { MessageDetailsPage } from "../../../../pages/authenticated/message-details"; +import { MessageIDSearchPage } from "../../../../pages/authenticated/message-id-search"; +import { mockGetHistoryReportResponse } from "../../../../pages/authenticated/report-details"; + +import { test as baseTest, expect } from "../../../../test"; export interface MessageDetailsPageFixtures { messageDetailsPage: MessageDetailsPage; diff --git a/frontend-react/e2e/spec/all/authenticated/message-id-search-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/message-id-search-page.spec.ts similarity index 94% rename from frontend-react/e2e/spec/all/authenticated/message-id-search-page.spec.ts rename to frontend-react/e2e/spec/all/authenticated/admin/message-id-search-page.spec.ts index 9de8e807739..2ac84973da4 100644 --- a/frontend-react/e2e/spec/all/authenticated/message-id-search-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/message-id-search-page.spec.ts @@ -1,9 +1,9 @@ -import { noData, tableRows } from "../../../helpers/utils"; -import { MOCK_GET_MESSAGES } from "../../../mocks/messages"; -import { MessageIDSearchPage } from "../../../pages/authenticated/message-id-search"; -import { openReportIdDetailPage } from "../../../pages/authenticated/submission-history"; +import { noData, tableRows } from "../../../../helpers/utils"; +import { MOCK_GET_MESSAGES } from "../../../../mocks/messages"; +import { MessageIDSearchPage } from "../../../../pages/authenticated/message-id-search"; +import { openReportIdDetailPage } from "../../../../pages/authenticated/submission-history"; -import { test as baseTest, expect } from "../../../test"; +import { test as baseTest, expect } from "../../../../test"; export interface MessageIDSearchPageFixtures { messageIDSearchPage: MessageIDSearchPage; diff --git a/frontend-react/e2e/spec/all/authenticated/organization-settings-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts similarity index 97% rename from frontend-react/e2e/spec/all/authenticated/organization-settings-page.spec.ts rename to frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts index 83ce97b9e2a..7ba068638d9 100644 --- a/frontend-react/e2e/spec/all/authenticated/organization-settings-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts @@ -2,9 +2,9 @@ import { expect } from "@playwright/test"; import { readFileSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; -import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../mocks/organizations"; -import { OrganizationPage } from "../../../pages/authenticated/organization"; -import { test as baseTest } from "../../../test"; +import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../../mocks/organizations"; +import { OrganizationPage } from "../../../../pages/authenticated/organization"; +import { test as baseTest } from "../../../../test"; const __dirname = fileURLToPath(import.meta.url); diff --git a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts index b2d0d929a4b..c539a824ed5 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts @@ -1,10 +1,10 @@ -import { addDays, endOfDay, startOfDay, subDays } from "date-fns"; -import type { RSOrganizationSettings } from "../../../../../src/config/endpoints/settings"; -import { SuccessRate } from "../../../../../src/pages/admin/receiver-dashboard/utils"; -import { durationFormatShort } from "../../../../../src/utils/DateTimeUtils"; -import { formatDate } from "../../../../../src/utils/misc"; -import { AdminReceiverStatusPage } from "../../../../pages/authenticated/admin/receiver-status"; -import { test as baseTest, expect, logins } from "../../../../test"; +import {addDays, endOfDay, startOfDay, subDays} from "date-fns"; +import type {RSOrganizationSettings} from "../../../../../src/config/endpoints/settings"; +import {SuccessRate} from "../../../../../src/pages/admin/receiver-dashboard/utils"; +import {durationFormatShort} from "../../../../../src/utils/DateTimeUtils"; +import {formatDate} from "../../../../../src/utils/misc"; +import {AdminReceiverStatusPage} from "../../../../pages/authenticated/admin/receiver-status"; +import {test as baseTest, expect, logins} from "../../../../test"; export interface AdminReceiverStatusPageFixtures { adminReceiverStatusPage: AdminReceiverStatusPage; @@ -42,29 +42,29 @@ const test = baseTest.extend({ test.describe("Admin Receiver Status Page", () => { test.describe("not authenticated", () => { - test("redirects to login", async ({ adminReceiverStatusPage }) => { + test("redirects to login", async ({adminReceiverStatusPage}) => { await expect(adminReceiverStatusPage.page).toHaveURL("/login"); }); }); test.describe("authenticated receiver", () => { - test.use({ storageState: logins.receiver.path }); - test("returns Page Not Found", async ({ adminReceiverStatusPage }) => { + test.use({storageState: logins.receiver.path}); + test("returns Page Not Found", async ({adminReceiverStatusPage}) => { await expect(adminReceiverStatusPage.page).toHaveTitle(/Page Not Found/); }); }); test.describe("authenticated sender", () => { - test.use({ storageState: logins.sender.path }); - test("returns Page Not Found", async ({ adminReceiverStatusPage }) => { + test.use({storageState: logins.sender.path}); + test("returns Page Not Found", async ({adminReceiverStatusPage}) => { await expect(adminReceiverStatusPage.page).toHaveTitle(/Page Not Found/); }); }); test.describe("authenticated admin", () => { - test.use({ storageState: logins.admin.path }); + test.use({storageState: logins.admin.path}); - test("If there is an error, the error is shown on the page", async ({ adminReceiverStatusPage }) => { + test("If there is an error, the error is shown on the page", async ({adminReceiverStatusPage}) => { adminReceiverStatusPage.mockError = true; await adminReceiverStatusPage.reload(); @@ -74,25 +74,19 @@ test.describe("Admin Receiver Status Page", () => { test.describe("Header", () => { test( "has correct title + heading", - { - tag: "@smoke", - }, - async ({ adminReceiverStatusPage }) => { + async ({adminReceiverStatusPage}) => { await adminReceiverStatusPage.testHeader(); }, ); }); - test.describe("When there is no error",() => { - test.describe("Displays correctly", () => { + test.describe("When there is no error", () => { + test.describe("Displays correctly", () => { test.describe( "filters", - { - tag: "@smoke", - }, () => { - test("date range", async ({ adminReceiverStatusPage }) => { - const { button, label, modalOverlay, valueDisplay } = + test("date range", async ({adminReceiverStatusPage}) => { + const {button, label, modalOverlay, valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; await expect(label).toBeVisible(); await expect(button).toBeVisible(); @@ -100,8 +94,8 @@ test.describe("Admin Receiver Status Page", () => { await expect(modalOverlay).toBeHidden(); }); - test("receiver name", async ({ adminReceiverStatusPage }) => { - const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = + test("receiver name", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = adminReceiverStatusPage.filterFormInputs.receiverName; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -113,8 +107,8 @@ test.describe("Admin Receiver Status Page", () => { await expect(tooltip).toHaveText(expectedTooltipText); }); - test("results message", async ({ adminReceiverStatusPage }) => { - const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = + test("results message", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = adminReceiverStatusPage.filterFormInputs.resultMessage; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -126,8 +120,8 @@ test.describe("Admin Receiver Status Page", () => { await expect(tooltip).toHaveText(expectedTooltipText); }); - test("success type", async ({ adminReceiverStatusPage }) => { - const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = + test("success type", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = adminReceiverStatusPage.filterFormInputs.successType; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -143,31 +137,28 @@ test.describe("Admin Receiver Status Page", () => { // Failures here indicate potential misalignment of playwright/browser timezone test.describe("receiver statuses", () => { - test("time periods", async ({ adminReceiverStatusPage }) => { + test("time periods", async ({adminReceiverStatusPage}) => { const result = await adminReceiverStatusPage.testReceiverStatusDisplay(); expect(result).toBe(true); }); }); + }); - test.describe("Footer", - { - tag: "@smoke", - }, () => { - test("has footer and explicit scroll to footer and scroll to top", async ({ - adminReceiverStatusPage, - }) => { - await adminReceiverStatusPage.testFooter(); - }); - }); + test.describe("Footer", () => { + test("has footer and explicit scroll to footer and scroll to top", async ({ + adminReceiverStatusPage, + }) => { + await adminReceiverStatusPage.testFooter(); + }); }); - test.describe("Functions correctly",() => { - test.describe("filters",() => { + test.describe("Functions correctly", () => { + test.describe("filters", () => { test.describe( "date range", () => { - test("works through calendar", async ({ adminReceiverStatusPage }) => { - const { valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; + test("works through calendar", async ({adminReceiverStatusPage}) => { + const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; const now = new Date(); const targetFrom = startOfDay(subDays(now, 3)); const targetTo = addDays(endOfDay(now), 1); @@ -188,8 +179,8 @@ test.describe("Admin Receiver Status Page", () => { }); }); - test("works through textboxes", async ({ adminReceiverStatusPage }) => { - const { valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; + test("works through textboxes", async ({adminReceiverStatusPage}) => { + const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; await expect(adminReceiverStatusPage.receiverStatusRowsLocator).not.toHaveCount(0); const now = new Date(); const targetFrom = startOfDay(subDays(now, 3)); @@ -214,12 +205,11 @@ test.describe("Admin Receiver Status Page", () => { }, ); - test("receiver name", async ({ adminReceiverStatusPage }) => { - const { organizationName, receiverName, successRate } = + test("receiver name", async ({adminReceiverStatusPage}) => { + const {organizationName, receiverName, successRate} = adminReceiverStatusPage.timePeriodData[1]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; - const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); const expectedReceiverStatusRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( @@ -228,30 +218,29 @@ test.describe("Admin Receiver Status Page", () => { successRate, ); - expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); + await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); await adminReceiverStatusPage.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 adminReceiverStatusPage.resetFilters(); - expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); + await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); }); - test("result message", async ({ adminReceiverStatusPage }) => { + test("result message", async ({adminReceiverStatusPage}) => { // 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 {days} = adminReceiverStatusPage.timePeriodData[receiverI]; + const {connectionCheckResult} = days[dayI].timePeriods[timePeriodI].entries[entryI]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; @@ -259,11 +248,11 @@ test.describe("Admin Receiver Status Page", () => { resultMessage: connectionCheckResult, }); - for (const [i, { days }] of adminReceiverStatusPage.timePeriodData.entries()) { + for (const [i, {days}] of adminReceiverStatusPage.timePeriodData.entries()) { const isRowExpected = i === receiverI; const row = receiversStatusRows.nthCustom(i); - for (const [i, { timePeriods }] of days.entries()) { + for (const [i, {timePeriods}] of days.entries()) { const isDayExpected = isRowExpected && i === dayI; const rowDay = row.days.nthCustom(i); @@ -274,7 +263,7 @@ test.describe("Admin Receiver Status Page", () => { : /^((?!success-result-hidden).)*$/; const rowDayTimePeriod = rowDay.timePeriods.nth(i); - // await expect(rowDayTimePeriod).toBeVisible(); + await expect(rowDayTimePeriod).toBeVisible(); await expect(rowDayTimePeriod).toHaveClass(expectedClass); } } @@ -282,58 +271,48 @@ test.describe("Admin Receiver Status Page", () => { await adminReceiverStatusPage.resetFilters(); - // TODO: revisit after filters have been fixed per ticket #15737 - // await adminReceiverStatusPage.testReceiverStatusDisplay(); + await adminReceiverStatusPage.testReceiverStatusDisplay(); }); - test("success type", async ({ adminReceiverStatusPage }) => { - const [failRow,] = adminReceiverStatusPage.timePeriodData; + test("success type", async ({adminReceiverStatusPage}) => { + const [failRow, , mixedRow] = adminReceiverStatusPage.timePeriodData; const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( failRow.organizationName, failRow.receiverName, failRow.successRate, ); - // const mixedRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( - // mixedRow.organizationName, - // mixedRow.receiverName, - // mixedRow.successRate, - // ); + const mixedRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + mixedRow.organizationName, + mixedRow.receiverName, + mixedRow.successRate, + ); const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; - const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); const expectedRow = receiversStatusRows.nthCustom(0); - expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); + await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); await adminReceiverStatusPage.updateFilters({ successType: "ALL_FAILURE", }); - let receiversStatusRowsCount = await receiversStatusRows.count(); - - expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + await expect(receiversStatusRows).toHaveCount(1); await expect(expectedRow.title).toHaveText(failRowTitle); await adminReceiverStatusPage.updateFilters({ successType: "MIXED_SUCCESS", }); - receiversStatusRowsCount = await receiversStatusRows.count(); - expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); - // TODO: revisit after filters have been fixed per ticket #15737 - // await expect(expectedRow.title).toHaveText(mixedRowTitle); - - // await adminReceiverStatusPage.resetFilters(); - // receiversStatusRowsCount = await receiversStatusRows.count(); - // - // expect(receiversStatusRowsCount).toBe(defaultReceiversStatusRowsCount); + await expect(receiversStatusRows).toHaveCount(1); + await expect(expectedRow.title).toHaveText(mixedRowTitle); + + await adminReceiverStatusPage.resetFilters(); + + await expect(receiversStatusRows).toHaveCount(4); }); }); test.describe("receiver statuses", () => { - test.describe("date range length changes", - { - tag: "@smoke", - }, () => { - test("increases", async ({ adminReceiverStatusPage }) => { + test.describe("date range length changes", () => { + test("increases", async ({adminReceiverStatusPage}) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; const days = rows.nthCustom(0).days; await expect(rows).not.toHaveCount(0); @@ -348,7 +327,7 @@ test.describe("Admin Receiver Status Page", () => { await expect(days).toHaveCount(4); }); - test("decreases", async ({ adminReceiverStatusPage }) => { + test("decreases", async ({adminReceiverStatusPage}) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; const days = rows.nthCustom(0).days; await expect(rows).not.toHaveCount(0); @@ -364,102 +343,19 @@ test.describe("Admin Receiver Status Page", () => { }); }); - // TODO: revisit after filters have been fixed per ticket #15737 - test("time period modals", async ({ adminReceiverStatusPage }) => { - const overlay = adminReceiverStatusPage.filterFormInputs.dateRange.modalOverlay; - - for (const [i, { days }] of adminReceiverStatusPage.timePeriodData.entries()) { - const { days: daysLoc } = adminReceiverStatusPage.receiverStatusRowsLocator.nthCustom(i); - - for (const [dayI, day] of days.entries()) { - for (const [i, { successRateType, entries }] of day.timePeriods.entries()) { - // only first entry in time period is currently displayed - const { - organizationName, - organizationId, - receiverId, - receiverName, - connectionCheckSuccessful, - connectionCheckStartedAt, - connectionCheckCompletedAt, - connectionCheckResult, - } = entries[0] ?? {}; - const sliceEle = daysLoc.nthCustom(dayI).timePeriods.nth(i); - - const isModalExpectedVisible = successRateType !== SuccessRate.UNDEFINED; - - await sliceEle.click({ force: true }); - await expect(overlay).toBeAttached({ - attached: isModalExpectedVisible, - }); - - if (isModalExpectedVisible) { - const expectedResultText = connectionCheckSuccessful ? "success" : "failed"; - const expectedModalText = `Results for connection verification checkOrg:${organizationName} (id: ${organizationId})Receiver:${receiverName} (id: ${receiverId})Result:${expectedResultText}Started At:${formatDate(connectionCheckStartedAt)}${connectionCheckStartedAt.toISOString()}Time to complete:${durationFormatShort(connectionCheckCompletedAt, connectionCheckStartedAt)}Result message:${connectionCheckResult}`; - - await expect(overlay).toBeVisible(); - await expect(overlay).toHaveText(expectedModalText); - - await overlay.press("Escape"); - } - } - } - } + test("time period modals", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverTimePeriodModals(); + expect(result).toBe(true); }); - // Cannot smoke test since some links are not valid in staging - test("receiver org links", async ({ adminReceiverStatusPage }) => { - const rows = adminReceiverStatusPage.receiverStatusRowsLocator; - - for (const [i, { organizationName }] of adminReceiverStatusPage.timePeriodData.entries()) { - const row = rows.nthCustom(i); - - const link = row.title.getByRole("link", { - name: organizationName,exact: true - }).first(); - const expectedUrl = adminReceiverStatusPage.getExpectedStatusOrganizationUrl(i); - await expect(link).toBeVisible(); - const p = adminReceiverStatusPage.page.route( - `api/settings/organizations/${organizationName}`, - (route) => - route.fulfill({ - json: { - description: "fake", - filters: [], - name: organizationName, - jurisdiction: "fake", - version: 0, - createdAt: "", - createdBy: "", - } satisfies RSOrganizationSettings, - }), - ); - await link.click(); - await expect(adminReceiverStatusPage.page).toHaveURL(expectedUrl); - await p; - await adminReceiverStatusPage.page.goBack(); - } + test("receiver org links", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverOrgLinks(); + expect(result).toBe(true); }); - test("receiver links", - { - tag: "@smoke", - }, async ({ adminReceiverStatusPage }) => { - const rows = adminReceiverStatusPage.receiverStatusRowsLocator; - - for (const [i, { receiverName }] of adminReceiverStatusPage.timePeriodData.entries()) { - const row = rows.nthCustom(i); - - const link = row.title.getByRole("link", { - name: receiverName, - }); - await expect(link).toBeVisible(); - await link.click(); - await expect(adminReceiverStatusPage.page).toHaveURL( - adminReceiverStatusPage.getExpectedStatusReceiverUrl(i), - ); - await adminReceiverStatusPage.page.goBack(); - } + test("receiver links", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverLinks(); + expect(result).toBe(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 new file mode 100644 index 00000000000..00bb645049d --- /dev/null +++ b/frontend-react/e2e/spec/chromium-only/authenticated/receiver-status-page-user-flow.spec.ts @@ -0,0 +1,337 @@ +import {addDays, endOfDay, startOfDay, subDays} from "date-fns"; +import type {RSOrganizationSettings} from "../../../../src/config/endpoints/settings"; +import {SuccessRate} from "../../../../src/pages/admin/receiver-dashboard/utils"; +import {durationFormatShort} from "../../../../src/utils/DateTimeUtils"; +import {formatDate} from "../../../../src/utils/misc"; +import {AdminReceiverStatusPage} from "../../../pages/authenticated/admin/receiver-status"; +import {test as baseTest, expect, logins} from "../../../test"; + +export interface AdminReceiverStatusPageFixtures { + adminReceiverStatusPage: AdminReceiverStatusPage; +} + +const test = baseTest.extend({ + adminReceiverStatusPage: async ( + { + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + frontendWarningsLogPath, + isFrontendWarningsLog, + }, + use, + ) => { + const page = new AdminReceiverStatusPage({ + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + isFrontendWarningsLog, + frontendWarningsLogPath, + isTestOrg: true, + }); + await page.goto(); + await use(page); + }, +}); + +test.describe("Admin Receiver Status Page", + { + tag: "@smoke", + }, () => { + test.use({storageState: logins.admin.path}); + test.describe("displays correctly", () => { + test.describe("header", () => { + test( + "has correct title + heading", + async ({adminReceiverStatusPage}) => { + await adminReceiverStatusPage.testHeader(); + }, + ); + }); + + test.describe( + "filters", + () => { + test("date range", async ({adminReceiverStatusPage}) => { + const {button, label, modalOverlay, valueDisplay} = + adminReceiverStatusPage.filterFormInputs.dateRange; + await expect(label).toBeVisible(); + await expect(button).toBeVisible(); + await expect(valueDisplay).toHaveText(adminReceiverStatusPage.expectedDateRangeLabelText); + await expect(modalOverlay).toBeHidden(); + }); + + test("receiver name", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + adminReceiverStatusPage.filterFormInputs.receiverName; + await expect(label).toBeVisible(); + await expect(input).toBeVisible(); + await expect(input).toHaveValue(expectedDefaultValue); + + await expect(tooltip).toBeHidden(); + await input.hover(); + await expect(tooltip).toBeVisible(); + await expect(tooltip).toHaveText(expectedTooltipText); + }); + + test("results message", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + adminReceiverStatusPage.filterFormInputs.resultMessage; + await expect(label).toBeVisible(); + await expect(input).toBeVisible(); + await expect(input).toHaveValue(expectedDefaultValue); + + await expect(tooltip).toBeHidden(); + await input.hover(); + await expect(tooltip).toBeVisible(); + await expect(tooltip).toHaveText(expectedTooltipText); + }); + + test("success type", async ({adminReceiverStatusPage}) => { + const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + adminReceiverStatusPage.filterFormInputs.successType; + await expect(label).toBeVisible(); + await expect(input).toBeVisible(); + await expect(input).toHaveValue(expectedDefaultValue); + + await expect(tooltip).toBeHidden(); + await input.hover(); + await expect(tooltip).toBeVisible(); + await expect(tooltip).toHaveText(expectedTooltipText); + }); + }, + ); + + // Failures here indicate potential misalignment of playwright/browser timezone + test.describe("receiver statuses", () => { + test("time periods", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverStatusDisplay(true); + expect(result).toBe(true); + }); + }); + + test.describe("has footer", () => { + test("has footer and explicit scroll to footer and scroll to top", async ({ + adminReceiverStatusPage, + }) => { + await adminReceiverStatusPage.testFooter(); + }); + }); + }); + + test.describe("functions correctly", () => { + test.describe("filters", () => { + test.describe( + "date range", + () => { + test("works through calendar", async ({adminReceiverStatusPage}) => { + const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; + const now = new Date(); + const targetFrom = startOfDay(subDays(now, 3)); + const targetTo = addDays(endOfDay(now), 1); + + const reqUrl = await adminReceiverStatusPage.updateFilters({ + dateRange: { + value: [targetFrom, targetTo], + }, + }); + expect(reqUrl).toBeDefined(); + + await expect(valueDisplay).toHaveText( + adminReceiverStatusPage.expectedDateRangeLabelText, + ); + expect(Object.fromEntries(reqUrl!.searchParams.entries())).toMatchObject({ + start_date: targetFrom.toISOString(), + end_date: targetTo.toISOString(), + }); + }); + + test("works through textboxes", async ({adminReceiverStatusPage}) => { + const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; + await expect(adminReceiverStatusPage.receiverStatusRowsLocator).not.toHaveCount(0); + const now = new Date(); + const targetFrom = startOfDay(subDays(now, 3)); + const targetTo = addDays(endOfDay(now), 1); + + const reqUrl = await adminReceiverStatusPage.updateFilters({ + dateRange: { + value: [targetFrom, targetTo], + }, + }); + + expect(reqUrl).toBeDefined(); + + await expect(valueDisplay).toHaveText( + adminReceiverStatusPage.expectedDateRangeLabelText, + ); + expect(Object.fromEntries(reqUrl!.searchParams.entries())).toMatchObject({ + start_date: targetFrom.toISOString(), + end_date: targetTo.toISOString(), + }); + }); + }, + ); + + test("receiver name", async ({adminReceiverStatusPage}) => { + const {organizationName, receiverName, successRate} = + adminReceiverStatusPage.timePeriodData[1]; + + 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}) => { + // 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; + const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + failRow.organizationName, + failRow.receiverName, + failRow.successRate, + ); + // const mixedRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + // mixedRow.organizationName, + // mixedRow.receiverName, + // mixedRow.successRate, + // ); + + const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); + const expectedRow = receiversStatusRows.nthCustom(0); + + expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); + + await adminReceiverStatusPage.updateFilters({ + successType: "ALL_FAILURE", + }); + let receiversStatusRowsCount = await receiversStatusRows.count(); + + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + await expect(expectedRow.title).toHaveText(failRowTitle); + + await adminReceiverStatusPage.updateFilters({ + successType: "MIXED_SUCCESS", + }); + receiversStatusRowsCount = await receiversStatusRows.count(); + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + // TODO: revisit after filters have been fixed per ticket #15737 + // await expect(expectedRow.title).toHaveText(mixedRowTitle); + + // await adminReceiverStatusPage.resetFilters(); + // receiversStatusRowsCount = await receiversStatusRows.count(); + // + // expect(receiversStatusRowsCount).toBe(defaultReceiversStatusRowsCount); + }); + }); + + test.describe("receiver statuses", () => { + test.describe("date range length changes", () => { + test("increases", async ({adminReceiverStatusPage}) => { + const rows = adminReceiverStatusPage.receiverStatusRowsLocator; + const days = rows.nthCustom(0).days; + await expect(rows).not.toHaveCount(0); + const now = new Date(); + const targetFrom = startOfDay(subDays(now, 3)); + const targetTo = endOfDay(now); + await adminReceiverStatusPage.updateFilters({ + dateRange: { + value: [targetFrom, targetTo], + }, + }); + await expect(days).toHaveCount(4); + }); + + test("decreases", async ({adminReceiverStatusPage}) => { + const rows = adminReceiverStatusPage.receiverStatusRowsLocator; + const days = rows.nthCustom(0).days; + await expect(rows).not.toHaveCount(0); + const now = new Date(); + const targetFrom = startOfDay(subDays(now, 1)); + const targetTo = endOfDay(now); + await adminReceiverStatusPage.updateFilters({ + dateRange: { + value: [targetFrom, targetTo], + }, + }); + await expect(days).toHaveCount(2); + }); + }); + + test("time period modals", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverTimePeriodModals(true); + expect(result).toBe(true); + }); + + test("receiver org links", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverOrgLinks(true); + expect(result).toBe(true); + }); + + test("receiver links", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverLinks(true); + expect(result).toBe(true); + }); + }); + }); + }); From 3192545078c7306a046765eaaa726aae68fb310b Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Thu, 5 Sep 2024 14:29:34 -0700 Subject: [PATCH 03/13] Fixed linting --- .../spec/all/authenticated/admin/receiver-status-page.spec.ts | 4 ---- .../authenticated/receiver-status-page-user-flow.spec.ts | 4 ---- 2 files changed, 8 deletions(-) diff --git a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts index c539a824ed5..1ccd3779a3a 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts @@ -1,8 +1,4 @@ import {addDays, endOfDay, startOfDay, subDays} from "date-fns"; -import type {RSOrganizationSettings} from "../../../../../src/config/endpoints/settings"; -import {SuccessRate} from "../../../../../src/pages/admin/receiver-dashboard/utils"; -import {durationFormatShort} from "../../../../../src/utils/DateTimeUtils"; -import {formatDate} from "../../../../../src/utils/misc"; import {AdminReceiverStatusPage} from "../../../../pages/authenticated/admin/receiver-status"; import {test as baseTest, expect, logins} from "../../../../test"; 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 00bb645049d..f95e8752a4e 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 @@ -1,8 +1,4 @@ import {addDays, endOfDay, startOfDay, subDays} from "date-fns"; -import type {RSOrganizationSettings} from "../../../../src/config/endpoints/settings"; -import {SuccessRate} from "../../../../src/pages/admin/receiver-dashboard/utils"; -import {durationFormatShort} from "../../../../src/utils/DateTimeUtils"; -import {formatDate} from "../../../../src/utils/misc"; import {AdminReceiverStatusPage} from "../../../pages/authenticated/admin/receiver-status"; import {test as baseTest, expect, logins} from "../../../test"; From 44e220a572279dd283feb5808625d48a63bc7d32 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Thu, 5 Sep 2024 16:36:26 -0700 Subject: [PATCH 04/13] Fixed path --- .../admin/organization-settings-page.spec.ts | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts index 7ba068638d9..f57ef8cb13a 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts @@ -1,10 +1,10 @@ -import { expect } from "@playwright/test"; -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import { fileURLToPath } from "node:url"; -import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../../mocks/organizations"; -import { OrganizationPage } from "../../../../pages/authenticated/organization"; -import { test as baseTest } from "../../../../test"; +import {expect} from "@playwright/test"; +import {readFileSync} from "node:fs"; +import {join} from "node:path"; +import {fileURLToPath} from "node:url"; +import {MOCK_GET_ORGANIZATION_SETTINGS_LIST} from "../../../../mocks/organizations"; +import {OrganizationPage} from "../../../../pages/authenticated/organization"; +import {test as baseTest} from "../../../../test"; const __dirname = fileURLToPath(import.meta.url); @@ -43,35 +43,35 @@ const test = baseTest.extend({ test.describe("Admin Organization Settings Page", () => { test.describe("not authenticated", () => { - test("redirects to login", async ({ organizationPage }) => { + test("redirects to login", async ({organizationPage}) => { await expect(organizationPage.page).toHaveURL("/login"); }); }); test.describe("authenticated receiver", () => { - test.use({ storageState: "e2e/.auth/receiver.json" }); - test("returns Page Not Found", async ({ organizationPage }) => { + test.use({storageState: "e2e/.auth/receiver.json"}); + test("returns Page Not Found", async ({organizationPage}) => { await expect(organizationPage.page).toHaveTitle(/Page Not Found/); }); }); test.describe("authenticated sender", () => { - test.use({ storageState: "e2e/.auth/sender.json" }); - test("returns Page Not Found", async ({ organizationPage }) => { + test.use({storageState: "e2e/.auth/sender.json"}); + test("returns Page Not Found", async ({organizationPage}) => { await expect(organizationPage.page).toHaveTitle(/Page Not Found/); }); }); test.describe("authenticated admin", () => { - test.use({ storageState: "e2e/.auth/admin.json" }); + test.use({storageState: "e2e/.auth/admin.json"}); test.describe("Header", () => { - test("has correct title + heading", async ({ organizationPage }) => { + test("has correct title + heading", async ({organizationPage}) => { await organizationPage.testHeader(); }); }); - test("If there is an error, the error is shown on the page", async ({ organizationPage }) => { + test("If there is an error, the error is shown on the page", async ({organizationPage}) => { organizationPage.mockError = true; await organizationPage.reload(); await expect(organizationPage.page.getByText("there was an error")).toBeVisible(); @@ -79,8 +79,8 @@ test.describe("Admin Organization Settings Page", () => { test.describe("When there is no error", () => { test("nav contains the 'Admin tools' dropdown with 'Organization Settings' option", async ({ - organizationPage, - }) => { + organizationPage, + }) => { const navItems = organizationPage.page.locator(".usa-nav li"); await expect(navItems).toContainText(["Admin tools"]); @@ -96,12 +96,12 @@ test.describe("Admin Organization Settings Page", () => { await expect(organizationPage.page).toHaveURL("/admin/settings"); }); - test("Has correct title", async ({ organizationPage }) => { + test("Has correct title", async ({organizationPage}) => { await expect(organizationPage.page).toHaveURL(/settings/); await expect(organizationPage.page).toHaveTitle(/Admin-Organizations/); }); - test("Displays data", async ({ organizationPage }) => { + test("Displays data", async ({organizationPage}) => { // Heading with result length await expect( organizationPage.page.getByRole("heading", { @@ -122,12 +122,12 @@ test.describe("Admin Organization Settings Page", () => { const cols = await row.getByRole("cell").allTextContents(); expect(cols).toHaveLength(colHeaders.length); - const { description, jurisdiction, name, stateCode } = + const {description, jurisdiction, name, stateCode} = i === 0 ? MOCK_GET_ORGANIZATION_SETTINGS_LIST[0] : (MOCK_GET_ORGANIZATION_SETTINGS_LIST.find((i) => i.name === cols[0]) ?? { - name: "INVALID", - }); + name: "INVALID", + }); // if first row, we expect column headers. else, the data row matching id (name) // SetEdit is text of buttons in button column const expectedColContents = @@ -141,7 +141,7 @@ test.describe("Admin Organization Settings Page", () => { } }); - test("Create new organization navigation works", async ({ organizationPage }) => { + test("Create new organization navigation works", async ({organizationPage}) => { const link = organizationPage.page.getByRole("link", { name: "Create New Organization", }); @@ -155,7 +155,7 @@ test.describe("Admin Organization Settings Page", () => { expect(organizationPage.page.url()).toContain(expectedUrl); }); - test("Save CSV button downloads a file", async ({ organizationPage }) => { + test("Save CSV button downloads a file", async ({organizationPage}) => { const downloadProm = organizationPage.page.waitForEvent("download"); const saveButton = organizationPage.page.getByRole("button", { name: "Save List to CSV", @@ -174,9 +174,9 @@ test.describe("Admin Organization Settings Page", () => { expect(download.suggestedFilename()).toBe("prime-orgs.csv"); }); - test("Filtering works", async ({ organizationPage }) => { + test("Filtering works", async ({organizationPage}) => { const table = organizationPage.page.getByRole("table"); - const { description, name, jurisdiction, stateCode } = MOCK_GET_ORGANIZATION_SETTINGS_LIST[2]; + const {description, name, jurisdiction, stateCode} = MOCK_GET_ORGANIZATION_SETTINGS_LIST[2]; const filterBox = organizationPage.page.getByRole("textbox", { name: "Filter:", }); @@ -201,7 +201,7 @@ test.describe("Admin Organization Settings Page", () => { } }); - test('Clicking "Set" updates link label', async ({ organizationPage }) => { + test('Clicking "Set" updates link label', async ({organizationPage}) => { const firstDataRow = organizationPage.page.getByRole("table").getByRole("row").nth(1); const firstDataRowName = (await firstDataRow.getByRole("cell").nth(0).textContent()) ?? "INVALID"; const setButton = firstDataRow.getByRole("button", { @@ -218,7 +218,7 @@ test.describe("Admin Organization Settings Page", () => { await expect(orgLink).toHaveAttribute("href", "/admin/settings"); }); - test("Edit navigation works", async ({ organizationPage }) => { + test("Edit navigation works", async ({organizationPage}) => { const firstDataRow = organizationPage.page.getByRole("table").getByRole("row").nth(1); const firstDataRowName = await firstDataRow.getByRole("cell").nth(0).textContent(); const expectedUrl = `/admin/orgsettings/org/${firstDataRowName}`; @@ -237,7 +237,7 @@ test.describe("Admin Organization Settings Page", () => { }); test.describe("Footer", () => { - test("has footer and explicit scroll to footer and scroll to top", async ({ organizationPage }) => { + test("has footer and explicit scroll to footer and scroll to top", async ({organizationPage}) => { await organizationPage.testFooter(); }); }); From 54a06707de69fd25552148a9f12a85bf3583be93 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Thu, 5 Sep 2024 16:52:48 -0700 Subject: [PATCH 05/13] Fixed path --- .../all/authenticated/admin/organization-settings-page.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts index f57ef8cb13a..ee9773e664c 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts @@ -165,7 +165,7 @@ test.describe("Admin Organization Settings Page", () => { await saveButton.click(); const download = await downloadProm; - const expectedFile = readFileSync(join(__dirname, "../../../../mocks/prime-orgs.csv"), { + const expectedFile = readFileSync(join(__dirname, "../../../../../mocks/prime-orgs.csv"), { encoding: "utf-8", }); const stream = await download.createReadStream(); From d91c908d165453e80b3884d8dadc10218218a00b Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Fri, 6 Sep 2024 09:26:10 -0700 Subject: [PATCH 06/13] Removed commented code --- frontend-react/e2e/pages/authenticated/admin/receiver-status.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 9aef53e3b9a..981a8658b9c 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -222,8 +222,6 @@ export class AdminReceiverStatusPage extends BasePage { } get receiverStatusRowsLocator() { - // const rows = this.statusContainer.locator("> .perreceiver-row"); - const rows = this.statusContainer.locator("> .grid-row"); return Object.assign(rows, { From 6805a26819a22d5cc659cb4cc87567767284bebf Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Fri, 6 Sep 2024 09:50:05 -0700 Subject: [PATCH 07/13] Fixed spacing issues --- .../authenticated/admin/receiver-status.ts | 19 ++++++++++--------- .../receiver-status-page-user-flow.spec.ts | 17 +++++++++-------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 981a8658b9c..ec3777be213 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -1,15 +1,16 @@ -import {expect, Locator} from "@playwright/test"; -import {endOfDay, format, startOfDay, subDays} from "date-fns"; -import type {RSOrganizationSettings} from "../../../../src/config/endpoints/settings"; -import {RSReceiverStatus} from "../../../../src/hooks/api/UseReceiversConnectionStatus/UseReceiversConnectionStatus"; +import { expect, Locator } from "@playwright/test"; +import { endOfDay, format, startOfDay, subDays } from "date-fns"; +import type { RSOrganizationSettings } from "../../../../src/config/endpoints/settings"; +import { RSReceiverStatus } from "../../../../src/hooks/api/UseReceiversConnectionStatus/UseReceiversConnectionStatus"; import { createStatusTimePeriodData, - SUCCESS_RATE_CLASSNAME_MAP, SuccessRate, + SUCCESS_RATE_CLASSNAME_MAP, + SuccessRate, } from "../../../../src/pages/admin/receiver-dashboard/utils"; -import {DatePair, dateShortFormat, durationFormatShort} from "../../../../src/utils/DateTimeUtils"; -import {formatDate} from "../../../../src/utils/misc"; -import {createMockGetReceiverStatus} from "../../../mocks/receiverStatus"; -import {BasePage, BasePageTestArgs, type ResponseHandlerEntry, type RouteHandlerFulfillEntry} from "../../BasePage"; +import { DatePair, dateShortFormat, durationFormatShort } from "../../../../src/utils/DateTimeUtils"; +import { formatDate } from "../../../../src/utils/misc"; +import { createMockGetReceiverStatus } from "../../../mocks/receiverStatus"; +import { BasePage, BasePageTestArgs, type ResponseHandlerEntry, type RouteHandlerFulfillEntry } from "../../BasePage"; export interface AdminReceiverStatusPageUpdateFiltersProps { dateRange?: { 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 f95e8752a4e..866e0b0793e 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 @@ -1,6 +1,6 @@ -import {addDays, endOfDay, startOfDay, subDays} from "date-fns"; -import {AdminReceiverStatusPage} from "../../../pages/authenticated/admin/receiver-status"; -import {test as baseTest, expect, logins} from "../../../test"; +import { addDays, endOfDay, startOfDay, subDays } from "date-fns"; +import { AdminReceiverStatusPage } from "../../../pages/authenticated/admin/receiver-status"; +import { test as baseTest, expect, logins } from "../../../test"; export interface AdminReceiverStatusPageFixtures { adminReceiverStatusPage: AdminReceiverStatusPage; @@ -113,11 +113,12 @@ test.describe("Admin Receiver Status Page", }); test.describe("has footer", () => { - test("has footer and explicit scroll to footer and scroll to top", async ({ - adminReceiverStatusPage, - }) => { - await adminReceiverStatusPage.testFooter(); - }); + test("has footer and explicit scroll to footer and scroll to top", + async ({ + adminReceiverStatusPage, + }) => { + await adminReceiverStatusPage.testFooter(); + }); }); }); From 6d11d812a5bb234db81237642791fb0bf1f9ae85 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Fri, 6 Sep 2024 09:56:59 -0700 Subject: [PATCH 08/13] Fixed spacing issues --- .../authenticated/admin/receiver-status.ts | 34 +++++------ .../receiver-status-page-user-flow.spec.ts | 56 +++++++++---------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index ec3777be213..77b3c7c525b 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -95,7 +95,7 @@ export class AdminReceiverStatusPage extends BasePage { this._receiverStatus = []; this._timePeriodData = []; - this.filterForm = this.page.getByRole("form", {name: "filter"}); + this.filterForm = this.page.getByRole("form", { name: "filter" }); const dateRangeOverlay = this.page.getByRole("dialog").locator(".usa-modal-overlay"); const dateRangeDefaultValue = [startOfDay(subDays(now, 2)), endOfDay(now)] as DatePair; this.filterFormInputs = { @@ -122,7 +122,7 @@ export class AdminReceiverStatusPage extends BasePage { modalEndButton: dateRangeOverlay.getByRole("button").nth(1), expectedDefaultValue: dateRangeDefaultValue, value: dateRangeDefaultValue, - valueDisplay: this.page.locator("span", {hasText: "🗓"}), + valueDisplay: this.page.locator("span", { hasText: "🗓" }), }, receiverName: { label: this.page.locator("label", { @@ -209,7 +209,7 @@ export class AdminReceiverStatusPage extends BasePage { const endDate = url.searchParams.get("end_date"); const range = startDate && endDate ? ([new Date(startDate), new Date(endDate)] as DatePair) : undefined; this._receiverStatus = data; - this._timePeriodData = range ? this.createTimePeriodData({data, range}) : []; + this._timePeriodData = range ? this.createTimePeriodData({ data, range }) : []; }, ]; } @@ -300,7 +300,7 @@ export class AdminReceiverStatusPage extends BasePage { : Promise.resolve(); if (dateRange && isDateRangeDifferent) { - const {value, inputMethod} = dateRange; + const { value, inputMethod } = dateRange; await this.updateFilterDateRange(...value, inputMethod); } if (receiverName != null && receiverName !== this.filterFormInputs.receiverName.value) @@ -387,13 +387,13 @@ export class AdminReceiverStatusPage extends BasePage { } getExpectedStatusOrganizationUrl(rowI: number) { - const {organizationName} = this.timePeriodData[rowI]; + const { organizationName } = this.timePeriodData[rowI]; return `/admin/orgsettings/org/${organizationName}`; } getExpectedStatusReceiverUrl(rowI: number) { - const {organizationName, receiverName} = this.timePeriodData[rowI]; + const { organizationName, receiverName } = this.timePeriodData[rowI]; return `/admin/orgreceiversettings/org/${organizationName}/receiver/${receiverName}/action/edit`; } @@ -414,9 +414,9 @@ export class AdminReceiverStatusPage extends BasePage { ].join(" "); for (const [ i, - {days, successRate, organizationName, receiverName, successRateType}, + { days, successRate, organizationName, receiverName, successRateType }, ] of this.timePeriodData.entries()) { - const {title, display, days: daysLoc} = statusRows.nthCustom(i); + const { title, display, days: daysLoc } = statusRows.nthCustom(i); const expectedTitleText = this.getExpectedReceiverStatusRowTitle( organizationName, @@ -434,11 +434,11 @@ export class AdminReceiverStatusPage extends BasePage { await expect(daysLoc).toHaveCount(days.length); - for (const [i, {timePeriods}] of days.entries()) { + for (const [i, { timePeriods }] of days.entries()) { const daySlices = daysLoc.nthCustom(i).timePeriods; await expect(daySlices).toHaveCount(timePeriods.length); - for (const [i, {successRateType}] of timePeriods.entries()) { + for (const [i, { successRateType }] of timePeriods.entries()) { const sliceEle = daySlices.nth(i); const expectedClass = new RegExp(SUCCESS_RATE_CLASSNAME_MAP[successRateType]); @@ -458,10 +458,10 @@ export class AdminReceiverStatusPage extends BasePage { async testReceiverOrgLinks(isSmoke = false) { const rows = this.receiverStatusRowsLocator; - for (const [i, {organizationName}] of this.timePeriodData.entries()) { + for (const [i, { organizationName }] of this.timePeriodData.entries()) { const row = rows.nthCustom(i); - const link = row.title.getByRole("link", {name: organizationName, exact: true}).first(); + const link = row.title.getByRole("link", { name: organizationName, exact: true }).first(); const expectedUrl = this.getExpectedStatusOrganizationUrl(i); await expect(link).toBeVisible(); const p = this.page.route( @@ -495,11 +495,11 @@ export class AdminReceiverStatusPage extends BasePage { async testReceiverTimePeriodModals(isSmoke = false) { const overlay = this.filterFormInputs.dateRange.modalOverlay; - for (const [i, {days}] of this.timePeriodData.entries()) { - const {days: daysLoc} = this.receiverStatusRowsLocator.nthCustom(i); + for (const [i, { days }] of this.timePeriodData.entries()) { + const { days: daysLoc } = this.receiverStatusRowsLocator.nthCustom(i); for (const [dayI, day] of days.entries()) { - for (const [i, {successRateType, entries}] of day.timePeriods.entries()) { + for (const [i, { successRateType, entries }] of day.timePeriods.entries()) { // only first entry in time period is currently displayed const { organizationName, @@ -515,7 +515,7 @@ export class AdminReceiverStatusPage extends BasePage { const isModalExpectedVisible = successRateType !== SuccessRate.UNDEFINED; - await sliceEle.click({force: true}); + await sliceEle.click({ force: true }); await expect(overlay).toBeAttached({ attached: isModalExpectedVisible, }); @@ -543,7 +543,7 @@ export class AdminReceiverStatusPage extends BasePage { async testReceiverLinks(isSmoke = false) { const rows = this.receiverStatusRowsLocator; - for (const [i, {receiverName}] of this.timePeriodData.entries()) { + for (const [i, { receiverName }] of this.timePeriodData.entries()) { const row = rows.nthCustom(i); const link = row.title.getByRole("link", { 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 866e0b0793e..5cb5fcf15c2 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 @@ -40,12 +40,12 @@ test.describe("Admin Receiver Status Page", { tag: "@smoke", }, () => { - test.use({storageState: logins.admin.path}); + test.use({ storageState: logins.admin.path }); test.describe("displays correctly", () => { test.describe("header", () => { test( "has correct title + heading", - async ({adminReceiverStatusPage}) => { + async ({ adminReceiverStatusPage }) => { await adminReceiverStatusPage.testHeader(); }, ); @@ -54,8 +54,8 @@ test.describe("Admin Receiver Status Page", test.describe( "filters", () => { - test("date range", async ({adminReceiverStatusPage}) => { - const {button, label, modalOverlay, valueDisplay} = + test("date range", async ({ adminReceiverStatusPage }) => { + const { button, label, modalOverlay, valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; await expect(label).toBeVisible(); await expect(button).toBeVisible(); @@ -63,8 +63,8 @@ test.describe("Admin Receiver Status Page", await expect(modalOverlay).toBeHidden(); }); - test("receiver name", async ({adminReceiverStatusPage}) => { - const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + test("receiver name", async ({ adminReceiverStatusPage }) => { + const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = adminReceiverStatusPage.filterFormInputs.receiverName; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -76,8 +76,8 @@ test.describe("Admin Receiver Status Page", await expect(tooltip).toHaveText(expectedTooltipText); }); - test("results message", async ({adminReceiverStatusPage}) => { - const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + test("results message", async ({ adminReceiverStatusPage }) => { + const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = adminReceiverStatusPage.filterFormInputs.resultMessage; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -89,8 +89,8 @@ test.describe("Admin Receiver Status Page", await expect(tooltip).toHaveText(expectedTooltipText); }); - test("success type", async ({adminReceiverStatusPage}) => { - const {input, expectedTooltipText, label, tooltip, expectedDefaultValue} = + test("success type", async ({ adminReceiverStatusPage }) => { + const { input, expectedTooltipText, label, tooltip, expectedDefaultValue } = adminReceiverStatusPage.filterFormInputs.successType; await expect(label).toBeVisible(); await expect(input).toBeVisible(); @@ -106,7 +106,7 @@ test.describe("Admin Receiver Status Page", // Failures here indicate potential misalignment of playwright/browser timezone test.describe("receiver statuses", () => { - test("time periods", async ({adminReceiverStatusPage}) => { + test("time periods", async ({ adminReceiverStatusPage }) => { const result = await adminReceiverStatusPage.testReceiverStatusDisplay(true); expect(result).toBe(true); }); @@ -127,8 +127,8 @@ test.describe("Admin Receiver Status Page", test.describe( "date range", () => { - test("works through calendar", async ({adminReceiverStatusPage}) => { - const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; + test("works through calendar", async ({ adminReceiverStatusPage }) => { + const { valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; const now = new Date(); const targetFrom = startOfDay(subDays(now, 3)); const targetTo = addDays(endOfDay(now), 1); @@ -149,8 +149,8 @@ test.describe("Admin Receiver Status Page", }); }); - test("works through textboxes", async ({adminReceiverStatusPage}) => { - const {valueDisplay} = adminReceiverStatusPage.filterFormInputs.dateRange; + test("works through textboxes", async ({ adminReceiverStatusPage }) => { + const { valueDisplay } = adminReceiverStatusPage.filterFormInputs.dateRange; await expect(adminReceiverStatusPage.receiverStatusRowsLocator).not.toHaveCount(0); const now = new Date(); const targetFrom = startOfDay(subDays(now, 3)); @@ -175,8 +175,8 @@ test.describe("Admin Receiver Status Page", }, ); - test("receiver name", async ({adminReceiverStatusPage}) => { - const {organizationName, receiverName, successRate} = + test("receiver name", async ({ adminReceiverStatusPage }) => { + const { organizationName, receiverName, successRate } = adminReceiverStatusPage.timePeriodData[1]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; @@ -205,14 +205,14 @@ test.describe("Admin Receiver Status Page", expect(defaultReceiversStatusRowsCount).toBe(adminReceiverStatusPage.timePeriodData.length); }); - test("result message", async ({adminReceiverStatusPage}) => { + test("result message", async ({ adminReceiverStatusPage }) => { // 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 { days } = adminReceiverStatusPage.timePeriodData[receiverI]; + const { connectionCheckResult } = days[dayI].timePeriods[timePeriodI].entries[entryI]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; @@ -220,10 +220,10 @@ test.describe("Admin Receiver Status Page", resultMessage: connectionCheckResult, }); - for (const [i, {days}] of adminReceiverStatusPage.timePeriodData.entries()) { + for (const [i, { days }] of adminReceiverStatusPage.timePeriodData.entries()) { const row = receiversStatusRows.nthCustom(i); - for (const [i, {timePeriods}] of days.entries()) { + for (const [i, { timePeriods }] of days.entries()) { const rowDay = row.days.nthCustom(i); for (const [i] of timePeriods.entries()) { @@ -240,7 +240,7 @@ test.describe("Admin Receiver Status Page", // await adminReceiverStatusPage.testReceiverStatusDisplay(); }); - test("success type", async ({adminReceiverStatusPage}) => { + test("success type", async ({ adminReceiverStatusPage }) => { const [failRow, ,] = adminReceiverStatusPage.timePeriodData; const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( failRow.organizationName, @@ -284,7 +284,7 @@ test.describe("Admin Receiver Status Page", test.describe("receiver statuses", () => { test.describe("date range length changes", () => { - test("increases", async ({adminReceiverStatusPage}) => { + test("increases", async ({ adminReceiverStatusPage }) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; const days = rows.nthCustom(0).days; await expect(rows).not.toHaveCount(0); @@ -299,7 +299,7 @@ test.describe("Admin Receiver Status Page", await expect(days).toHaveCount(4); }); - test("decreases", async ({adminReceiverStatusPage}) => { + test("decreases", async ({ adminReceiverStatusPage }) => { const rows = adminReceiverStatusPage.receiverStatusRowsLocator; const days = rows.nthCustom(0).days; await expect(rows).not.toHaveCount(0); @@ -315,17 +315,17 @@ test.describe("Admin Receiver Status Page", }); }); - test("time period modals", async ({adminReceiverStatusPage}) => { + test("time period modals", async ({ adminReceiverStatusPage }) => { const result = await adminReceiverStatusPage.testReceiverTimePeriodModals(true); expect(result).toBe(true); }); - test("receiver org links", async ({adminReceiverStatusPage}) => { + test("receiver org links", async ({ adminReceiverStatusPage }) => { const result = await adminReceiverStatusPage.testReceiverOrgLinks(true); expect(result).toBe(true); }); - test("receiver links", async ({adminReceiverStatusPage}) => { + test("receiver links", async ({ adminReceiverStatusPage }) => { const result = await adminReceiverStatusPage.testReceiverLinks(true); expect(result).toBe(true); }); From 720cc5edc44ac2542159e447cf5c020b3d83b054 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Fri, 6 Sep 2024 10:00:00 -0700 Subject: [PATCH 09/13] Fixed spacing issues --- .../e2e/pages/authenticated/admin/receiver-status.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 77b3c7c525b..91e0d830ab9 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -286,11 +286,11 @@ export class AdminReceiverStatusPage extends BasePage { } async updateFilters({ - dateRange, - receiverName, - resultMessage, - successType, - }: AdminReceiverStatusPageUpdateFiltersProps) { + dateRange, + receiverName, + resultMessage, + successType, + }: AdminReceiverStatusPageUpdateFiltersProps) { // API request will only fire if date ranges are different const isDateRangeDifferent = dateRange == null || this.getIsDateRangesDifferent(this.filterFormInputs.dateRange.value, dateRange.value); From 1682da1b6463420de27406f5c9b41f85a90a8877 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Sat, 7 Sep 2024 11:19:57 -0700 Subject: [PATCH 10/13] Fixed failing tests --- .../authenticated/admin/receiver-status.ts | 32 ++++++++++++ .../admin/receiver-status-page.spec.ts | 27 +--------- .../receiver-status-page-user-flow.spec.ts | 52 ++++++------------- 3 files changed, 51 insertions(+), 60 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index 91e0d830ab9..a65ed16ce84 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -455,6 +455,38 @@ export class AdminReceiverStatusPage extends BasePage { return true; } + async testReceiverName() { + const { organizationName, receiverName, successRate } = + this.timePeriodData[1]; + + const receiversStatusRows = this.receiverStatusRowsLocator; + const defaultReceiversStatusRowsCount = await receiversStatusRows.count(); + const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); + const expectedReceiverStatusRowTitle = + this.getExpectedReceiverStatusRowTitle( + organizationName, + receiverName, + successRate, + ); + + expect(defaultReceiversStatusRowsCount).toBe(this.timePeriodData.length); + + await this.updateFilters({ + receiverName, + }); + + const receiversStatusRowsCount = await receiversStatusRows.count(); + expect(receiversStatusRowsCount).toBeGreaterThanOrEqual(1); + await expect(expectedReceiverStatusRow).toBeVisible(); + await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); + + await this.resetFilters(); + + expect(defaultReceiversStatusRowsCount).toBe(this.timePeriodData.length); + + return true; + } + async testReceiverOrgLinks(isSmoke = false) { const rows = this.receiverStatusRowsLocator; diff --git a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts index 1ccd3779a3a..e647a00534b 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts @@ -202,31 +202,8 @@ test.describe("Admin Receiver Status Page", () => { ); test("receiver name", async ({adminReceiverStatusPage}) => { - const {organizationName, receiverName, successRate} = - adminReceiverStatusPage.timePeriodData[1]; - - const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; - const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); - const expectedReceiverStatusRowTitle = - adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( - organizationName, - receiverName, - successRate, - ); - - await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); - - await adminReceiverStatusPage.updateFilters({ - receiverName, - }); - - await expect(receiversStatusRows).toHaveCount(1); - await expect(expectedReceiverStatusRow).toBeVisible(); - await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); - - await adminReceiverStatusPage.resetFilters(); - - await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); + const result = await adminReceiverStatusPage.testReceiverName(); + expect(result).toBe(true); }); test("result message", async ({adminReceiverStatusPage}) => { 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 5cb5fcf15c2..80241109259 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 @@ -176,43 +176,18 @@ test.describe("Admin Receiver Status Page", ); test("receiver name", async ({ adminReceiverStatusPage }) => { - const { organizationName, receiverName, successRate } = - adminReceiverStatusPage.timePeriodData[1]; - - 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); + const result = await adminReceiverStatusPage.testReceiverName(); + expect(result).toBe(true); }); - test("result message", async ({ adminReceiverStatusPage }) => { + test("result message", async ({adminReceiverStatusPage}) => { // 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 {days} = adminReceiverStatusPage.timePeriodData[receiverI]; + const {connectionCheckResult} = days[dayI].timePeriods[timePeriodI].entries[entryI]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; @@ -220,26 +195,33 @@ test.describe("Admin Receiver Status Page", resultMessage: connectionCheckResult, }); - for (const [i, { days }] of adminReceiverStatusPage.timePeriodData.entries()) { + for (const [i, {days}] of adminReceiverStatusPage.timePeriodData.entries()) { + const isRowExpected = i === receiverI; const row = receiversStatusRows.nthCustom(i); - for (const [i, { timePeriods }] of days.entries()) { + for (const [i, {timePeriods}] of days.entries()) { + const isDayExpected = isRowExpected && i === dayI; const rowDay = row.days.nthCustom(i); for (const [i] of timePeriods.entries()) { + const isTimePeriodExpected = isDayExpected && i === timePeriodI; + const expectedClass = !isTimePeriodExpected + ? /success-result-hidden/ + : /^((?!success-result-hidden).)*$/; const rowDayTimePeriod = rowDay.timePeriods.nth(i); - await expect(rowDayTimePeriod).toHaveClass(/success-result-hidden/); + await expect(rowDayTimePeriod).toBeVisible(); + await expect(rowDayTimePeriod).toHaveClass(expectedClass); } } } await adminReceiverStatusPage.resetFilters(); - // TODO: revisit after filters have been fixed per ticket #15737 - // await adminReceiverStatusPage.testReceiverStatusDisplay(); + await adminReceiverStatusPage.testReceiverStatusDisplay(); }); + test("success type", async ({ adminReceiverStatusPage }) => { const [failRow, ,] = adminReceiverStatusPage.timePeriodData; const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( From f8e04fe364753608170af7237881b5a8046e692e Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Sat, 7 Sep 2024 11:45:38 -0700 Subject: [PATCH 11/13] Fixed failing tests --- .../authenticated/admin/receiver-status.ts | 43 ++++++++++++++ .../admin/receiver-status-page.spec.ts | 57 +++++++------------ .../receiver-status-page-user-flow.spec.ts | 40 +------------ 3 files changed, 67 insertions(+), 73 deletions(-) diff --git a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts index a65ed16ce84..297a9cf9d66 100644 --- a/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts +++ b/frontend-react/e2e/pages/authenticated/admin/receiver-status.ts @@ -487,6 +487,49 @@ export class AdminReceiverStatusPage extends BasePage { return true; } + async testReceiverMessage() { + // 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} = this.timePeriodData[receiverI]; + const {connectionCheckResult} = days[dayI].timePeriods[timePeriodI].entries[entryI]; + + const receiversStatusRows = this.receiverStatusRowsLocator; + + await this.updateFilters({ + resultMessage: connectionCheckResult, + }); + + for (const [i, {days}] of this.timePeriodData.entries()) { + const isRowExpected = i === receiverI; + const row = receiversStatusRows.nthCustom(i); + + for (const [i, {timePeriods}] of days.entries()) { + const isDayExpected = isRowExpected && i === dayI; + const rowDay = row.days.nthCustom(i); + + for (const [i] of timePeriods.entries()) { + const isTimePeriodExpected = isDayExpected && i === timePeriodI; + const expectedClass = !isTimePeriodExpected + ? /success-result-hidden/ + : /^((?!success-result-hidden).)*$/; + const rowDayTimePeriod = rowDay.timePeriods.nth(i); + + await expect(rowDayTimePeriod).toBeVisible(); + await expect(rowDayTimePeriod).toHaveClass(expectedClass); + } + } + } + + await this.resetFilters(); + + await this.testReceiverStatusDisplay(); + + return true; + } + async testReceiverOrgLinks(isSmoke = false) { const rows = this.receiverStatusRowsLocator; diff --git a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts index e647a00534b..edba29a56c0 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/receiver-status-page.spec.ts @@ -201,50 +201,37 @@ test.describe("Admin Receiver Status Page", () => { }, ); - test("receiver name", async ({adminReceiverStatusPage}) => { - const result = await adminReceiverStatusPage.testReceiverName(); - expect(result).toBe(true); - }); - - test("result message", async ({adminReceiverStatusPage}) => { - // 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]; + test("receiver name", async ({ adminReceiverStatusPage }) => { + const { organizationName, receiverName, successRate } = + adminReceiverStatusPage.timePeriodData[1]; const receiversStatusRows = adminReceiverStatusPage.receiverStatusRowsLocator; + const expectedReceiverStatusRow = receiversStatusRows.nthCustom(0); + const expectedReceiverStatusRowTitle = + adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( + organizationName, + receiverName, + successRate, + ); + + await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); await adminReceiverStatusPage.updateFilters({ - resultMessage: connectionCheckResult, + receiverName, }); - for (const [i, {days}] of adminReceiverStatusPage.timePeriodData.entries()) { - const isRowExpected = i === receiverI; - const row = receiversStatusRows.nthCustom(i); - - for (const [i, {timePeriods}] of days.entries()) { - const isDayExpected = isRowExpected && i === dayI; - const rowDay = row.days.nthCustom(i); - - for (const [i] of timePeriods.entries()) { - const isTimePeriodExpected = isDayExpected && i === timePeriodI; - const expectedClass = !isTimePeriodExpected - ? /success-result-hidden/ - : /^((?!success-result-hidden).)*$/; - const rowDayTimePeriod = rowDay.timePeriods.nth(i); - - await expect(rowDayTimePeriod).toBeVisible(); - await expect(rowDayTimePeriod).toHaveClass(expectedClass); - } - } - } + await expect(receiversStatusRows).toHaveCount(1); + await expect(expectedReceiverStatusRow).toBeVisible(); + await expect(expectedReceiverStatusRow.title).toHaveText(expectedReceiverStatusRowTitle); await adminReceiverStatusPage.resetFilters(); - await adminReceiverStatusPage.testReceiverStatusDisplay(); + await expect(receiversStatusRows).toHaveCount(adminReceiverStatusPage.timePeriodData.length); + }); + + test("result message", async ({adminReceiverStatusPage}) => { + const result = await adminReceiverStatusPage.testReceiverMessage(); + expect(result).toBe(true); }); test("success type", async ({adminReceiverStatusPage}) => { 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 80241109259..456a0f18318 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 @@ -181,44 +181,8 @@ test.describe("Admin Receiver Status Page", }); test("result message", async ({adminReceiverStatusPage}) => { - // 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 isRowExpected = i === receiverI; - const row = receiversStatusRows.nthCustom(i); - - for (const [i, {timePeriods}] of days.entries()) { - const isDayExpected = isRowExpected && i === dayI; - const rowDay = row.days.nthCustom(i); - - for (const [i] of timePeriods.entries()) { - const isTimePeriodExpected = isDayExpected && i === timePeriodI; - const expectedClass = !isTimePeriodExpected - ? /success-result-hidden/ - : /^((?!success-result-hidden).)*$/; - const rowDayTimePeriod = rowDay.timePeriods.nth(i); - - await expect(rowDayTimePeriod).toBeVisible(); - await expect(rowDayTimePeriod).toHaveClass(expectedClass); - } - } - } - - await adminReceiverStatusPage.resetFilters(); - - await adminReceiverStatusPage.testReceiverStatusDisplay(); + const result = await adminReceiverStatusPage.testReceiverMessage(); + expect(result).toBe(true); }); From 5b29b413e4b2d158738b6080a04001029a7e74f8 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Mon, 9 Sep 2024 10:08:21 -0700 Subject: [PATCH 12/13] 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; From d5e9d7681c40cbb6ed9871c4162d9d18359e58a8 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Mon, 9 Sep 2024 10:24:42 -0700 Subject: [PATCH 13/13] Added check if using mock --- .../authenticated/receiver-status-page-user-flow.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 35a4b1e98fc..5c4e456b43d 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 @@ -242,7 +242,8 @@ test.describe("Admin Receiver Status Page", // await adminReceiverStatusPage.testReceiverStatusDisplay(); }); - test("success type", async ({ adminReceiverStatusPage }) => { + test("success type", async ({ adminReceiverStatusPage, isMockDisabled }) => { + test.skip(!isMockDisabled, "Mocks are ENABLED, skipping 'success type' test"); const [failRow, ,] = adminReceiverStatusPage.timePeriodData; const failRowTitle = adminReceiverStatusPage.getExpectedReceiverStatusRowTitle( failRow.organizationName,