Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E2E test Filedownload issue #15730

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 fs from "node:fs";
import {
expectTableColumnValues,
removeDateTime,
tableColumnDateTimeInRange,
tableDataCellValue,
tableRows,
Expand Down Expand Up @@ -79,10 +80,6 @@
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("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 @@
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 / Lint

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.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 @@
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 All @@ -414,8 +414,8 @@
);

if (responsePromise) {
await expect(dailyDataPage.page).toHaveURL(`${URL_REPORT_DETAILS}/${reportId}`);

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

View workflow job for this annotation

GitHub Actions / Lint

Avoid calling `expect` conditionally`
await expect(dailyDataPage.page).toHaveTitle(/Daily Data - ReportStream/);

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

View workflow job for this annotation

GitHub Actions / Lint

Avoid calling `expect` conditionally`
await expect(dailyDataPage.page.locator("h1").getByText(reportId)).toBeVisible();

// Facility table headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
// 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",

Check failure on line 59 in frontend-react/e2e/spec/chromium-only/public-pages-link-check.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected use of networkidle
});
const baseUrl = new URL(page.url()).origin;

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