Skip to content

Commit a252f99

Browse files
committed
add docs datalayer sanity check to CI...
1 parent 392a518 commit a252f99

File tree

6 files changed

+423
-9
lines changed

6 files changed

+423
-9
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,37 @@ jobs:
4747
run: yarn build:lib
4848
- name: Build with VitePress
4949
run: yarn docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
50-
- name: Upload artifact
51-
uses: actions/upload-pages-artifact@v3
52-
with:
53-
path: docs/.vitepress/dist
54-
50+
51+
# Test Job
52+
test:
53+
name: Test
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
- name: Setup Node
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: 22
62+
cache: yarn
63+
- name: Install dependencies
64+
run: yarn install
65+
- name: Build skuilder libraries
66+
run: yarn build:lib
67+
- name: Start dev server and run tests
68+
run: |
69+
yarn docs:dev &
70+
SERVER_PID=$!
71+
npx wait-on http://localhost:5173/vue-skuilder
72+
yarn docs:test
73+
kill $SERVER_PID
74+
5575
# Deployment job
5676
deploy:
5777
environment:
5878
name: github-pages
5979
url: ${{ steps.deployment.outputs.page_url }}
60-
needs: build
80+
needs: [build, test]
6181
runs-on: ubuntu-latest
6282
name: Deploy
6383
steps:

cypress.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:5173',
6+
supportFile: false,
7+
specPattern: 'docs/test/**/*.cy.{js,jsx,ts,tsx}',
8+
video: false,
9+
screenshotOnRunFailure: true,
10+
},
11+
});

docs/test/embedded-course.cy.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* Smoke test for docs site embedded course functionality
3+
*
4+
* Ensures that:
5+
* - The embedded course loads without "not found" errors
6+
* - The data layer initializes correctly
7+
* - Study sessions can be started
8+
* - Cards load successfully
9+
*/
10+
11+
describe('Docs Site - Embedded Course', () => {
12+
beforeEach(() => {
13+
// Visit the embedded course test page
14+
cy.visit('/vue-skuilder/dbg/embedded-course-test.html');
15+
});
16+
17+
it('should load the embedded course without "not found" errors', () => {
18+
// Capture console errors
19+
const consoleErrors: string[] = [];
20+
21+
cy.window().then((win) => {
22+
cy.stub(win.console, 'error').callsFake((...args) => {
23+
const message = args.join(' ');
24+
consoleErrors.push(message);
25+
});
26+
});
27+
28+
// Wait for the data layer to initialize
29+
cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible');
30+
31+
// Check for "not found" errors in console
32+
cy.window().then(() => {
33+
const notFoundErrors = consoleErrors.filter(msg =>
34+
msg.toLowerCase().includes('not found')
35+
);
36+
37+
if (notFoundErrors.length > 0) {
38+
throw new Error(`Found "not found" errors in console:\n${notFoundErrors.join('\n')}`);
39+
}
40+
});
41+
});
42+
43+
it('should start a study session and load cards without errors', () => {
44+
// Capture console errors
45+
const consoleErrors: string[] = [];
46+
47+
cy.window().then((win) => {
48+
cy.stub(win.console, 'error').callsFake((...args) => {
49+
const message = args.join(' ');
50+
consoleErrors.push(message);
51+
});
52+
});
53+
54+
// Wait for initialization
55+
cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible');
56+
57+
// Wait for the "Start Session" button to appear and click it
58+
cy.contains('button', 'Start Session', { timeout: 10000 })
59+
.should('be.visible')
60+
.click();
61+
62+
// Wait for the init state to disappear (button should be gone)
63+
cy.contains('button', 'Start Session').should('not.exist');
64+
65+
// Verify we're not in loading state
66+
cy.contains('Loading course').should('not.exist');
67+
68+
// Give it a moment for card hydration
69+
cy.wait(2000);
70+
71+
// Check for "not found" errors in console after session start
72+
cy.window().then(() => {
73+
const notFoundErrors = consoleErrors.filter(msg =>
74+
msg.toLowerCase().includes('not found')
75+
);
76+
77+
if (notFoundErrors.length > 0) {
78+
throw new Error(`Found "not found" errors in console after session start:\n${notFoundErrors.join('\n')}`);
79+
}
80+
});
81+
82+
// Verify no error state is shown
83+
cy.contains('Initialization failed').should('not.exist');
84+
cy.contains('Error:').should('not.exist');
85+
});
86+
87+
it('should load the remote course test page', () => {
88+
// Test the remote course embedding as well
89+
cy.visit('/vue-skuilder/dbg/remote-crs-embedding.html');
90+
91+
const consoleErrors: string[] = [];
92+
93+
cy.window().then((win) => {
94+
cy.stub(win.console, 'error').callsFake((...args) => {
95+
const message = args.join(' ');
96+
consoleErrors.push(message);
97+
});
98+
});
99+
100+
// Wait for initialization
101+
cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible');
102+
103+
// Check for "not found" errors
104+
cy.window().then(() => {
105+
const notFoundErrors = consoleErrors.filter(msg =>
106+
msg.toLowerCase().includes('not found')
107+
);
108+
109+
if (notFoundErrors.length > 0) {
110+
throw new Error(`Found "not found" errors in remote course test:\n${notFoundErrors.join('\n')}`);
111+
}
112+
});
113+
});
114+
});

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"vtag": "node scripts/vtag.js",
2727
"docs:dev": "vitepress dev docs",
2828
"docs:build": "vitepress build docs",
29-
"docs:preview": "vitepress preview docs"
29+
"docs:preview": "vitepress preview docs",
30+
"docs:test": "cypress run",
31+
"docs:test:open": "cypress open"
3032
},
3133
"private": true,
3234
"workspaces": [
@@ -39,6 +41,7 @@
3941
"@typescript-eslint/parser": "^8.25.0",
4042
"canvas": "^3.2.0",
4143
"concurrently": "^9.1.2",
44+
"cypress": "^15.6.0",
4245
"eslint": "^9.21.0",
4346
"eslint-config-prettier": "^10.0.2",
4447
"eslint-plugin-vue": "^9.32.0",
@@ -49,6 +52,7 @@
4952
"vitepress": "^2.0.0-alpha.12",
5053
"vitepress-plugin-llms": "^1.7.5",
5154
"vue": "^3.5.13",
52-
"vuetify": "^3.7.0"
55+
"vuetify": "^3.7.0",
56+
"wait-on": "^8.0.1"
5357
}
5458
}

tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"target": "ES2022",
5+
"lib": ["ES2022", "DOM"],
6+
"module": "ESNext",
7+
"moduleResolution": "node",
8+
"types": ["cypress", "node"],
9+
"esModuleInterop": true,
10+
"skipLibCheck": true
11+
},
12+
"include": [
13+
"docs/test/**/*.ts",
14+
"cypress/**/*.ts"
15+
]
16+
}

0 commit comments

Comments
 (0)