Skip to content

Commit 25128fa

Browse files
authored
chore: optimize e2e test (#364)
1 parent c502806 commit 25128fa

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

packages/midscene/tests/ai/evaluate/ai-data/assertion/online_order.json

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"testDataPath": "test-data/online_order",
33
"testCases": [
4-
{
5-
"prompt": "the 'select option' button background color is yellow",
6-
"expected": true
7-
},
84
{
95
"prompt": "there are three tabs in the page, named 'Menu', 'Reviews', 'Merchant'",
106
"expected": true

packages/midscene/tests/ai/evaluate/inspect.test.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ describe('ai inspect element', () => {
8989
},
9090
);
9191

92-
console.log('planning res', res);
9392
prompt = res.actions[0].locate?.prompt as string;
9493
console.log('prompt from planning', prompt);
9594
expect(prompt).toBeTruthy();
@@ -98,8 +97,15 @@ describe('ai inspect element', () => {
9897
if (!relocateAfterPlanning) {
9998
const matchedId = res.actions[0].locate?.id;
10099
if (matchedId) {
100+
const element = elementById(matchedId);
101101
return {
102-
elements: [elementById(matchedId)],
102+
elements: [
103+
{
104+
id: element.id,
105+
reason: element.reason ?? '',
106+
text: element.content ?? '',
107+
},
108+
],
103109
};
104110
}
105111

@@ -117,7 +123,13 @@ describe('ai inspect element', () => {
117123
return {
118124
...parseResult,
119125
elements: parseResult.elements.length
120-
? [parseResult.elements[0]]
126+
? [
127+
{
128+
...parseResult.elements[0],
129+
reason: parseResult.elements[0].reason ?? '',
130+
text: parseResult.elements[0].text ?? '',
131+
},
132+
]
121133
: [],
122134
};
123135
},

packages/midscene/tests/ai/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { PlanningAction } from '@/types';
22

3-
export const repeatTime = 2;
3+
export const repeatTime = 1;
44
export function makePlanResultStable(plans: PlanningAction[]) {
55
return plans.map((plan) => {
66
// Removing thinking makes the results stable for snapshot testing

0 commit comments

Comments
 (0)