From 8b3e1f0e97b67a61fefffe1f99ddac61c5768478 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 5 Oct 2025 06:15:43 +0200 Subject: [PATCH] test: copy satellite ID from console overview instead of workaround --- e2e/page-objects/console.page.ts | 15 +++++++++++++++ e2e/utils/init.utils.ts | 9 +-------- playwright.config.ts | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/e2e/page-objects/console.page.ts b/e2e/page-objects/console.page.ts index 40f0cc1e..326abf1f 100644 --- a/e2e/page-objects/console.page.ts +++ b/e2e/page-objects/console.page.ts @@ -1,4 +1,6 @@ import {InternetIdentityPage} from '@dfinity/internet-identity-playwright'; +import {notEmptyString} from '@dfinity/utils'; +import {PrincipalTextSchema} from '@dfinity/zod-schemas'; import {expect} from '@playwright/test'; import {testIds} from '../constants/test-ids.constants'; import {IdentityPage, type IdentityPageParams} from './identity.page'; @@ -84,4 +86,17 @@ export class ConsolePage extends IdentityPage { context: this.context }); } + + async copySatelliteID(): Promise { + await expect(this.page.getByTestId(testIds.satelliteOverview.copySatelliteId)).toBeVisible(); + + await this.page.getByTestId(testIds.satelliteOverview.copySatelliteId).click(); + + const satelliteId = await this.page.evaluate(() => navigator.clipboard.readText()); + + expect(notEmptyString(satelliteId)).toBeTruthy(); + expect(PrincipalTextSchema.safeParse(satelliteId).success).toBeTruthy(); + + return satelliteId; + } } diff --git a/e2e/utils/init.utils.ts b/e2e/utils/init.utils.ts index f0705266..a23ef2ae 100644 --- a/e2e/utils/init.utils.ts +++ b/e2e/utils/init.utils.ts @@ -1,5 +1,4 @@ import {testWithII} from '@dfinity/internet-identity-playwright'; -import {assertNonNullish} from '@dfinity/utils'; import {CliPage} from '../page-objects/cli.page'; import {ConsolePage} from '../page-objects/console.page'; @@ -30,13 +29,7 @@ export const initTestSuite = (): (() => TestSuitePages) => { await consolePage.createSatellite({kind: 'website'}); - // TODO: replace with a testId that copies to Satellite ID from the Overview - const currentUrl = await page.evaluate(() => document.location.href); - const url = URL.parse(currentUrl); - assertNonNullish(url); - const urlParams = new URLSearchParams(url.searchParams); - const satelliteId = urlParams.get('s'); - assertNonNullish(satelliteId); + const satelliteId = await consolePage.copySatelliteID(); cliPage = await CliPage.initWithEmulatorLogin({satelliteId}); }); diff --git a/playwright.config.ts b/playwright.config.ts index a6ded49c..d5e6e9fe 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -19,7 +19,8 @@ export default defineConfig({ testIdAttribute: 'data-tid', baseURL: 'http://localhost:5866', trace: 'on', - ...(DEV && {headless: false}) + ...(DEV && {headless: false}), + permissions: ['clipboard-read', 'clipboard-write'] }, projects: [ {