Skip to content

Commit 0b550fb

Browse files
authored
feat(ci): run demo tests against local workspace code (#2481)
* feat(ci): run demo tests against local workspace code Mirrors the examples approach: - Add pnpm overrides for superdoc and @superdoc-dev/react so demos resolve from local workspace instead of npm - Add demos/* and demos/*/* to pnpm workspace - Rewrite ci-demos workflow: shared build job with pnpm workspace install, expanded path triggers (packages/superdoc, super-editor, layout-engine, react), Playwright browser cache - Increase smoke test timeouts for SPA hydration and dev server startup * fix(ci): trigger demos CI on root config file changes Changes to package.json, pnpm-lock.yaml, or pnpm-workspace.yaml affect workspace resolution and can break demo installs. * fix(demos): add missing prosemirror-state dependency to toolbar demo The toolbar demo imports prosemirror-state directly but never declared it. Worked with npm's flat hoisting but fails with pnpm's strict module resolution.
1 parent fc59604 commit 0b550fb

5 files changed

Lines changed: 73 additions & 21 deletions

File tree

.github/workflows/ci-demos.yml

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,50 @@ on:
44
pull_request:
55
paths:
66
- 'demos/**'
7+
- 'packages/superdoc/**'
8+
- 'packages/react/**'
9+
- 'packages/super-editor/**'
10+
- 'packages/layout-engine/**'
11+
- 'shared/**'
12+
- 'package.json'
13+
- 'pnpm-lock.yaml'
14+
- 'pnpm-workspace.yaml'
715
workflow_dispatch:
816

917
jobs:
10-
validate:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- uses: pnpm/action-setup@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: '20'
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Build superdoc
35+
run: pnpm build:superdoc
36+
37+
- name: Install Playwright
38+
working-directory: demos/__tests__
39+
run: npx playwright install chromium
40+
41+
- name: Cache workspace
42+
uses: actions/cache/save@v4
43+
with:
44+
path: |
45+
.
46+
~/.cache/ms-playwright
47+
key: demos-workspace-${{ github.sha }}
48+
49+
smoke-test:
50+
needs: build
1151
runs-on: ubuntu-latest
1252
strategy:
1353
fail-fast: false
@@ -32,21 +72,25 @@ jobs:
3272
- vanilla
3373
- vue
3474
steps:
35-
- uses: actions/checkout@v6
36-
37-
- name: Setup Node.js
38-
uses: actions/setup-node@v6
75+
- name: Restore workspace
76+
uses: actions/cache/restore@v4
3977
with:
40-
node-version: '20'
41-
42-
- name: Install demo dependencies
43-
working-directory: demos/${{ matrix.demo }}
44-
run: npm install
45-
46-
- name: Install smoke test dependencies
47-
working-directory: demos/__tests__
48-
run: npm install && npx playwright install chromium
78+
path: |
79+
.
80+
~/.cache/ms-playwright
81+
key: demos-workspace-${{ github.sha }}
4982

5083
- name: Run smoke test
5184
working-directory: demos/__tests__
5285
run: DEMO=${{ matrix.demo }} npx playwright test
86+
87+
validate:
88+
if: always()
89+
needs: [smoke-test]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Check results
93+
run: |
94+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
95+
exit 1
96+
fi

demos/__tests__/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default defineConfig({
3434
webServer: {
3535
command,
3636
url: `http://localhost:${port}`,
37-
timeout: 30_000,
37+
timeout: 120_000,
3838
reuseExistingServer: !process.env.CI,
3939
},
4040
use: {

demos/__tests__/smoke.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ test('demo loads without errors', async ({ page }) => {
1515
);
1616

1717
await page.goto('/');
18-
await expect(page.locator('body')).toBeVisible();
18+
// SPA frameworks (e.g. Next.js) may hide the body during hydration;
19+
// give them enough time to mount before checking visibility.
20+
await expect(page.locator('body')).toBeVisible({ timeout: 30_000 });
1921

2022
// Give the app a moment to initialize (SuperDoc is async)
2123
await page.waitForTimeout(2000);

demos/toolbar/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dev": "vite"
88
},
99
"dependencies": {
10+
"prosemirror-state": "^1.4.3",
1011
"superdoc": "latest"
1112
},
1213
"devDependencies": {

pnpm-lock.yaml

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)