Skip to content

Commit 6cb1182

Browse files
fix: file and summary request params #4102
1 parent 7080737 commit 6cb1182

File tree

6 files changed

+151
-73
lines changed

6 files changed

+151
-73
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Filters } from "@databiosphere/findable-ui/lib/common/entities";
2+
import { useFileManifest } from "@databiosphere/findable-ui/lib/hooks/useFileManifest/useFileManifest";
3+
4+
export interface ExportEntityProps {
5+
filters: Filters;
6+
}
7+
8+
/**
9+
* Empty wrapper component that triggers calls to populate the selected data in the side channel. Required only
10+
* for choose export method functionality (as individual export methods trigger the required calls themsleves).
11+
* @param {Object} props - The properties object.
12+
* @param {ExportEntityProps} props.filters - The base filters for displaying the selected data related.
13+
* @returns Fragment.
14+
*/
15+
export const ExportEntity = ({ filters }: ExportEntityProps): JSX.Element => {
16+
useFileManifest(filters);
17+
return <></>;
18+
};

app/components/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export { FileNameCell } from "./Detail/components/GeneratedMatricesTables/compon
9595
export { GeneratedMatricesTables } from "./Detail/components/GeneratedMatricesTables/generatedMatricesTables";
9696
export { AtlasSection } from "./Detail/components/Section/components/AtlasSection/atlasSection";
9797
export { ManifestDownloadEntity as AnVILManifestDownloadEntity } from "./Export/components/AnVILExplorer/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity";
98+
export { ExportEntity as AnVILExportEntity } from "./Export/components/AnVILExplorer/components/ExportEntity/exportEntity";
9899
export { BioNetworkCell } from "./Index/components/BioNetworkCell/bioNetworkCell";
99100
export { ConsentCodesCell } from "./Index/components/ConsentCodesCell/consentCodesCell";
100101
export { CopyCell } from "./Index/components/CopyCell/copyCell";

app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders.ts

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import { FEATURE_FLAGS } from "../../../common/contants";
111111
import { Unused, Void } from "../../../common/entities";
112112
import { SUMMARY_DISPLAY_TEXT } from "./summaryMapper/constants";
113113
import { mapExportSummary } from "./summaryMapper/summaryMapper";
114+
import { ExportEntity } from "app/components/Export/components/AnVILExplorer/components/ExportEntity/exportEntity";
114115

115116
/**
116117
* Build props for activity type BasicCell component from the given activities response.
@@ -468,6 +469,22 @@ export const buildDatasetExportMethodManifestDownload = (
468469
};
469470
};
470471

472+
/**
473+
* Build props for either the ExportEntity component for the display of the choose export methods or
474+
* the AnVILManifestDownloadEntity component for the display of the manifest download method.
475+
* @param datasetsResponse - Response model return from datasets API.
476+
* @returns model to be used as props for the ExportEntity component.
477+
*/
478+
export const buildDatasetExportPropsWithFilter = (
479+
datasetsResponse: DatasetsResponse
480+
):
481+
| React.ComponentProps<typeof ExportEntity>
482+
| typeof C.AnVILManifestDownloadEntity => {
483+
return {
484+
filters: getExportEntityFilters(datasetsResponse),
485+
};
486+
};
487+
471488
/**
472489
* Build props for ExportMethod component for display of the export to terra metadata section.
473490
* @param datasetsResponse - Response model return from datasets API.
@@ -525,6 +542,35 @@ export function buildDatasetPath(datasetsResponse: DatasetsResponse): string {
525542
return `${URL_DATASETS}/${datasetId}`;
526543
}
527544

545+
/**
546+
* Build props for dataset ExportToTerra component.
547+
* @param datasetsResponse - Response model return from datasets API.
548+
* @param viewContext - View context.
549+
* @returns model to be used as props for the ExportToTerra component.
550+
*/
551+
export const builDatasetTerraExport = (
552+
datasetsResponse: DatasetsResponse,
553+
viewContext: ViewContext<DatasetsResponse>
554+
): React.ComponentProps<typeof C.ExportToTerra> => {
555+
const { fileManifestState } = viewContext;
556+
// Get the initial filters.
557+
const filters = getExportEntityFilters(datasetsResponse);
558+
// Grab the form facet.
559+
const formFacet = getFormFacets(fileManifestState);
560+
return {
561+
ExportForm: C.ExportToTerraForm,
562+
ExportToTerraStart: MDX.ExportToTerraStart,
563+
ExportToTerraSuccess: MDX.ExportToTerraSuccess,
564+
fileManifestState,
565+
fileManifestType: FILE_MANIFEST_TYPE.ENTITY_EXPORT_TO_TERRA,
566+
fileSummaryFacetName: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT,
567+
filters,
568+
formFacet,
569+
manifestDownloadFormat: MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB,
570+
manifestDownloadFormats: [MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB],
571+
};
572+
};
573+
528574
/**
529575
* Build dataset title Link component from the given datasets response.
530576
* @param datasetsResponse - Response model return from datasets API.
@@ -624,35 +670,6 @@ export const buildExportCurrentQuery = (
624670
};
625671
};
626672

627-
/**
628-
* Build props for ExportToTerra component from the given datasets response.
629-
* @param datasetsResponse - Response model return from datasets API.
630-
* @param viewContext - View context.
631-
* @returns model to be used as props for the ExportToTerra component.
632-
*/
633-
export const buildExportEntityToTerra = (
634-
datasetsResponse: DatasetsResponse,
635-
viewContext: ViewContext<DatasetsResponse>
636-
): React.ComponentProps<typeof C.ExportToTerra> => {
637-
const { fileManifestState } = viewContext;
638-
// Get the initial filters.
639-
const filters = getExportEntityFilters(datasetsResponse);
640-
// Grab the form facet.
641-
const formFacet = getFormFacets(fileManifestState);
642-
return {
643-
ExportForm: C.ExportToTerraForm,
644-
ExportToTerraStart: MDX.ExportToTerraStart,
645-
ExportToTerraSuccess: MDX.ExportToTerraSuccess,
646-
fileManifestState,
647-
fileManifestType: FILE_MANIFEST_TYPE.ENTITY_EXPORT_TO_TERRA,
648-
fileSummaryFacetName: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT,
649-
filters,
650-
formFacet,
651-
manifestDownloadFormat: MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB,
652-
manifestDownloadFormats: [MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB],
653-
};
654-
};
655-
656673
/**
657674
* Build props for export BackPageHero component.
658675
* @param _ - Void.
@@ -913,19 +930,6 @@ export const buildManifestDownload = (
913930
};
914931
};
915932

916-
/*
917-
* Build props for ManifestDownloadEntity component.
918-
* @param datasetsResponse - Response model return from datasets API.
919-
* @returns model to be used as props for the ManifestDownloadEntity component.
920-
*/
921-
export const buildManifestDownloadEntity = (
922-
datasetsResponse: DatasetsResponse
923-
): React.ComponentProps<typeof C.AnVILManifestDownloadEntity> => {
924-
return {
925-
filters: getExportEntityFilters(datasetsResponse),
926-
};
927-
};
928-
929933
/**
930934
* Build props for organism type BasicCell component from the given donors response.
931935
* @param response - Response model return from index/donors API endpoint.

e2e/anvil/anvil-dataset.spec.ts

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, Locator, Page, test } from "@playwright/test";
1+
import { expect, Locator, Page, Request, test } from "@playwright/test";
22
import {
33
BUTTON_TEXT_ANALYZE_IN_TERRA,
44
BUTTON_TEXT_EXPORT,
@@ -16,6 +16,11 @@ import {
1616
MUI_TABLE_ROW_ROOT,
1717
} from "../features/common/constants";
1818
import { ROUTE_MANIFEST_DOWNLOAD } from "../../site-config/anvil-cmg/dev/export/constants";
19+
import { ANVIL_CMG_CATEGORY_KEY } from "../../site-config/anvil-cmg/category";
20+
import {
21+
APIEndpoints,
22+
AZUL_PARAM,
23+
} from "@databiosphere/findable-ui/lib/apis/azul/common/entities";
1924

2025
const { describe } = test;
2126

@@ -40,6 +45,21 @@ describe.parallel("Dataset", () => {
4045
await expect(exportButton).toBeVisible();
4146
});
4247

48+
test("displays login to export method", async ({ page }) => {
49+
await goToDataset(page, CHIP_TEXT_ACCESS_REQUIRED);
50+
51+
// Navigate to the choose export method page.
52+
const currentUrl = page.url();
53+
await page.goto(`${currentUrl}/export`);
54+
55+
// Confirm the login alert is displayed.
56+
await expect(
57+
page.locator(
58+
`${MUI_ALERT_ROOT}:has-text("To export this dataset, please sign in and, if necessary, request access.")`
59+
)
60+
).toBeVisible();
61+
});
62+
4363
test("displays export method", async ({ page }) => {
4464
await goToDataset(page, CHIP_TEXT_ACCESS_GRANTED);
4565

@@ -55,6 +75,36 @@ describe.parallel("Dataset", () => {
5575
).toBeVisible();
5676
});
5777

78+
test("displays export method selected data", async ({ page }) => {
79+
await goToDataset(page, CHIP_TEXT_ACCESS_GRANTED);
80+
81+
// Wait for the summary request once the export button is clicked.
82+
const [request] = await Promise.all([
83+
page.waitForRequest((request) =>
84+
request.url().includes(APIEndpoints.SUMMARY)
85+
),
86+
clickLink(page, BUTTON_TEXT_EXPORT),
87+
]);
88+
89+
// Confirm summary request has dataset ID request param.
90+
verifySummaryRequest(request);
91+
});
92+
93+
test("displays login to download file manifest", async ({ page }) => {
94+
await goToDataset(page, CHIP_TEXT_ACCESS_REQUIRED);
95+
96+
// Navigate to the export file manifest page.
97+
const currentUrl = page.url();
98+
await page.goto(`${currentUrl}${ROUTE_MANIFEST_DOWNLOAD}`);
99+
100+
// Confirm the login alert is displayed.
101+
await expect(
102+
page.locator(
103+
`${MUI_ALERT_ROOT}:has-text("To download this dataset manifest, please sign in and, if necessary, request access.")`
104+
)
105+
).toBeVisible();
106+
});
107+
58108
test("displays download file manifest", async ({ page }) => {
59109
await goToDataset(page, CHIP_TEXT_ACCESS_GRANTED);
60110

@@ -76,37 +126,25 @@ describe.parallel("Dataset", () => {
76126
await expect(buttons.nth(1)).toBeVisible();
77127
});
78128

79-
test("displays login to export method", async ({ page }) => {
80-
await goToDataset(page, CHIP_TEXT_ACCESS_REQUIRED);
81-
82-
// Navigate to the choose export method page.
83-
const currentUrl = page.url();
84-
await page.goto(`${currentUrl}/export`);
85-
86-
// Confirm the login alert is displayed.
87-
await expect(
88-
page.locator(
89-
`${MUI_ALERT_ROOT}:has-text("To export this dataset, please sign in and, if necessary, request access.")`
90-
)
91-
).toBeVisible();
92-
});
129+
test("displays download file manifest selected data", async ({ page }) => {
130+
await goToDataset(page, CHIP_TEXT_ACCESS_GRANTED);
93131

94-
test("displays login to download file manifest", async ({ page }) => {
95-
await goToDataset(page, CHIP_TEXT_ACCESS_REQUIRED);
132+
// Confirm export button is visible and click it.
133+
await clickLink(page, BUTTON_TEXT_EXPORT);
96134

97-
// Navigate to the export file manifest page.
98-
const currentUrl = page.url();
99-
await page.goto(`${currentUrl}${ROUTE_MANIFEST_DOWNLOAD}`);
135+
// Wait for the summary request once the file manifest button is clicked.
136+
const [request] = await Promise.all([
137+
page.waitForRequest((request) =>
138+
request.url().includes(APIEndpoints.SUMMARY)
139+
),
140+
clickLink(page, BUTTON_TEXT_REQUEST_FILE_MANIFEST),
141+
]);
100142

101-
// Confirm the login alert is displayed.
102-
await expect(
103-
page.locator(
104-
`${MUI_ALERT_ROOT}:has-text("To download this dataset manifest, please sign in and, if necessary, request access.")`
105-
)
106-
).toBeVisible();
143+
// Confirm summary request has dataset ID request param.
144+
verifySummaryRequest(request);
107145
});
108146

109-
test("displays download analyze in Terra", async ({ page }) => {
147+
test("displays analyze in Terra", async ({ page }) => {
110148
await goToDataset(page, CHIP_TEXT_ACCESS_GRANTED);
111149

112150
// Confirm export button is visible and click it.
@@ -174,3 +212,16 @@ async function goToDataset(page: Page, access: DatasetAccess): Promise<void> {
174212
// Wait for the dataset detail page to load (specifically the dataset title).
175213
await page.waitForSelector(`h1:has-text("${datasetTitle}")`);
176214
}
215+
216+
/**
217+
* Confirm dataset ID is in the /summary request URL.
218+
* @param request - The request object.
219+
*/
220+
function verifySummaryRequest(request: Request): void {
221+
// Grab the filters param from the request.
222+
const url = new URL(request.url());
223+
const paramValue = url.searchParams.get(AZUL_PARAM.FILTERS) || "";
224+
225+
// Validate dataset ID is in the filters query parameter.
226+
expect(paramValue).toContain(ANVIL_CMG_CATEGORY_KEY.DATASET_ID);
227+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"check-system-status:anvil-cmg": "esrun e2e/anvil/anvil-check-system-status.ts"
3636
},
3737
"dependencies": {
38-
"@databiosphere/findable-ui": "21.1.0",
38+
"@databiosphere/findable-ui": "21.1.1",
3939
"@emotion/react": "^11.13.3",
4040
"@emotion/styled": "^11.13.0",
4141
"@mdx-js/loader": "^3.0.1",

site-config/anvil-cmg/dev/detail/dataset/export/export.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const exportConfig: ExportConfig = {
5454
children: [
5555
{
5656
component: C.ExportToTerra,
57-
viewBuilder: V.buildExportToTerra,
57+
viewBuilder: V.builDatasetTerraExport,
5858
} as ComponentConfig<typeof C.ExportToTerra>,
5959
],
6060
component: C.BackPageContentMainColumn,
@@ -104,7 +104,7 @@ export const exportConfig: ExportConfig = {
104104
children: [
105105
{
106106
component: C.AnVILManifestDownloadEntity,
107-
viewBuilder: V.buildManifestDownloadEntity,
107+
viewBuilder: V.buildDatasetExportPropsWithFilter,
108108
} as ComponentConfig<
109109
typeof C.AnVILManifestDownloadEntity,
110110
DatasetsResponse
@@ -143,7 +143,6 @@ export const exportConfig: ExportConfig = {
143143
children: [
144144
{
145145
component: MDX.Alert,
146-
// TODO(cc) update text
147146
viewBuilder: V.buildAlertDatasetExportWarning,
148147
} as ComponentConfig<typeof MDX.Alert, DatasetsResponse>,
149148
],
@@ -160,6 +159,11 @@ export const exportConfig: ExportConfig = {
160159
children: [
161160
{
162161
children: [
162+
// Empty component for triggering calls to populate the selected data in the side channel.
163+
{
164+
component: C.AnVILExportEntity,
165+
viewBuilder: V.buildDatasetExportPropsWithFilter,
166+
} as ComponentConfig<typeof C.AnVILExportEntity>,
163167
{
164168
component: C.ExportMethod,
165169
viewBuilder: V.buildDatasetExportMethodTerra,

0 commit comments

Comments
 (0)