mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
Adds playwright component fixture tests
This commit is contained in:
committed by
Henning Dieterichs
parent
bd5138e608
commit
6e701d61b3
24
test/componentFixtures/playwright/tests/utils.ts
Normal file
24
test/componentFixtures/playwright/tests/utils.ts
Normal 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 });
|
||||
}
|
||||
Reference in New Issue
Block a user