Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow(ci): fix ai e2e test #94

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/midscene/src/ai-model/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ if (typeof process.env[MIDSCENE_MODEL_NAME] === 'string') {
async function createOpenAI() {
let openai: OpenAI | AzureOpenAI;
if (process.env[OPENAI_USE_AZURE]) {
console.log('Using Azure OpenAI');
openai = new AzureOpenAI(extraConfig);
} else {
openai = new OpenAI(extraConfig);
Expand Down
2 changes: 1 addition & 1 deletion packages/web-integration/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dotenv.config({
*/
export default defineConfig({
// testDir: './tests/ai/e2e',
// testIgnore: 'generate-test-data.spec.ts',
testIgnore: 'generate-test-data.spec.ts',
timeout: 900 * 1000,
/* Run tests in files in parallel */
fullyParallel: false,
Expand Down
9 changes: 9 additions & 0 deletions packages/web-integration/src/extractor/web-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ function collectElementInfo(
// Retrieve the text content of the selected option
valueContent = selectedOption.textContent || '';
}

if (
((node as HTMLElement).tagName.toLowerCase() === 'input' ||
(node as HTMLElement).tagName.toLowerCase() === 'textarea') &&
(node as HTMLInputElement).value
) {
valueContent = (node as HTMLInputElement).value;
}

const elementInfo: WebElementInfo = {
id: nodeHashId,
nodePath,
Expand Down
1 change: 0 additions & 1 deletion packages/web-integration/src/puppeteer/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export class Page<
});

let buf: Buffer;
console.log(viewportSize);
if (viewportSize.deviceScaleFactor > 1) {
buf = (await resizeImg(readFileSync(path), {
width: viewportSize.width,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[
{
"title": "Enter \"Learn\" in the task box",
"title": "Enter \"Learn\" in the task box, don't press enter",
"actions": [
"Planning",
"Insight / Locate",
"Action / Input"
]
},
{
"title": "Add \"JS today\" to the existing content of the task box and press enter",
"title": "Add \"JS today\" to base on the existing content(important) of the task box, then press enter",
"actions": [
"Planning",
"Insight / Locate",
Expand All @@ -28,10 +28,7 @@
{
"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"
"Planning"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ test('ai todo', async ({ ai, aiQuery }) => {
test.setTimeout(1000 * 30);
}

await ai('Enter "Learn" in the task box');
await ai('Enter "Learn" in the task box, don\'t press enter');

await ai(
'Add "JS today" to the existing content of the task box and press enter',
'Add "JS today" to base on the existing content(important) of the task box, then press enter',
);

await ai(
Expand All @@ -33,7 +34,7 @@ test('ai todo', async ({ ai, aiQuery }) => {
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');
await ai('Click the check button to the left of the second task');
await ai('Click the completed Status button below the task list');
await ai('Click the "completed" Status button below the task list');

const taskList = await aiQuery<string[]>('string[], tasks in the list');
expect(taskList.length).toBe(1);
Expand Down
Loading