-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): input supports additions, deletions, and changes (#78)
* feat(web): input supports additions, deletions, and changes * chore: optimize unit test content
- Loading branch information
Showing
39 changed files
with
1,034 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
packages/midscene/tests/ai/automation/__snapshots__/planning-input.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`automation - planning input - openAI > input value 1`] = ` | ||
[ | ||
{ | ||
"param": { | ||
"prompt": "", | ||
}, | ||
"thought": undefined, | ||
"type": "Locate", | ||
}, | ||
{ | ||
"param": null, | ||
"thought": undefined, | ||
"type": "Tap", | ||
}, | ||
{ | ||
"param": { | ||
"value": "learning english", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input - openAI > input value 2`] = ` | ||
[ | ||
{ | ||
"param": { | ||
"prompt": "", | ||
}, | ||
"thought": undefined, | ||
"type": "Locate", | ||
}, | ||
{ | ||
"param": { | ||
"value": "learning english", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
{ | ||
"param": { | ||
"value": "Enter", | ||
}, | ||
"thought": undefined, | ||
"type": "KeyboardPress", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input - openAI > input value Add, delete, correct and check 1`] = ` | ||
[ | ||
{ | ||
"param": { | ||
"prompt": "", | ||
}, | ||
"thought": undefined, | ||
"type": "Locate", | ||
}, | ||
{ | ||
"param": null, | ||
"thought": undefined, | ||
"type": "Tap", | ||
}, | ||
{ | ||
"param": { | ||
"value": "Learn English tomorrow", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input - openAI > input value Add, delete, correct and check 2`] = ` | ||
[ | ||
{ | ||
"param": { | ||
"prompt": "", | ||
}, | ||
"thought": undefined, | ||
"type": "Locate", | ||
}, | ||
{ | ||
"param": { | ||
"value": "Learn skiing", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input - openAI > input value Add, delete, correct and check 3`] = ` | ||
[ | ||
{ | ||
"param": { | ||
"prompt": "", | ||
}, | ||
"thought": undefined, | ||
"type": "Locate", | ||
}, | ||
{ | ||
"param": null, | ||
"thought": undefined, | ||
"type": "Tap", | ||
}, | ||
{ | ||
"param": { | ||
"value": "Learn ", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; |
44 changes: 44 additions & 0 deletions
44
packages/midscene/tests/ai/automation/planning-input.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { plan } from '@/ai-model'; | ||
import type { PlanningAction } from '@/types'; | ||
import { getPageDataOfTestName } from 'tests/ai/inspector/util'; | ||
/* eslint-disable max-lines-per-function */ | ||
import { describe, expect, it, vi } from 'vitest'; | ||
import { makePlanResultStable, modelList } from '../util'; | ||
|
||
vi.setConfig({ | ||
testTimeout: 180 * 1000, | ||
hookTimeout: 30 * 1000, | ||
}); | ||
|
||
modelList.forEach((model) => { | ||
describe(`automation - planning input - ${model}`, () => { | ||
it('input value', async () => { | ||
const { context } = await getPageDataOfTestName('todo'); | ||
const instructions = [ | ||
'In the taskbar, type learning english', | ||
'In the taskbar, type learning english and hit Enter', | ||
]; | ||
|
||
for (const instruction of instructions) { | ||
const { plans } = await plan(instruction, { context }, model); | ||
const res = makePlanResultStable(plans); | ||
expect(res).toMatchSnapshot(); | ||
} | ||
}); | ||
|
||
it('input value Add, delete, correct and check', async () => { | ||
const { context } = await getPageDataOfTestName('todo-input-with-value'); | ||
const instructions = [ | ||
'Append "tomorrow" to the existing content in the task input box', | ||
'Replace "English" with "skiing" in the existing content of the task input box', | ||
'Delete "English" from the existing content in the task input box', | ||
]; | ||
|
||
for (const instruction of instructions) { | ||
const { plans } = await plan(instruction, { context }, model); | ||
const res = makePlanResultStable(plans); | ||
expect(res).toMatchSnapshot(); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.