Path: blob/main/test/componentFixtures/playwright/tests/utils.ts
13527 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Page } from '@playwright/test';67function getBaseURL(): string {8const port = process.env['COMPONENT_EXPLORER_PORT'];9if (!port) {10throw new Error('COMPONENT_EXPLORER_PORT is not set. Is the webServer running?');11}12return `http://localhost:${port}`;13}1415/**16* Navigates to a component fixture in embedded mode and waits for it to render.17* @param waitForSelector - A CSS selector to wait for after navigation, indicating the fixture has rendered.18*/19export async function openFixture(page: Page, fixtureId: string, waitForSelector = '.image-carousel-editor'): Promise<void> {20const url = `${getBaseURL()}/___explorer?mode=embedded&fixture=${encodeURIComponent(fixtureId)}`;21await page.goto(url, { waitUntil: 'load' });22await page.locator(waitForSelector).waitFor({ state: 'visible', timeout: 20_000 });23}242526