Skip to content

Commit b106f55

Browse files
committed
chore: make tests os agnostic
1 parent 4aab4cb commit b106f55

28 files changed

+14795
-12586
lines changed

.github/workflows/tests.yml

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,45 @@
1-
name: Tests
21
on:
32
push:
4-
branches:
5-
- main
6-
- next
7-
- v1
3+
branches: [main, next, v1]
84
pull_request:
9-
branches:
10-
- main
11-
- next
12-
- v1
5+
branches: [main, next, v1]
136
jobs:
14-
unit:
15-
name: API Tests
16-
runs-on: ubuntu-latest
17-
steps:
18-
- name: Checkout repo
19-
uses: actions/checkout@v3
20-
- name: Setup node
21-
uses: actions/setup-node@v3
22-
with:
23-
node-version: 20
24-
- uses: pnpm/action-setup@v2
25-
with:
26-
version: 8
27-
- name: Download deps
28-
run: pnpm i
29-
- name: Build packages
30-
run: pnpm run build
31-
- name: Run tests
32-
run: pnpm exec vitest
33-
- name: Typecheck
34-
run: pnpm -r run typecheck
35-
367
e2e:
378
name: E2E Tests
9+
timeout-minutes: 60
3810
runs-on: ubuntu-latest
3911
steps:
40-
- name: Checkout repo
41-
uses: actions/checkout@v3
42-
- name: Setup node
43-
uses: actions/setup-node@v3
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
4414
with:
45-
node-version: 20
46-
- uses: pnpm/action-setup@v2
47-
with:
48-
version: 8
49-
- name: Download deps
15+
node-version: lts/*
16+
- name: Enable Corepack
17+
run: corepack enable
18+
- name: Install dependencies
5019
run: pnpm i
51-
- name: Install Playwright
20+
- name: Install Playwright Browsers
5221
run: pnpm exec playwright install --with-deps
53-
- name: Run tests
22+
- name: Run Playwright tests
5423
run: pnpm exec playwright test
55-
- name: Upload test result
56-
uses: actions/upload-artifact@v2
24+
- uses: actions/upload-artifact@v4
5725
if: always()
5826
with:
59-
name: test-results
60-
path: test-results/
27+
name: playwright-report
28+
path: playwright-report/
6129
retention-days: 30
30+
unit:
31+
name: API Tests
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: lts/*
38+
- name: Enable Corepack
39+
run: corepack enable
40+
- name: Install dependencies
41+
run: pnpm i
42+
- name: Run Vitest tests
43+
run: pnpm exec vitest
44+
- name: Run Typecheck
45+
run: pnpm -r run typecheck

.gitignore

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Logs
2-
logs
32
*.log
3+
logs
44
npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
@@ -9,20 +9,20 @@ yarn-error.log*
99
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1010

1111
# Runtime data
12-
pids
1312
*.pid
14-
*.seed
1513
*.pid.lock
14+
*.seed
15+
pids
1616

1717
# Build result
18-
/packages/*/*.js
1918
!/packages/*/rollup.config.js
19+
/packages/*/_virtual
2020
/packages/*/*.cjs
21-
/packages/*/*.mjs
2221
/packages/*/*.d.ts
23-
/packages/*/README
22+
/packages/*/*.js
23+
/packages/*/*.mjs
2424
/packages/*/LICENSE
25-
/packages/*/_virtual
25+
/packages/*/README
2626

2727
# Anything built
2828
build/
@@ -41,10 +41,9 @@ node_modules/
4141

4242
# Output of 'npm pack'
4343
*.tgz
44-
/test-results/
4544
/playwright-report/
4645
/playwright/.cache/
46+
/test-results/
4747

4848
# DS Store
4949
.DS_Store
50-
**/.DS_Store

tests/integrations/async-validation.spec.ts renamed to e2e/async-validation.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground, selectAll } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {
@@ -74,7 +74,7 @@ async function runTest(page: Page, javaScriptEnabled: boolean) {
7474
'Title is required',
7575
]);
7676

77-
await fieldset.email.press('Control+a');
77+
await selectAll(fieldset.email);
7878
await fieldset.email.press('ArrowRight');
7979
await fieldset.email.type('u');
8080
if (!javaScriptEnabled) {
@@ -86,7 +86,7 @@ async function runTest(page: Page, javaScriptEnabled: boolean) {
8686
'Title is required',
8787
]);
8888

89-
await fieldset.email.press('Control+a');
89+
await selectAll(fieldset.email);
9090
await fieldset.email.press('ArrowRight');
9191
await fieldset.email.type('i');
9292
if (!javaScriptEnabled) {
@@ -98,7 +98,7 @@ async function runTest(page: Page, javaScriptEnabled: boolean) {
9898
'Title is required',
9999
]);
100100

101-
await fieldset.email.press('Control+a');
101+
await selectAll(fieldset.email);
102102
await fieldset.email.press('ArrowRight');
103103
await fieldset.email.type('d');
104104
if (!javaScriptEnabled) {
@@ -117,7 +117,7 @@ async function runTest(page: Page, javaScriptEnabled: boolean) {
117117

118118
await expect(playground.error).toHaveText(['Email is already used', '']);
119119

120-
await fieldset.email.press('Control+a');
120+
await selectAll(fieldset.email);
121121
await fieldset.email.press('ArrowRight');
122122
await fieldset.email.type('e');
123123
await playground.submit.click();

tests/integrations/collection.spec.ts renamed to e2e/collection.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
async function runTest(
55
page: Page,

tests/integrations/conform-validitystate.spec.ts renamed to e2e/conform-validitystate.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
async function setupField(page: Page, constraint: object, secret?: any) {
55
const playground = getPlayground(page);

tests/integrations/custom-inputs.spec.ts renamed to e2e/custom-inputs.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
async function runTest(page: Page) {
55
const playground = getPlayground(page);

tests/integrations/dom-value.spec.ts renamed to e2e/dom-value.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/file-upload.spec.ts renamed to e2e/file-upload.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/form-attributes.spec.ts renamed to e2e/form-attributes.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/form-control.spec.ts renamed to e2e/form-control.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

e2e/helpers.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Locator, Page } from '@playwright/test';
2+
3+
export function getPlayground(page: Page) {
4+
const container = page.locator('body');
5+
const submission = container.locator('pre');
6+
7+
return {
8+
container,
9+
form: container.locator('form'),
10+
submit: container.locator('footer button[type="submit"]'),
11+
reset: container.locator('footer button[type="reset"]'),
12+
submission,
13+
result: () => submission.innerText().then(JSON.parse),
14+
error: container.locator('main p'),
15+
};
16+
}
17+
18+
export async function selectAll(locator: Locator) {
19+
switch (process.platform) {
20+
case 'darwin':
21+
await locator.press('Meta+a');
22+
break;
23+
default:
24+
await locator.press('Control+a');
25+
}
26+
}
27+
28+
export async function cut(locator: Locator) {
29+
switch (process.platform) {
30+
case 'darwin':
31+
await locator.press('Meta+x');
32+
break;
33+
default:
34+
await locator.press('Control+x');
35+
}
36+
}
37+
38+
export async function paste(locator: Locator) {
39+
switch (process.platform) {
40+
case 'darwin':
41+
await locator.press('Meta+v');
42+
break;
43+
default:
44+
await locator.press('Control+v');
45+
}
46+
}

tests/integrations/input-attributes.spec.ts renamed to e2e/input-attributes.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/input-event.spec.ts renamed to e2e/input-event.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Page, test, expect } from '@playwright/test';
2+
import { cut, paste, selectAll } from './helpers';
23

34
async function getForm(
45
page: Page,
@@ -125,7 +126,7 @@ test('works with keyboard events', async ({ page }) => {
125126
];
126127

127128
// Cut out 'c'
128-
await form.nativeInput.press('Control+x');
129+
await cut(form.nativeInput);
129130
await expect(form.nativeLogs).toHaveText(logs2);
130131
await expect(form.baseLogs).toHaveText(logs2);
131132

@@ -145,7 +146,7 @@ test('works with keyboard events', async ({ page }) => {
145146
];
146147

147148
// Paste the 'c' back
148-
await form.nativeInput.press('Control+v');
149+
await paste(form.nativeInput);
149150
await expect(form.nativeLogs).toHaveText(logs3);
150151
await expect(form.baseLogs).toHaveText(logs3);
151152

@@ -164,8 +165,7 @@ test('works with keyboard events', async ({ page }) => {
164165
createLog('change', 3),
165166
];
166167

167-
// Select all text
168-
await form.nativeInput.press('Control+a');
168+
await selectAll(form.nativeInput);
169169
await expect(form.nativeLogs).toHaveText(logs4);
170170
await expect(form.baseLogs).toHaveText(logs4);
171171

tests/integrations/metadata.spec.ts renamed to e2e/metadata.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
const list = form.locator('fieldset');

tests/integrations/nested-list.spec.ts renamed to e2e/nested-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/parse-with-yup.spec.ts renamed to e2e/parse-with-yup.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground, selectAll } from './helpers';
33

44
function getUsernameInput(container: Locator) {
55
return container.locator('[name="username"]');
@@ -22,7 +22,7 @@ async function runTest(page: Page) {
2222
'At least 1 number',
2323
]);
2424

25-
await username.press('Control+a');
25+
await selectAll(username);
2626
await username.press('ArrowRight');
2727
await username.type('C');
2828

@@ -33,7 +33,7 @@ async function runTest(page: Page) {
3333
'At least 1 number',
3434
]);
3535

36-
await username.press('Control+a');
36+
await selectAll(username);
3737
await username.press('ArrowRight');
3838
await username.type('on');
3939
await playground.submit.click();
@@ -42,13 +42,13 @@ async function runTest(page: Page) {
4242
'At least 1 number',
4343
]);
4444

45-
await username.press('Control+a');
45+
await selectAll(username);
4646
await username.press('ArrowRight');
4747
await username.type('form');
4848
await playground.submit.click();
4949
await expect(playground.error).toHaveText(['At least 1 number']);
5050

51-
await username.press('Control+a');
51+
await selectAll(username);
5252
await username.press('ArrowRight');
5353
await username.type('2023');
5454
await playground.submit.click();

tests/integrations/recursive-list.spec.ts renamed to e2e/recursive-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/reset-default-value.spec.ts renamed to e2e/reset-default-value.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

tests/integrations/simple-list.spec.ts renamed to e2e/simple-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Page, type Locator, test, expect } from '@playwright/test';
2-
import { getPlayground } from '../helpers';
2+
import { getPlayground } from './helpers';
33

44
function getFieldset(form: Locator) {
55
return {

0 commit comments

Comments
 (0)