Skip to content

Commit 8a3a717

Browse files
committed
fix: prepublish protection script removed (migrated to trusted publisher on the npm side)
ci: playwright cache step added test: timeout increased for the slow github action
1 parent 1f7c7a7 commit 8a3a717

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

.github/workflows/publish.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
id-token: write
10+
contents: read
1011

1112
jobs:
1213
publish:
@@ -18,14 +19,34 @@ jobs:
1819
node-version: '20.x'
1920
registry-url: 'https://registry.npmjs.org'
2021

22+
- name: Update npm
23+
run: npm install -g npm@latest
24+
2125
- name: Install dependencies
2226
run: npm ci
2327

28+
- name: Get installed Playwright version
29+
id: playwright-version
30+
run: echo "version=$(npm ls @playwright/test --json | jq -r '.dependencies["@playwright/test"].version')" >> $GITHUB_OUTPUT
31+
32+
- name: Cache Playwright browsers
33+
uses: actions/cache@v4
34+
id: playwright-cache
35+
with:
36+
path: '~/.cache/ms-playwright'
37+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
38+
restore-keys: |
39+
${{ runner.os }}-playwright-
40+
2441
- name: Install Playwright browsers
42+
if: steps.playwright-cache.outputs.cache-hit != 'true'
2543
run: npx playwright install --with-deps
2644

45+
- name: Run Playwright tests
46+
run: npm run test
47+
2748
- name: Build
2849
run: npm run build
2950

3051
- name: Publish
31-
run: npm publish --access public
52+
run: npm publish

e2e/rowspan.spec.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect, test } from '@playwright/test';
22

33
test('rowspan', async ({ page }, testInfo) => {
4-
testInfo?.setTimeout(2000);
5-
page.setDefaultNavigationTimeout(1000);
6-
page.setDefaultTimeout(100);
4+
testInfo?.setTimeout(10000);
5+
page.setDefaultNavigationTimeout(5000);
6+
page.setDefaultTimeout(1000);
77

88
await page.goto('/');
99

@@ -25,24 +25,28 @@ test('rowspan', async ({ page }, testInfo) => {
2525
},
2626
};
2727

28-
for (const [
29-
selector,
30-
validator,
31-
] of Object.entries(cases)) {
32-
const elements = await page.locator(selector).filter({ visible: true }).all();
28+
for (const [selector, validator] of Object.entries(cases)) {
29+
const elements = await page
30+
.locator(selector)
31+
.filter({ visible: true })
32+
.all();
3333
for await (const el of elements) {
3434
const box = await el.boundingBox();
3535
const targetHeight = validator.height;
3636
const actualHeight = box?.height;
3737
const heightError =
38-
targetHeight != null && actualHeight != null && Math.abs(targetHeight - actualHeight) > 10
38+
targetHeight != null &&
39+
actualHeight != null &&
40+
Math.abs(targetHeight - actualHeight) > 10
3941
? `Bad height: expected around ${targetHeight}px, actual ${actualHeight}px`
4042
: undefined;
4143

4244
const targetTop = validator.top;
4345
const actualTop = box?.y;
4446
const topError =
45-
targetTop != null && actualTop != null && Math.abs(targetTop - actualTop) > 10
47+
targetTop != null &&
48+
actualTop != null &&
49+
Math.abs(targetTop - actualTop) > 10
4650
? `Bad top position: expected around ${targetTop}px, actual ${actualTop}px`
4751
: undefined;
4852

e2e/utils.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { Locator, Page, TestInfo } from '@playwright/test';
1+
import type { Locator, Page, TestInfo } from '@playwright/test';
22

33
interface TestScenario {
44
url: string;
55
rules: Record<string, (locator: Locator) => Promise<void>>;
66
}
77

8-
export async function testTheScenario(scenario: TestScenario, page: Page, testInfo?: TestInfo) {
9-
testInfo?.setTimeout(2000);
8+
export async function testTheScenario(
9+
scenario: TestScenario,
10+
page: Page,
11+
testInfo?: TestInfo,
12+
) {
13+
testInfo?.setTimeout(10000);
1014
page.setDefaultNavigationTimeout(1000);
1115
page.setDefaultTimeout(100);
1216

1317
await page.goto(scenario.url);
1418

15-
for (const [
16-
selector,
17-
validator,
18-
] of Object.entries(scenario.rules)) {
19+
for (const [selector, validator] of Object.entries(scenario.rules)) {
1920
await validator(page.locator(selector));
2021
}
2122
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"dist"
1919
],
2020
"scripts": {
21-
"prepublishOnly": "npm run lint && npm run test && npm run build && git diff --exit-code --quiet || { echo \"Git working directory is not clean. Please commit or stash your changes.\"; exit 1; }",
2221
"build": "tsup src/index.ts --format cjs,esm --dts --minify --clean",
2322
"lint": "biome lint ./src",
2423
"format": "biome format --write ./src",

0 commit comments

Comments
 (0)