2024-07-25 10:47:02 +08:00
|
|
|
import { expect } from 'playwright/test';
|
2024-07-23 16:25:11 +08:00
|
|
|
import { test } from './fixture';
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
await page.goto('https://todomvc.com/examples/react/dist/');
|
|
|
|
});
|
|
|
|
|
2024-08-23 08:28:25 +08:00
|
|
|
const CACHE_TIME_OUT =
|
|
|
|
Boolean(process.env.MIDSCENE_CACHE) && Boolean(process.env.GITHUB_ACTIONS);
|
|
|
|
|
2024-08-21 14:43:35 +08:00
|
|
|
test('ai todo', async ({ ai, aiQuery, aiWaitFor }) => {
|
2024-08-23 08:28:25 +08:00
|
|
|
if (CACHE_TIME_OUT) {
|
|
|
|
test.setTimeout(1000 * 30);
|
|
|
|
}
|
|
|
|
|
2024-08-28 19:31:59 +08:00
|
|
|
await ai('Enter "Learn" in the task box');
|
2024-08-04 08:28:19 +08:00
|
|
|
await ai(
|
2024-08-28 19:31:59 +08:00
|
|
|
'Add "JS today" to the existing content of the task box and press enter',
|
2024-08-04 08:28:19 +08:00
|
|
|
);
|
2024-08-10 07:57:15 +08:00
|
|
|
|
2024-08-21 14:43:35 +08:00
|
|
|
await aiWaitFor('the input box for task title is empty now');
|
|
|
|
|
2024-08-04 08:28:19 +08:00
|
|
|
await ai(
|
|
|
|
'Enter "Learn Rust tomorrow" in the task box, then press Enter to create',
|
|
|
|
);
|
|
|
|
await ai(
|
|
|
|
'Enter "Learning AI the day after tomorrow" in the task box, then press Enter to create',
|
|
|
|
);
|
2024-08-28 19:31:59 +08:00
|
|
|
|
|
|
|
const allTaskList = await aiQuery<string[]>('string[], tasks in the list');
|
|
|
|
expect(allTaskList.length).toBe(3);
|
|
|
|
expect(allTaskList).toContain('Learn JS today');
|
|
|
|
expect(allTaskList).toContain('Learn Rust tomorrow');
|
|
|
|
expect(allTaskList).toContain('Learning AI the day after tomorrow');
|
|
|
|
|
2024-08-15 17:59:43 +08:00
|
|
|
await ai('Move your mouse over the second item in the task list');
|
|
|
|
await ai('Click the delete button to the right of the second task');
|
2024-07-23 16:25:11 +08:00
|
|
|
await ai('Click the check button to the left of the second task');
|
|
|
|
await ai('Click the completed Status button below the task list');
|
2024-07-25 10:47:02 +08:00
|
|
|
|
|
|
|
const taskList = await aiQuery<string[]>('string[], tasks in the list');
|
|
|
|
expect(taskList.length).toBe(1);
|
|
|
|
expect(taskList[0]).toBe('Learning AI the day after tomorrow');
|
|
|
|
|
2024-08-04 08:28:19 +08:00
|
|
|
const placeholder = await ai(
|
|
|
|
'string, return the placeholder text in the input box',
|
|
|
|
{ type: 'query' },
|
|
|
|
);
|
2024-07-25 10:47:02 +08:00
|
|
|
expect(placeholder).toBe('What needs to be done?');
|
2024-07-23 16:25:11 +08:00
|
|
|
});
|