Skip to content

Commit 8289093

Browse files
committed
feat: first draft of backpages test (#4080)
1 parent 30f489c commit 8289093

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from "@playwright/test";
2+
import { testExportBackpage } from "../testFunctions";
3+
import { anvilTabs } from "./anvil-tabs";
4+
test("Smoke test `Export to Terra` button on the first available dataset", async ({
5+
context,
6+
page,
7+
}) => {
8+
await testExportBackpage(context, page, anvilTabs.datasets);
9+
});

explorer/e2e/testFunctions.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, Locator, Page } from "@playwright/test";
1+
import { BrowserContext, expect, Locator, Page } from "@playwright/test";
22
import { TabDescription } from "./testInterfaces";
33

44
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */
@@ -431,4 +431,64 @@ export async function testClearAll(
431431
await page.locator("body").click();
432432
}
433433
}
434+
435+
// Backpages tests
436+
export async function testExportBackpage(
437+
context: BrowserContext,
438+
page: Page,
439+
tab: TabDescription
440+
): Promise<void> {
441+
// Goto the specified tab
442+
await page.goto(tab.url);
443+
await expect(getFirstElementTextLocator(page, 1)).toBeVisible();
444+
// Expect to find row with a granted status indicator
445+
const granted_row_locator = await page
446+
.getByRole("row")
447+
.filter({ has: page.getByRole("cell", { name: "Granted" }) })
448+
.first()
449+
.getByRole("cell")
450+
.first();
451+
await expect(granted_row_locator).toBeVisible();
452+
// Click into the selected row
453+
await granted_row_locator.click();
454+
// Click the "Export" tab
455+
await page.getByText("Export", { exact: true }).click();
456+
await expect(page).toHaveURL(/\.*\/export-to-terra/);
457+
await expect(page.getByRole("checkbox").first()).toBeVisible();
458+
const requestLinkButtonLocator = page.getByRole("button", {
459+
name: "Request Link",
460+
});
461+
await expect(requestLinkButtonLocator).toBeEnabled();
462+
// Select all checkboxes on the page
463+
const checkboxes = await page.getByRole("checkbox").all();
464+
console.log(checkboxes);
465+
for (const checkbox of checkboxes) {
466+
console.log(checkbox);
467+
if (!(await checkbox.isChecked())) {
468+
await checkbox.click();
469+
await expect(checkbox).toBeChecked();
470+
await expect(checkbox).toBeEnabled({ timeout: 10000 });
471+
}
472+
}
473+
// Click the "Request Link" button
474+
await expect(requestLinkButtonLocator).toBeEnabled({ timeout: 10000 });
475+
await requestLinkButtonLocator.click();
476+
await expect(
477+
page.getByText("Your link will be ready shortly...", { exact: true })
478+
).toBeVisible();
479+
await expect(
480+
page.getByText("Your Terra Workspace Link is Ready", { exact: true })
481+
).toBeVisible({ timeout: 30000 });
482+
const openTerraButton = page.getByRole("button", { name: "Open Terra" });
483+
await expect(openTerraButton).toBeEnabled();
484+
// Click the "Open Terra" Button and await a new browser tab
485+
const pagePromise = context.waitForEvent("page");
486+
await openTerraButton.click();
487+
const newPage = await pagePromise;
488+
// Expect the new browser tab to look like the Terra page
489+
await expect(
490+
newPage.getByText("Welcome to Terra Community Workbench")
491+
).toBeVisible();
492+
}
493+
434494
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/

0 commit comments

Comments
 (0)