|
1 | | -import { expect, Locator, Page } from "@playwright/test"; |
| 1 | +import { BrowserContext, expect, Locator, Page } from "@playwright/test"; |
2 | 2 | import { TabDescription } from "./testInterfaces"; |
3 | 3 |
|
4 | 4 | /* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ |
@@ -431,4 +431,64 @@ export async function testClearAll( |
431 | 431 | await page.locator("body").click(); |
432 | 432 | } |
433 | 433 | } |
| 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 | + |
434 | 494 | /* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/ |
0 commit comments