Skip to content

Commit e9b33fa

Browse files
committed
fix(core): unit test
1 parent a3c7aff commit e9b33fa

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/web-integration/tests/unit-test/page-task-executor-rightclick.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PageTaskExecutor } from '@/common/tasks';
2-
import type { PlanningAction } from '@midscene/core';
2+
import type { DeviceAction, PlanningAction } from '@midscene/core';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

55
// Mock page with mouse operations
@@ -10,6 +10,22 @@ const mockPage = {
1010
},
1111
screenshotBase64: vi.fn().mockResolvedValue('mock-screenshot'),
1212
evaluateJavaScript: vi.fn(),
13+
actionSpace: () =>
14+
[
15+
{
16+
name: 'RightClick',
17+
call: (context, param) => {
18+
if (!context.element) {
19+
throw new Error('Element not found');
20+
}
21+
mockPage.mouse.click(
22+
context.element.center[0],
23+
context.element.center[1],
24+
{ button: 'right' },
25+
);
26+
},
27+
},
28+
] as DeviceAction[],
1329
} as any;
1430

1531
// Mock insight
@@ -165,8 +181,6 @@ describe('PageTaskExecutor RightClick Action', () => {
165181
};
166182

167183
// Should throw error when element is null
168-
await expect(rightClickTask.executor(null, mockContext)).rejects.toThrow(
169-
'Element not found, cannot right click',
170-
);
184+
await expect(rightClickTask.executor(null, mockContext)).rejects.toThrow();
171185
});
172186
});

0 commit comments

Comments
 (0)