Skip to content

Commit

Permalink
test: addressed anvil index flakiness issues (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaten committed Nov 4, 2024
1 parent f9ebce2 commit f05f64d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 40 deletions.
2 changes: 1 addition & 1 deletion explorer/e2e/anvil/anvil-index-export-button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "../testFunctions";
import { ANVIL_TABS } from "./anvil-tabs";

test("Smoke test File Manifest Request index export workflow on the Diles tab", async ({
test("Smoke test File Manifest Request index export workflow on the Files tab", async ({
page,
}) => {
await testIndexExportWorkflow(page, ANVIL_TABS.FILES);
Expand Down
45 changes: 6 additions & 39 deletions explorer/e2e/testFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1063,32 +1063,6 @@ export async function testBackpageDetails(
return true;
}

type DownloadResult = {
filename: string;
url: string;
};

/**
* Attempt to download a file, confirm that it succeeds, and get the filename and file url
* @param page - a Playwright Page object
* @param downloadActionLocator - a locator that initiates the file download when clicked
* @returns - an object containing the url and filename
*/
async function checkDownloadAndReturnLink(
page: Page,
downloadActionLocator: Locator
): Promise<DownloadResult> {
const downloadPromise = page.waitForEvent("download");
await downloadActionLocator.click();
const download = await downloadPromise;
const downloadFilename = download.suggestedFilename();
const downloadUrl = download.url();
return {
filename: downloadFilename,
url: downloadUrl,
};
}

export async function testIndexExportWorkflow(
page: Page,
tab: TabDescription
Expand Down Expand Up @@ -1121,24 +1095,17 @@ export async function testIndexExportWorkflow(
});
// Complete the export request form
await makeMinimalExportRequest(page, exportRequestButtonLocator);
if (tab.indexExportPage?.secondLoadingMessage !== undefined) {
await expect(
page.getByText(tab.indexExportPage.secondLoadingMessage, {
exact: true,
})
).toBeVisible();
}
// Click the Export Action button and check that a download occurs
const exportActionButtonLocator = page.getByRole("link", {
name: tab.indexExportPage?.exportActionButtonText,
});
await expect(exportActionButtonLocator).toBeEnabled();
const downloadResult = await checkDownloadAndReturnLink(
page,
exportActionButtonLocator
);
console.log(downloadResult);
const downloadPromise = page.waitForEvent("download", { timeout: 10000 }); // This timeout is necessary, as otherwise the test will wait for the global test timeout
await exportActionButtonLocator.click();
const download = await downloadPromise;
// Cancel the download when it occurs, since there's no need to let it fully download
await download.cancel();
return true;
//TODO: validate the results from the downnload
}

export async function testIndexExportSummary(
Expand Down

0 comments on commit f05f64d

Please sign in to comment.