Skip to content

Commit

Permalink
Waiting for response before checking dates.
Browse files Browse the repository at this point in the history
Updated playwright config
  • Loading branch information
penny-lischer committed Sep 4, 2024
1 parent 247c33d commit dd05172
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
import { tableColumnDateTimeInRange, tableDataCellValue, TEST_ORG_IGNORE } from "../../../helpers/utils";
import { endDate, setDate, startDate } from "../../../pages/authenticated/daily-data";
import * as submissionHistory from "../../../pages/authenticated/submission-history";
import { openReportIdDetailPage, SubmissionHistoryPage } from "../../../pages/authenticated/submission-history";
import {
openReportIdDetailPage,
SubmissionHistoryPage,
URL_SUBMISSION_HISTORY
} from "../../../pages/authenticated/submission-history";
import { test as baseTest } from "../../../test";

export interface SubmissionHistoryPageFixtures {
Expand Down Expand Up @@ -53,10 +57,6 @@ test.describe(
test.describe("admin user", () => {
test.use({ storageState: "e2e/.auth/admin.json" });

test.beforeAll(({ browserName }) => {
test.skip(browserName !== "chromium");
});

test.describe(`${TEST_ORG_IGNORE} org`, () => {
test("nav contains the 'Submission History' option", async ({ submissionHistoryPage }) => {
const navItems = submissionHistoryPage.page.locator(".usa-nav li");
Expand Down Expand Up @@ -125,16 +125,24 @@ test.describe(

// Apply button is enabled
await submissionHistoryPage.filterButton.click();
await submissionHistoryPage.page.locator(".usa-table tbody").waitFor({ state: "visible" });

// Check that table data contains the dates/times that were selected
const areDatesInRange = await tableColumnDateTimeInRange(
submissionHistoryPage.page,
1,
fromDate,
toDate,
const responsePromise = await submissionHistoryPage.page.waitForResponse(
(res) => res.status() === 200 && res.url().includes(URL_SUBMISSION_HISTORY),
);
expect(areDatesInRange).toBe(true);

if (responsePromise) {
// Check that table data contains the dates/times that were selected
const areDatesInRange = await tableColumnDateTimeInRange(
submissionHistoryPage.page,
1,
fromDate,
toDate,
);

// eslint-disable-next-line playwright/no-conditional-expect
expect(areDatesInRange).toBe(true);
} else {
console.error("Request not received within the timeout period");
}
});

test("on 'clear' resets the dates", async ({ submissionHistoryPage }) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend-react/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default defineConfig({
name: "chromium",
use: { browserName: "chromium" },
dependencies: ["setup"],
testMatch: "spec/all/**/*.spec.ts",
testMatch: ["spec/all/**/*.spec.ts", "spec/chromium-only/**/*.spec.ts"],
},
{
name: "firefox",
Expand Down

0 comments on commit dd05172

Please sign in to comment.