Adds playwright component fixture tests

This commit is contained in:
Henning Dieterichs
2026-04-01 11:05:45 +02:00
committed by Henning Dieterichs
parent bd5138e608
commit 6e701d61b3
10 changed files with 405 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Page } from '@playwright/test';
function getBaseURL(): string {
const port = process.env['COMPONENT_EXPLORER_PORT'];
if (!port) {
throw new Error('COMPONENT_EXPLORER_PORT is not set. Is the webServer running?');
}
return `http://localhost:${port}`;
}
/**
* Navigates to a component fixture in embedded mode and waits for it to render.
* @param waitForSelector - A CSS selector to wait for after navigation, indicating the fixture has rendered.
*/
export async function openFixture(page: Page, fixtureId: string, waitForSelector = '.image-carousel-editor'): Promise<void> {
const url = `${getBaseURL()}/___explorer?mode=embedded&fixture=${encodeURIComponent(fixtureId)}`;
await page.goto(url, { waitUntil: 'load' });
await page.locator(waitForSelector).waitFor({ state: 'visible', timeout: 20_000 });
}