From b6aaaa6d2c11b7e58306559bd6bb6248c541deab Mon Sep 17 00:00:00 2001 From: MillenniumFalconMechanic Date: Thu, 30 Jan 2025 11:17:25 -0800 Subject: [PATCH] refactor: linting #4102 --- e2e/anvil/anvil-dataset.spec.ts | 2 +- e2e/testFunctions.ts | 15 --------- pages/[entityListType]/[...params].tsx | 42 +++++++++++--------------- 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/e2e/anvil/anvil-dataset.spec.ts b/e2e/anvil/anvil-dataset.spec.ts index a0db07f34..fd22eec57 100644 --- a/e2e/anvil/anvil-dataset.spec.ts +++ b/e2e/anvil/anvil-dataset.spec.ts @@ -27,7 +27,7 @@ describe.parallel("Dataset", () => { test("displays request access button", async ({ page }) => { await goToDataset(page, CHIP_TEXT_ACCESS_REQUIRED); - // Confirm export button is visible. + // Confirm request access button is visible. const exportButton = getLinkWithText(page, BUTTON_TEXT_REQUEST_ACCESS); await expect(exportButton).toBeVisible(); }); diff --git a/e2e/testFunctions.ts b/e2e/testFunctions.ts index b194b7268..b165a6c66 100644 --- a/e2e/testFunctions.ts +++ b/e2e/testFunctions.ts @@ -800,21 +800,6 @@ export async function testDeselectFiltersThroughSearchBar( } } -// /** -// * Get the first link to a backpage with specified backpage access -// * @param page - a Playright page locator -// * @param access - the string denoting the level of access desired -// * @returns a Playwright locator object to the first link to a backpage with the specified access -// */ -// const getBackpageLinkLocatorByAccess = (page: Page, access: string): Locator => -// page -// .getByRole("row") -// .filter({ has: page.getByRole("cell", { name: access }) }) -// .first() -// .getByRole("cell") -// .first() -// .getByRole("link"); - /** * Make an export request that leaves only the minimal number of checkboxes selected * @param page - a Playwright page object diff --git a/pages/[entityListType]/[...params].tsx b/pages/[entityListType]/[...params].tsx index 68ec2e709..311bd5518 100644 --- a/pages/[entityListType]/[...params].tsx +++ b/pages/[entityListType]/[...params].tsx @@ -91,41 +91,35 @@ function isOverride(override: Override): boolean { } /** - * Determine if the current view is choose export. + * Check if the current view matches the expected export path segment. + * @param query - The current query object. + * @param expectedIndex - The expected index for the parameter length check. + * @returns True if the view matches the expected export criteria. + */ +function isExportView(query: ParsedUrlQuery, expectedIndex: number): boolean { + return ( + !!query.params && + query.params.length === expectedIndex + 1 && + query.params[PARAMS_INDEX_TAB] === "export" + ); +} + +/** + * Determine if the current view is choose export method. * @param query - The current query object. * @returns True if the current view is choose export. */ function isChooseExportView(query: ParsedUrlQuery): boolean { - // Must have query params for export view. - if (!query.params) { - return false; - } - // Must have correct number of params for export view. - if (query.params.length !== PARAMS_INDEX_TAB + 1) { - return false; - } - // Must have export param. - const exportPathSegment = query.params[PARAMS_INDEX_TAB]; - return !!exportPathSegment && exportPathSegment === "export"; + return isExportView(query, PARAMS_INDEX_TAB); } /** - * Determine if the current view is an export method. + * Determine if the current view is an export method (e.g. file manifest or Terra). * @param query - The current query object. * @returns True if the current view is an export method. */ function isExportMethodView(query: ParsedUrlQuery): boolean { - // Must have query params for export method view. - if (!query.params) { - return false; - } - // Must have correct number of params for export method view. - if (query.params.length !== PARAMS_INDEX_EXPORT_METHOD + 1) { - return false; - } - // Must have export param. - const exportPathSegment = query.params[PARAMS_INDEX_TAB]; - return !!exportPathSegment && exportPathSegment === "export"; + return isExportView(query, PARAMS_INDEX_EXPORT_METHOD); } /**