generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experience/15212/submission history user flow (#15712)
* 15212 - submission user flow * Fixed merge conflicts
- Loading branch information
1 parent
6ee8ea1
commit 1ec24e5
Showing
7 changed files
with
465 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
frontend-react/e2e/pages/authenticated/submissions-details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { API_WATERS_REPORT } from "./report-details"; | ||
import { URL_SUBMISSION_HISTORY } from "./submission-history"; | ||
import { MOCK_GET_SUBMISSION_HISTORY } from "../../mocks/submissionHistory"; | ||
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../BasePage"; | ||
|
||
export const id = "73e3cbc8-9920-4ab7-871f-843a1db4c074"; | ||
export class SubmissionsDetailsPage extends BasePage { | ||
static readonly URL_SUBMISSIONS_DETAILS = `${URL_SUBMISSION_HISTORY}/${id}`; | ||
|
||
constructor(testArgs: BasePageTestArgs) { | ||
super( | ||
{ | ||
url: SubmissionsDetailsPage.URL_SUBMISSIONS_DETAILS, | ||
title: "ReportStream - CDC's free, interoperable data transfer platform", | ||
}, | ||
testArgs, | ||
); | ||
|
||
this.addMockRouteHandlers([this.createMockSubmissionHistoryHandler(MOCK_GET_SUBMISSION_HISTORY)]); | ||
} | ||
|
||
createMockSubmissionHistoryHandler(mockFileName: any, responseStatus = 200): RouteHandlerFulfillEntry { | ||
return [ | ||
`${API_WATERS_REPORT}/${id}/history`, | ||
() => { | ||
return { | ||
json: mockFileName, | ||
status: responseStatus, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
/** | ||
* Error expected additionally if user context isn't admin | ||
*/ | ||
get isPageLoadExpected() { | ||
return super.isPageLoadExpected && this.testArgs.storageState === this.testArgs.adminLogin.path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
frontend-react/e2e/spec/all/authenticated/submission-history-page-user-flow.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import { expect } from "@playwright/test"; | ||
|
||
import { | ||
FALLBACK_FROM_DATE_STRING, | ||
FALLBACK_TO_DATE_STRING, | ||
} from "../../../../src/hooks/filters/UseDateRange/UseDateRange"; | ||
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 { test as baseTest } from "../../../test"; | ||
|
||
export interface SubmissionHistoryPageFixtures { | ||
submissionHistoryPage: SubmissionHistoryPage; | ||
} | ||
|
||
const test = baseTest.extend<SubmissionHistoryPageFixtures>({ | ||
submissionHistoryPage: async ( | ||
{ | ||
page: _page, | ||
isMockDisabled, | ||
adminLogin, | ||
senderLogin, | ||
receiverLogin, | ||
storageState, | ||
frontendWarningsLogPath, | ||
isFrontendWarningsLog, | ||
}, | ||
use, | ||
) => { | ||
const page = new SubmissionHistoryPage({ | ||
page: _page, | ||
isMockDisabled, | ||
adminLogin, | ||
senderLogin, | ||
receiverLogin, | ||
storageState, | ||
frontendWarningsLogPath, | ||
isFrontendWarningsLog, | ||
isTestOrg: true, | ||
}); | ||
await page.goto(); | ||
await use(page); | ||
}, | ||
}); | ||
|
||
test.describe( | ||
"Submission history page - user flow smoke tests", | ||
{ | ||
tag: "@smoke", | ||
}, | ||
() => { | ||
test.describe("admin user", () => { | ||
test.use({ storageState: "e2e/.auth/admin.json" }); | ||
|
||
test.beforeAll(({ browserName }) => { | ||
test.skip(browserName !== "chromium"); | ||
Check warning on line 57 in frontend-react/e2e/spec/all/authenticated/submission-history-page-user-flow.spec.ts GitHub Actions / Build Frontend React
Check warning on line 57 in frontend-react/e2e/spec/all/authenticated/submission-history-page-user-flow.spec.ts GitHub Actions / Release: Build Frontend (React)
|
||
}); | ||
|
||
test.describe(`${TEST_ORG_IGNORE} org`, () => { | ||
test("nav contains the 'Submission History' option", async ({ submissionHistoryPage }) => { | ||
const navItems = submissionHistoryPage.page.locator(".usa-nav li"); | ||
await expect(navItems).toContainText(["Submission History"]); | ||
}); | ||
|
||
test("has correct title", async ({ submissionHistoryPage }) => { | ||
await expect(submissionHistoryPage.page).toHaveTitle(submissionHistoryPage.title); | ||
await expect(submissionHistoryPage.heading).toBeVisible(); | ||
}); | ||
|
||
test("has filter", async ({ submissionHistoryPage }) => { | ||
await expect(submissionHistoryPage.page.getByTestId("filter-container")).toBeAttached(); | ||
}); | ||
|
||
test("has footer", async ({ submissionHistoryPage }) => { | ||
await expect(submissionHistoryPage.footer).toBeAttached(); | ||
}); | ||
|
||
test.describe("table", () => { | ||
test.beforeEach(async ({ submissionHistoryPage }) => { | ||
await submissionHistoryPage.page.locator(".usa-table tbody").waitFor({ state: "visible" }); | ||
}); | ||
|
||
test("table has correct headers", async ({ submissionHistoryPage }) => { | ||
await submissionHistory.tableHeaders(submissionHistoryPage.page); | ||
}); | ||
|
||
test("table column 'ReportId' will open the report details", async ({ submissionHistoryPage }) => { | ||
const reportId = await tableDataCellValue(submissionHistoryPage.page, 0, 0); | ||
|
||
await submissionHistoryPage.page.getByRole("link", { name: reportId }).click(); | ||
const responsePromise = await submissionHistoryPage.page.waitForResponse( | ||
(res) => res.status() === 200 && res.url().includes("/history"), | ||
); | ||
|
||
if (responsePromise) { | ||
await openReportIdDetailPage(submissionHistoryPage.page, reportId); | ||
} else { | ||
console.error("Request not received within the timeout period"); | ||
} | ||
}); | ||
|
||
test("table has pagination", async ({ submissionHistoryPage }) => { | ||
await expect(submissionHistoryPage.page.getByTestId("Submissions pagination")).toBeAttached(); | ||
}); | ||
}); | ||
|
||
test.describe("filter", () => { | ||
test.describe("on 'onLoad'", () => { | ||
test("'From' date has a default value", async ({ submissionHistoryPage }) => { | ||
await expect(startDate(submissionHistoryPage.page)).toBeAttached(); | ||
await expect(startDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_FROM_DATE_STRING); | ||
}); | ||
|
||
test("'To' date has a default value", async ({ submissionHistoryPage }) => { | ||
await expect(endDate(submissionHistoryPage.page)).toBeAttached(); | ||
await expect(endDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_TO_DATE_STRING); | ||
}); | ||
}); | ||
|
||
test.describe("on 'Filter'", () => { | ||
test("with 'From' date, 'To' date", async ({ submissionHistoryPage }) => { | ||
const fromDate = await setDate(submissionHistoryPage.page, "#start-date", 180); | ||
const toDate = await setDate(submissionHistoryPage.page, "#end-date", 0); | ||
|
||
// 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, | ||
); | ||
expect(areDatesInRange).toBe(true); | ||
}); | ||
|
||
test("on 'clear' resets the dates", async ({ submissionHistoryPage }) => { | ||
await expect(startDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_FROM_DATE_STRING); | ||
await expect(endDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_TO_DATE_STRING); | ||
|
||
await setDate(submissionHistoryPage.page, "#start-date", 14); | ||
await setDate(submissionHistoryPage.page, "#end-date", 14); | ||
|
||
await submissionHistoryPage.clearButton.click(); | ||
|
||
await expect(startDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_FROM_DATE_STRING); | ||
await expect(endDate(submissionHistoryPage.page)).toHaveValue(FALLBACK_TO_DATE_STRING); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}, | ||
); |
Oops, something went wrong.