Skip to content

Commit 1906664

Browse files
authored
test: Fix updating snapshots (#1469)
* test: attempt at getting test snapshots updated * build: run tests in docker image * chore: add some base deps to compile canvas dep * test: non-interactive mode * build: as root * build: update before * build: tests from the right dir * test: run playwright & server at the same time * build: fix directory * build: use env var * chore: chill the output * build: move relative CI build into build workflow * revert: "build: move relative CI build into build workflow" This reverts commit bcabb7c.
1 parent 16ff4f8 commit 1906664

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

.github/workflows/build.yml

+25-28
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ jobs:
3030
${{ runner.os }}-build-
3131
${{ runner.os }}-
3232
33-
- name: cache playwright
34-
id: playwright-cache
35-
uses: actions/cache@v4
36-
with:
37-
path: ~/.cache/ms-playwright
38-
key: pw-new-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
39-
4033
- name: Install Dependencies
4134
run: npm install
4235

@@ -45,40 +38,44 @@ jobs:
4538

4639
- name: Lint packages
4740
run: npm run lint
48-
env:
49-
CI: true
5041

5142
- name: Build packages
5243
run: npm run build
53-
env:
54-
CI: true
5544

5645
- name: Run unit tests
5746
run: npm run test
58-
env:
59-
CI: true
6047

61-
- name: Run server
62-
run: npm run start:built & npx wait-on http://localhost:3000
63-
env:
64-
CI: true
48+
- name: Upload webpack stats artifact (editor)
49+
uses: relative-ci/agent-upload-artifact-action@v2
50+
with:
51+
webpackStatsFile: ./playground/dist/webpack-stats.json
52+
artifactName: relative-ci-artifacts-editor
53+
playwright:
54+
name: "Playwright Tests"
55+
runs-on: ubuntu-latest
56+
container:
57+
image: mcr.microsoft.com/playwright:v1.49.1-noble
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: lts/*
63+
- run: apt-get update && apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
64+
- name: Install dependencies
65+
run: npm ci
6566

66-
- name: Install Playwright
67-
run: npm run install-playwright
67+
- name: Build packages
68+
run: npm run build
6869

69-
- name: Run Playwright tests
70-
working-directory: ./tests
71-
run: npx playwright test
70+
- name: Run server and Playwright tests
71+
run: |
72+
npm run start:built > /dev/null &
73+
npx wait-on http://localhost:3000
74+
cd tests && HOME=/root npx playwright test
7275
7376
- uses: actions/upload-artifact@v4
7477
if: always()
7578
with:
7679
name: playwright-report
7780
path: tests/playwright-report/
7881
retention-days: 30
79-
80-
- name: Upload webpack stats artifact (editor)
81-
uses: relative-ci/agent-upload-artifact-action@v2
82-
with:
83-
webpackStatsFile: ./playground/dist/webpack-stats.json
84-
artifactName: relative-ci-artifacts-editor

tests/playwright.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const config: PlaywrightTestConfig = {
2323
},
2424
/* Fail the build on CI if you accidentally left test.only in the source code. */
2525
forbidOnly: !!process.env.CI,
26-
/* Retry on CI only */
27-
retries: process.env.CI ? 2 : 0,
26+
retries: 2,
2827
/* Opt out of parallel tests on CI. */
2928
workers: process.env.CI ? 1 : undefined,
3029
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
Loading

tests/src/end-to-end/draghandle/draghandle.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ test.describe("Check Draghandle functionality", () => {
5454
const h2y = await getDragHandleYCoord(page, H_TWO_BLOCK_SELECTOR);
5555
const h3y = await getDragHandleYCoord(page, H_THREE_BLOCK_SELECTOR);
5656

57-
expect(h1y < h2y && h1y < h3y && h2y < h3y).toBeTruthy();
57+
expect(h1y < h2y).toBeTruthy();
58+
expect(h2y < h3y).toBeTruthy();
5859
});
5960

6061
test("Draghandle should display next to correct nested block", async () => {
@@ -69,7 +70,8 @@ test.describe("Check Draghandle functionality", () => {
6970
const h2y = await getDragHandleYCoord(page, H_TWO_BLOCK_SELECTOR);
7071
const h3y = await getDragHandleYCoord(page, H_THREE_BLOCK_SELECTOR);
7172

72-
expect(h1y < h2y && h1y < h3y && h2y < h3y).toBeTruthy();
73+
expect(h1y < h2y).toBeTruthy();
74+
expect(h2y < h3y).toBeTruthy();
7375
});
7476

7577
test("Clicking draghandle should open menu", async () => {
Loading
Loading

tests/src/utils/mouse.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ async function getElementCenterCoords(_page: Page, element: Locator) {
2525

2626
export async function moveMouseOverElement(page: Page, element: Locator) {
2727
const boundingBox = (await element.boundingBox())!;
28-
const coords = { x: boundingBox.x + 1, y: boundingBox.y + 1 };
28+
const coords = {
29+
x: boundingBox.x + boundingBox.width / 2,
30+
y: boundingBox.y + boundingBox.height / 2,
31+
};
2932
await page.mouse.move(coords.x, coords.y, { steps: 5 });
3033
}
3134

0 commit comments

Comments
 (0)