Skip to content

Commit 8dea0c7

Browse files
authored
feat: add github actions for puppeteer and playwright (#12)
* fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow * fix: debug workflow
1 parent b74d7b3 commit 8dea0c7

File tree

8 files changed

+32
-52
lines changed

8 files changed

+32
-52
lines changed

.github/workflows/command-line-demo.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
description: 'Midscene report directory'
1212
required: true
1313
default: 'command-line/midscene_run/report/'
14+
push:
15+
branches:
16+
- main
1417

1518
jobs:
1619
run_script:

.github/workflows/playwright-demo.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ on:
66
output_folder:
77
description: 'Midscene report dir'
88
required: true
9-
default: 'playwright-demo/midscene-run/report'
9+
default: 'playwright-demo/midscene_run/report'
10+
push:
11+
branches:
12+
- main
1013

1114
jobs:
1215
run_script:
@@ -16,6 +19,7 @@ jobs:
1619
uses: actions/checkout@v4
1720

1821
- name: Run script
22+
id: run-script
1923
env:
2024
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
2125
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -24,10 +28,15 @@ jobs:
2428
npm i pnpm -g
2529
pnpm install
2630
pnpm run e2e
31+
continue-on-error: true
2732

2833
- name: Upload output folder
2934
uses: actions/upload-artifact@v4
3035
with:
3136
if-no-files-found: error
3237
name: Midscene Report
33-
path: ${{ github.workspace }}/${{ github.event.inputs.output_folder }}
38+
path: ${{ github.workspace }}/${{ github.event.inputs.output_folder }}
39+
40+
- name: Check if script failed
41+
if: steps.run-script.outcome == 'failure'
42+
run: exit 1

.github/workflows/puppeteer-demo.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ on:
66
output_folder:
77
description: 'Midscene report dir'
88
required: true
9-
default: 'puppeteer-demo/midscene-run/report'
9+
default: 'puppeteer-demo/midscene_run/report'
10+
push:
11+
branches:
12+
- main
1013

1114
jobs:
1215
run_script:
@@ -16,6 +19,7 @@ jobs:
1619
uses: actions/checkout@v4
1720

1821
- name: Run script
22+
id: run-script
1923
env:
2024
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
2125
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -24,10 +28,15 @@ jobs:
2428
npm i pnpm -g
2529
pnpm install
2630
pnpm run test
31+
continue-on-error: true
2732

2833
- name: Upload output folder
2934
uses: actions/upload-artifact@v4
3035
with:
3136
if-no-files-found: error
3237
name: Midscene Report
33-
path: ${{ github.workspace }}/${{ github.event.inputs.output_folder }}
38+
path: ${{ github.workspace }}/${{ github.event.inputs.output_folder }}
39+
40+
- name: Check if script failed
41+
if: steps.run-script.outcome == 'failure'
42+
run: exit 1

playwright-demo/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pnpm run e2e:ui
2727
# run e2e with playwright ui + cache
2828
pnpm run e2e:ui:cache
2929

30-
3130
# read report
3231
# You must run the pnpm run e2e or pnpm e2e:cache to view the report
3332
node ./midscene_run/midscene-report/index.js

playwright-demo/e2e/todo-mvc-en.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ test("ai todo - English Prompt - should fail", async ({
2929

3030
expect(list.length).toEqual(1);
3131

32-
// expect an error here. AI will give you the reason in error message.
33-
await aiAssert('At the bottom of the page, it shows "3 items left".');
32+
await aiAssert('At the bottom of the page, it shows "1 item left".');
3433
});

playwright-demo/e2e/todo-mvc-zh.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ test("ai todo - Chinese Prompt - should fail", async ({
2020
const list = await aiQuery("string[], 完整的任务列表");
2121
expect(list.length).toEqual(1);
2222

23-
// 这里应该要抛错,注意观察错误信息里会有 AI 给出的 reason
24-
await aiAssert('页面底部显示有 "3 items left"');
23+
await aiAssert('页面底部显示有 "1 item left"');
2524
});

playwright-demo/playwright.config.ts

+4-42
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import { defineConfig, devices } from '@playwright/test';
2-
import dotenv from 'dotenv';
1+
import { defineConfig, devices } from "@playwright/test";
2+
import dotenv from "dotenv";
33

44
/**
55
* Read environment variables from file.
66
* https://github.com/motdotla/dotenv
77
*/
88
dotenv.config();
99

10-
1110
/**
1211
* See https://playwright.dev/docs/test-configuration.
1312
*/
1413
export default defineConfig({
1514
testDir: "./e2e",
1615
testMatch: "**/*.spec.ts",
17-
timeout: 90000 * 1000,
16+
timeout: 180 * 1000,
1817
/* Run tests in files in parallel */
19-
fullyParallel: true,
18+
fullyParallel: false,
2019
/* Fail the build on CI if you accidentally left test.only in the source code. */
2120
forbidOnly: Boolean(process.env.CI),
2221
/* Retry on CI only */
@@ -40,42 +39,5 @@ export default defineConfig({
4039
name: "chromium",
4140
use: { ...devices["Desktop Chrome"] },
4241
},
43-
44-
// {
45-
// name: 'firefox',
46-
// use: { ...devices['Desktop Firefox'] },
47-
// },
48-
49-
// {
50-
// name: 'webkit',
51-
// use: { ...devices['Desktop Safari'] },
52-
// },
53-
54-
/* Test against mobile viewports. */
55-
// {
56-
// name: 'Mobile Chrome',
57-
// use: { ...devices['Pixel 5'] },
58-
// },
59-
// {
60-
// name: 'Mobile Safari',
61-
// use: { ...devices['iPhone 12'] },
62-
// },
63-
64-
/* Test against branded browsers. */
65-
// {
66-
// name: 'Microsoft Edge',
67-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
68-
// },
69-
// {
70-
// name: 'Google Chrome',
71-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
72-
// },
7342
],
74-
75-
/* Run your local dev server before starting the tests */
76-
// webServer: {
77-
// command: 'npm run start',
78-
// url: 'http://127.0.0.1:3000',
79-
// reuseExistingServer: !process.env.CI,
80-
// },
8143
});

puppeteer-demo/demo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
66
Promise.resolve(
77
(async () => {
88
const browser = await puppeteer.launch({
9-
headless: false, // 'false' means we can see the browser window
9+
headless: true, // 'true' means we can't see the browser window
1010
});
1111

1212
const page = await browser.newPage();

0 commit comments

Comments
 (0)