forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfixtures.ts
45 lines (40 loc) · 1.25 KB
/
fixtures.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import path from 'path';
import { test as base, chromium, type BrowserContext } from '@playwright/test';
const EXTENSION_PATH = path.join(__dirname, '../dist');
const LAUNCH_ARGS = [
`--disable-extensions-except=${EXTENSION_PATH}`,
`--load-extension=${EXTENSION_PATH}`,
// Ensure userAgent is correctly set in serviceworker:
'--user-agent=Playwright',
];
export const test = base.extend<{
context: BrowserContext;
extensionUrl: string;
demoPageUrl: string;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
const context = await chromium.launchPersistentContext('', {
headless: false,
args: LAUNCH_ARGS,
});
await use(context);
await context.close();
},
extensionUrl: async ({ context }, use) => {
let [background] = context.serviceWorkers();
if (!background) {
background = await context.waitForEvent('serviceworker');
}
const extensionId = background.url().split('/')[2];
const extensionUrl = `chrome-extension://${extensionId}/ui.html`;
await use(extensionUrl);
},
// eslint-disable-next-line no-empty-pattern
demoPageUrl: async ({}, use) => {
await use('http://localhost:5181');
},
});
export const expect = test.expect;