Skip to content

Commit

Permalink
chore: add ai test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoushaw committed Aug 22, 2024
1 parent c5c0ed2 commit cb4cccb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ jobs:
run: pnpm run build:pkg

- name: Run tests
run: pnpm run test
run: pnpm run test:ai

- name: Run e2e tests
run: pnpm run e2e
18 changes: 18 additions & 0 deletions packages/web-integration/tests/ai/e2e/ai-auto-todo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import path from 'node:path';
import { expect } from 'playwright/test';
import { test } from './fixture';

test.beforeEach(async ({ page }) => {
await page.goto('https://todomvc.com/examples/react/dist/');
});

test.afterEach(async ({ page, ai, aiAssert }) => {
await page.goto(
`file://${path.join(__dirname, '../../../midscene_run/report/latest-playwright-report.html')}`,
);
const actionsList = await ai(
'Sidebar task list Array<{title: string, actions: Array<string>}>',
{
type: 'query',
},
);
const parseList = JSON.stringify(actionsList, null, 4);
expect(parseList).toMatchSnapshot();
await aiAssert(
'On the left taskbar, check whether the specific execution content of the right task is normal',
);
});

test('ai todo', async ({ ai, aiQuery, aiWaitFor }) => {
await ai(
'Enter "Learn JS today" in the task box, then press Enter to create',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"Sidebar task list": [
{
"title": "Enter \"Learn JS today\" in the task box, then press Enter to create",
"actions": [
"Planning",
"Insight / Locate",
"Action / Input",
"Action / KeyboardPress"
]
},
{
"title": "waitFor: the input box for task title is empty now",
"actions": [
"Insight / Assert"
]
},
{
"title": "Enter \"Learn Rust tomorrow\" in the task box, then press Enter to create",
"actions": [
"Planning",
"Insight / Locate",
"Action / Input",
"Action / KeyboardPress"
]
},
{
"title": "Enter \"Learning AI the day after tomorrow\" in the task box, then press Enter to create",
"actions": [
"Planning",
"Insight / Locate",
"Action / Input",
"Action / KeyboardPress"
]
}
]
}

0 comments on commit cb4cccb

Please sign in to comment.