Skip to content

Commit 0d6bb2f

Browse files
authored
devops: add bots for other browsers/platforms (microsoft#174)
1 parent 795a9d5 commit 0d6bb2f

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ on:
88

99
jobs:
1010
build-and-test:
11-
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
1216

1317
steps:
1418
- uses: actions/checkout@v4
@@ -25,6 +29,10 @@ jobs:
2529
- name: Playwright install
2630
run: npx playwright install --with-deps
2731

32+
- name: Install MS Edge
33+
if: ${{ matrix.os == 'macos-latest' }} # MS Edge is not preinstalled on macOS runners.
34+
run: npx playwright install msedge
35+
2836
- name: Run linting
2937
run: npm run lint
3038

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- run: npx playwright install --with-deps
1919
- run: npm run build
2020
- run: npm run lint
21-
- run: npm run test
21+
- run: npm run ctest
2222
- run: npm publish --provenance
2323
env:
2424
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"lint": "eslint .",
2020
"watch": "tsc --watch",
2121
"test": "playwright test",
22+
"ctest": "playwright test --project=chrome",
2223
"clean": "rm -rf lib",
2324
"npm-publish": "npm run clean && npm run build && npm run test && npm publish"
2425
},

playwright.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@
1616

1717
import { defineConfig } from '@playwright/test';
1818

19+
import type { Project } from '@playwright/test';
20+
1921
export default defineConfig({
2022
testDir: './tests',
2123
fullyParallel: true,
2224
forbidOnly: !!process.env.CI,
2325
retries: process.env.CI ? 2 : 0,
2426
workers: process.env.CI ? 1 : undefined,
2527
reporter: 'list',
26-
projects: [{ name: 'default' }],
28+
projects: [
29+
{ name: 'chrome' },
30+
{ name: 'msedge', use: { mcpBrowser: 'msedge' } },
31+
{ name: 'chromium', use: { mcpBrowser: 'chromium' } },
32+
{ name: 'firefox', use: { mcpBrowser: 'firefox' } },
33+
{ name: 'webkit', use: { mcpBrowser: 'webkit' } },
34+
].filter(Boolean) as Project[],
2735
});

tests/fixtures.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ type Fixtures = {
2828
startClient: (options?: { args?: string[] }) => Promise<Client>;
2929
wsEndpoint: string;
3030
cdpEndpoint: string;
31+
32+
// Cli options.
33+
mcpHeadless: boolean;
34+
mcpBrowser: string | undefined;
3135
};
3236

3337
export const test = baseTest.extend<Fixtures>({
@@ -40,12 +44,16 @@ export const test = baseTest.extend<Fixtures>({
4044
await use(await startClient({ args: ['--vision'] }));
4145
},
4246

43-
startClient: async ({ }, use, testInfo) => {
47+
startClient: async ({ mcpHeadless, mcpBrowser }, use, testInfo) => {
4448
const userDataDir = testInfo.outputPath('user-data-dir');
4549
let client: StdioClientTransport | undefined;
4650

4751
use(async options => {
48-
const args = ['--headless', '--user-data-dir', userDataDir];
52+
const args = ['--user-data-dir', userDataDir];
53+
if (mcpHeadless)
54+
args.push('--headless');
55+
if (mcpBrowser)
56+
args.push(`--browser=${mcpBrowser}`);
4957
if (options?.args)
5058
args.push(...options.args);
5159
const transport = new StdioClientTransport({
@@ -89,6 +97,12 @@ export const test = baseTest.extend<Fixtures>({
8997
await use(`http://localhost:${port}`);
9098
browserProcess.kill();
9199
},
100+
101+
mcpHeadless: async ({ headless }, use) => {
102+
await use(headless);
103+
},
104+
105+
mcpBrowser: ['chromium', { option: true }],
92106
});
93107

94108
type Response = Awaited<ReturnType<Client['callTool']>>;

tests/pdf.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ test('save as pdf unavailable', async ({ startClient }) => {
3030
})).toHaveTextContent(/Tool \"browser_pdf_save\" not found/);
3131
});
3232

33-
test('save as pdf', async ({ client }) => {
33+
test('save as pdf', async ({ client, mcpBrowser }) => {
34+
test.skip(!!mcpBrowser && !['chromium', 'chrome', 'msedge'].includes(mcpBrowser), 'Save as PDF is only supported in Chromium.');
3435
expect(await client.callTool({
3536
name: 'browser_navigate',
3637
arguments: {

0 commit comments

Comments
 (0)