Skip to content

Commit

Permalink
Merge pull request #15730 from CDCgov/experience/15612/file-download-…
Browse files Browse the repository at this point in the history
…e2e-issue

Fix E2E test Filedownload issue
  • Loading branch information
etanb authored Aug 30, 2024
2 parents 4358a18 + 3e63704 commit e84f2c3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
15 changes: 15 additions & 0 deletions frontend-react/e2e/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,18 @@ export function toDateWithTime(date: string, time?: string) {
}
return toDateTime;
}

export function removeDateTime(filename: string) {
// Example string: "co.yml-beb0c9d9-ca1f-4af3-853e-0aba61541f66-20240829191221.hl7"
// Find the last hyphen and the last dot in the string
const lastHyphenIndex = filename.lastIndexOf("-");
const lastDotIndex = filename.lastIndexOf(".");

// If both indices are found, implying a properly formatted file extension,
// remove the timestamp
if (lastHyphenIndex !== -1 && lastDotIndex !== -1 && lastHyphenIndex < lastDotIndex) {
return filename.slice(0, lastHyphenIndex);
}

return filename;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { format } from "date-fns";
import fs from "node:fs";
import {
expectTableColumnValues,
removeDateTime,
tableColumnDateTimeInRange,
tableDataCellValue,
tableRows,
Expand Down Expand Up @@ -79,10 +80,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_ORG_UP_RECEIVER_UP} receiver`, () => {
test.describe("onLoad", () => {
test("has correct title", async ({ dailyDataPage }) => {
Expand All @@ -102,6 +99,7 @@ test.describe(
});

test("table has pagination", async ({ dailyDataPage }) => {
await dailyDataPage.page.locator(".usa-table tbody").waitFor({ state: "visible" });
await expect(dailyDataPage.page.locator('[aria-label="Pagination"]')).toBeAttached();
});

Expand Down Expand Up @@ -292,9 +290,11 @@ test.describe(
expect(await tableDataCellValue(dailyDataPage.page, 0, 0)).toEqual(reportId);
});

test("returns match for Filename", async ({ dailyDataPage }) => {
test.skip("returns match for Filename", async ({ dailyDataPage }) => {

Check warning on line 293 in frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build frontend

Unexpected use of the `.skip()` annotation

Check warning on line 293 in frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Release: Build Frontend (React)

Unexpected use of the `.skip()` annotation

Check warning on line 293 in frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build Frontend React

Unexpected use of the `.skip()` annotation
// Filename search is currently broken and being tracked
// in ticket #15644
const fileName = await tableDataCellValue(dailyDataPage.page, 0, 4);
await searchInput(dailyDataPage.page).fill(fileName);
await searchInput(dailyDataPage.page).fill(removeDateTime(fileName));
await searchButton(dailyDataPage.page).click();
await dailyDataPage.page.locator(".usa-table tbody").waitFor({ state: "visible" });

Expand Down Expand Up @@ -365,7 +365,7 @@ test.describe(
});
});

test.describe.skip("on 'Filename' click", () => {
test.describe("on 'Filename' click", () => {
test.beforeEach(async ({ dailyDataPage }) => {
await dailyDataPage.page.locator(".usa-table tbody").waitFor({ state: "visible" });
await dailyDataPage.page.locator("#receiver-dropdown").selectOption(TEST_ORG_UP_RECEIVER_UP);
Expand All @@ -387,7 +387,7 @@ test.describe(
const download = await downloadProm;

// assert filename
expect(download.suggestedFilename()).toEqual(expect.stringContaining(fileName));
expect(removeDateTime(download.suggestedFilename())).toEqual(removeDateTime(fileName));

// get and assert stats
expect((await fs.promises.stat(await download.path())).size).toBeGreaterThan(200);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable playwright/no-conditional-in-test */
/* eslint-disable playwright/no-networkidle */
import axios, { AxiosError } from "axios";
import * as fs from "fs";
import { test as baseTest, expect } from "../../test";
Expand Down Expand Up @@ -55,7 +55,9 @@ test.describe("Evaluate links on public facing pages", { tag: "@warning" }, () =
// Set test timeout to be 1 minute instead of 30 seconds
test.setTimeout(60000);
for (const path of urlPaths) {
await page.goto(path);
await page.goto(path, {
waitUntil: "networkidle",
});
const baseUrl = new URL(page.url()).origin;

const allATags = await page.getByRole("link", { includeHidden: true }).elementHandles();
Expand Down

0 comments on commit e84f2c3

Please sign in to comment.