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