forked from adazzle/react-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.workspace.ts
57 lines (54 loc) · 1.74 KB
/
vitest.workspace.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { defineWorkspace } from 'vitest/config';
import type { BrowserCommand } from 'vitest/node';
// TODO: remove when `userEvent.pointer` is supported
const resizeColumn: BrowserCommand<[resizeBy: number]> = async (context, resizeBy) => {
const page = context.page;
const frame = await context.frame();
const resizeHandle = frame.locator('[role="columnheader"][aria-colindex="2"] div');
const { x, y } = (await resizeHandle.boundingBox())!;
await resizeHandle.hover({
position: { x: 5, y: 5 }
});
await page.mouse.down();
await page.mouse.move(x + resizeBy + 5, y);
await page.mouse.up();
};
// TODO: remove when `userEvent.pointer` is supported
const dragFill: BrowserCommand<[from: string, to: string]> = async (context, from, to) => {
const page = context.page;
const frame = await context.frame();
await frame.getByRole('gridcell', { name: from }).click();
await frame.locator('.rdg-cell-drag-handle').hover();
await page.mouse.down();
const toCell = frame.getByRole('gridcell', { name: to });
await toCell.hover();
await page.mouse.up();
};
export default defineWorkspace([
{
extends: './vite.config.ts',
test: {
name: 'browser',
include: ['test/browser/**/*.test.*'],
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
commands: { resizeColumn, dragFill },
viewport: { width: 1920, height: 1080 },
headless: true,
screenshotFailures: process.env.CI !== 'true'
},
setupFiles: ['test/setup.ts', 'test/setupBrowser.ts']
}
},
{
extends: './vite.config.ts',
test: {
name: 'node',
include: ['test/node/**/*.test.*'],
environment: 'node',
setupFiles: ['test/setup.ts']
}
}
]);