Skip to content

Commit

Permalink
Merge pull request #15255 from CDCgov/experience/14238/integrate-pagi…
Browse files Browse the repository at this point in the history
…nation-api-daily-data

Experience/14238/integrate pagination api daily data
  • Loading branch information
etanb committed Jul 31, 2024
2 parents dfa6cf6 + 2dc22c9 commit 198d84e
Show file tree
Hide file tree
Showing 15 changed files with 1,559 additions and 1,876 deletions.
1,561 changes: 761 additions & 800 deletions frontend-react/e2e/mocks/deliveries.ts

Large diffs are not rendered by default.

114 changes: 42 additions & 72 deletions frontend-react/e2e/pages/report-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,45 @@ import { MOCK_GET_SUBMISSION_HISTORY } from "../mocks/submissionHistory";
export const URL_REPORT_DETAILS = "/report-details";
export const API_WATERS_REPORT = "**/api/waters/report";
export const API_HISTORY_REPORT = "**/api/history/report";
export const API_WATERS_ORG = "**/api/waters/org";
export const API_WATERS_ORG = "**/api/v1/waters/org";

export async function goto(page: Page, id: string) {
await page.goto(`${URL_REPORT_DETAILS}/${id}`, {
waitUntil: "domcontentloaded",
});
}
export async function mockGetReportDeliveryResponse(
page: Page,
id: string,
responseStatus = 200,
) {
export async function mockGetReportDeliveryResponse(page: Page, id: string, responseStatus = 200) {
await page.route(`${API_WATERS_REPORT}/${id}/delivery`, async (route) => {
const json = MOCK_GET_DELIVERY;
await route.fulfill({ json, status: responseStatus });
});
}

export async function mockGetDeliveriesForOrgAlaskaResponse(
page: Page,
byReportId?: boolean,
byFileName?: boolean,
receiver?: string,
interface MockGetDeliveriesForOrgResponseOptions {
page: Page;
byReportId?: boolean;
byFileName?: boolean;
receiver?: string;
responseStatus?: number;
}

export async function mockGetDeliveriesForOrgAlaskaResponse({
page,
byReportId,
byFileName,
receiver,
responseStatus = 200,
) {
}: MockGetDeliveriesForOrgResponseOptions) {
if (receiver) {
await page.route(
`${API_WATERS_ORG}/ak-phd.${receiver}/deliveries?*`,
async (route) => {
const json = MOCK_GET_DELIVERIES_AK_ELR;
await route.fulfill({ json, status: responseStatus });
},
);
await page.route(`${API_WATERS_ORG}/ak-phd.${receiver}/deliveries?*`, async (route) => {
await route.fulfill({ json: MOCK_GET_DELIVERIES_AK_ELR, status: responseStatus });
});
} else if (byReportId) {
await page.route(
`${API_WATERS_ORG}/ak-phd/deliveries?sortdir=DESC&cursor=3000-01-01T00:00:00.000Z&since=2000-01-01T00:00:00.000Z&until=3000-01-01T00:00:00.000Z&pageSize=61&receivingOrgSvcStatus=ACTIVE,TESTING&reportId=f4155156-1230-4f0a-8a50-0a0cdec5aa0e`,
async (route) => {
const json = MOCK_GET_DELIVERIES_AK_5;
await route.fulfill({
json,
json: MOCK_GET_DELIVERIES_AK_5,
status: 200,
});
},
Expand All @@ -65,46 +64,36 @@ export async function mockGetDeliveriesForOrgAlaskaResponse(
await page.route(
`${API_WATERS_ORG}/ak-phd/deliveries?sortdir=DESC&cursor=3000-01-01T00:00:00.000Z&since=2000-01-01T00:00:00.000Z&until=3000-01-01T00:00:00.000Z&pageSize=61&receivingOrgSvcStatus=ACTIVE,TESTING&fileName=ak-receiver-transform.yml-f4155156-1230-4f0a-8a50-0a0cdec5aa0e-20240423214401.hl7`,
async (route) => {
const json = MOCK_GET_DELIVERIES_AK_5;
await route.fulfill({
json,
json: MOCK_GET_DELIVERIES_AK_5,
status: 200,
});
},
);
} else {
await page.route(
`${API_WATERS_ORG}/ak-phd/deliveries?*`,
async (route) => {
const json = MOCK_GET_DELIVERIES_AK;
await route.fulfill({ json, status: responseStatus });
},
);
await page.route(`${API_WATERS_ORG}/ak-phd/deliveries?*`, async (route) => {
await route.fulfill({ json: MOCK_GET_DELIVERIES_AK, status: responseStatus });
});
}
}

export async function mockGetDeliveriesForOrgIgnoreResponse(
page: Page,
byReportId?: boolean,
byFileName?: boolean,
receiver?: string,
export async function mockGetDeliveriesForOrgIgnoreResponse({
page,
byReportId,
byFileName,
receiver,
responseStatus = 200,
) {
}: MockGetDeliveriesForOrgResponseOptions) {
if (receiver) {
await page.route(
`${API_WATERS_ORG}/ignore.${receiver}/deliveries?*`,
async (route) => {
const json = MOCK_GET_DELIVERIES_IGNORE_FULL_ELR;
await route.fulfill({ json, status: responseStatus });
},
);
await page.route(`${API_WATERS_ORG}/ignore.${receiver}/deliveries?*`, async (route) => {
await route.fulfill({ json: MOCK_GET_DELIVERIES_IGNORE_FULL_ELR, status: responseStatus });
});
} else if (byReportId) {
await page.route(
`${API_WATERS_ORG}/ignore/deliveries?sortdir=DESC&cursor=3000-01-01T00:00:00.000Z&since=2000-01-01T00:00:00.000Z&until=3000-01-01T00:00:00.000Z&pageSize=61&receivingOrgSvcStatus=ACTIVE,TESTING&reportId=729158ce-4125-46fa-bea0-3c0f910f472c`,
async (route) => {
const json = MOCK_GET_DELIVERIES_IGNORE_REPORT_ID;
await route.fulfill({
json,
json: MOCK_GET_DELIVERIES_IGNORE_REPORT_ID,
status: 200,
});
},
Expand All @@ -113,51 +102,34 @@ export async function mockGetDeliveriesForOrgIgnoreResponse(
await page.route(
`${API_WATERS_ORG}/ignore/deliveries?sortdir=DESC&cursor=3000-01-01T00:00:00.000Z&since=2000-01-01T00:00:00.000Z&until=3000-01-01T00:00:00.000Z&pageSize=61&receivingOrgSvcStatus=ACTIVE,TESTING&fileName=21c217a4-d098-494c-9364-f4dcf16b1d63-20240426204235.fhir`,
async (route) => {
const json = MOCK_GET_DELIVERIES_IGNORE_FILENAME;
await route.fulfill({
json,
json: MOCK_GET_DELIVERIES_IGNORE_FILENAME,
status: 200,
});
},
);
} else {
await page.route(
`${API_WATERS_ORG}/ignore/deliveries?*`,
async (route) => {
const json = MOCK_GET_DELIVERIES_IGNORE;
await route.fulfill({ json, status: responseStatus });
},
);
await page.route(`${API_WATERS_ORG}/ignore/deliveries?*`, async (route) => {
await route.fulfill({ json: MOCK_GET_DELIVERIES_IGNORE, status: responseStatus });
});
}
}

export async function mockGetReportFacilitiesResponse(
page: Page,
id: string,
responseStatus = 200,
) {
export async function mockGetReportFacilitiesResponse(page: Page, id: string, responseStatus = 200) {
await page.route(`${API_WATERS_REPORT}/${id}/facilities`, async (route) => {
const json = MOCK_GET_FACILITIES;
await route.fulfill({ json, status: responseStatus });
});
}

export async function mockGetSubmissionHistoryResponse(
page: Page,
id: string,
responseStatus = 200,
) {
export async function mockGetSubmissionHistoryResponse(page: Page, id: string, responseStatus = 200) {
await page.route(`${API_WATERS_REPORT}/${id}/history`, async (route) => {
const json = MOCK_GET_SUBMISSION_HISTORY;
await route.fulfill({ json, status: responseStatus });
});
}

export async function mockGetHistoryReportResponse(
page: Page,
id: string,
responseStatus = 200,
) {
export async function mockGetHistoryReportResponse(page: Page, id: string, responseStatus = 200) {
await page.route(`${API_HISTORY_REPORT}/${id}`, async (route) => {
const json = MOCK_GET_HISTORY_REPORT;
await route.fulfill({ json, status: responseStatus });
Expand All @@ -176,7 +148,5 @@ export async function downloadFile(page: Page, id: string, fileName: string) {
// assert filename
expect(download.suggestedFilename()).toBe(fileName);
// get and assert stats
expect(
(await fs.promises.stat(await download.path())).size,
).toBeGreaterThan(200);
expect((await fs.promises.stat(await download.path())).size).toBeGreaterThan(200);
}
Loading

0 comments on commit 198d84e

Please sign in to comment.