Skip to content

Commit 5c23030

Browse files
NiloCKclaude
andcommitted
Add Cypress E2E test infrastructure for standalone-ui
- Create Cypress configuration with port 6173 - Set up basic test framework with support files - Add smoke test for standalone-ui - Create CI workflow for standalone-ui E2E tests - Add status badge to README 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3877816 commit 5c23030

File tree

7 files changed

+146
-2
lines changed

7 files changed

+146
-2
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Standalone UI E2E Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight
6+
workflow_dispatch: # Allow manual triggering
7+
push:
8+
paths:
9+
- '.github/workflows/standalone-e2e-tests.yml'
10+
- 'packages/standalone-ui/**'
11+
12+
jobs:
13+
e2e-tests:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
submodules: 'recursive' # Get submodule for couchdb snapshot
20+
21+
- name: Display submodule information
22+
run: |
23+
echo "Submodule information:"
24+
git submodule status
25+
echo "CouchDB snapshot details:"
26+
cd test-couch && git log -1 --pretty=format:'%h - %s (%cr) <%an>'
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: '18'
32+
cache: 'yarn'
33+
34+
- name: Setup Docker
35+
uses: docker/setup-buildx-action@v2
36+
37+
- name: Install dependencies
38+
run: yarn install
39+
40+
- name: Install Cypress
41+
run: yarn workspace @vue-skuilder/standalone-ui cypress install
42+
43+
- name: Build dependencies
44+
run: |
45+
yarn workspace @vue-skuilder/common build
46+
yarn workspace @vue-skuilder/db build
47+
yarn workspace @vue-skuilder/common-ui build
48+
yarn workspace @vue-skuilder/courses build
49+
50+
- name: Start CouchDB
51+
run: yarn couchdb:start
52+
53+
- name: Start standalone UI and wait for services
54+
run: |
55+
# Start the standalone-ui in background
56+
yarn workspace @vue-skuilder/standalone-ui dev &
57+
# Wait for the webserver to be ready
58+
npx wait-on http://localhost:6173
59+
# Wait for the database to be ready
60+
npx wait-on http://localhost:5984
61+
62+
- name: Run E2E tests
63+
run: yarn workspace @vue-skuilder/standalone-ui cypress run
64+
65+
- name: Cleanup services
66+
if: always()
67+
run: |
68+
# Clean up
69+
kill $(lsof -t -i:6173) || true
70+
yarn couchdb:stop
71+
72+
- name: Upload screenshots on failure
73+
uses: actions/upload-artifact@v4
74+
if: failure()
75+
with:
76+
name: cypress-screenshots
77+
path: packages/standalone-ui/cypress/screenshots
78+
retention-days: 7
79+
80+
- name: Upload videos
81+
uses: actions/upload-artifact@v4
82+
if: always()
83+
with:
84+
name: cypress-videos
85+
path: packages/standalone-ui/cypress/videos
86+
retention-days: 7
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { defineConfig } = require('cypress');
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:6173', // package/standalone-ui vite dev server port
6+
supportFile: 'cypress/support/e2e.js',
7+
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
8+
setupNodeEvents(on, config) {
9+
// implement node event listeners here
10+
},
11+
},
12+
// increase the default timeout for slower operations
13+
defaultCommandTimeout: 10000,
14+
// Viewport configuration
15+
viewportWidth: 1280,
16+
viewportHeight: 800,
17+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Basic smoke test for standalone-ui
2+
describe('Smoke Test', () => {
3+
it('should load the application', () => {
4+
cy.visit('/');
5+
6+
// Verify that the application loaded
7+
// Update selector as needed based on your actual UI
8+
cy.get('body').should('be.visible');
9+
});
10+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// standalone-ui/cypress/support/commands.js
2+
// Basic commands file - will be expanded with specific commands as needed
3+
4+
// Example of a custom command format:
5+
// Cypress.Commands.add('commandName', (param1, param2) => {
6+
// // Command implementation
7+
// });
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// standalone-ui/cypress/support/e2e.js
2+
// This is the main support file for Cypress E2E tests
3+
4+
// Import commands.js using ES2015 syntax:
5+
import './commands';
6+
7+
// Cypress exception handling
8+
Cypress.on('uncaught:exception', (err) => {
9+
// Log the error for debugging
10+
console.log('Uncaught exception:', err.message);
11+
12+
// If the error is from PouchDB, ignore it
13+
if (err.message.includes('not_found') || err.message.includes('missing')) {
14+
return false; // Prevents Cypress from failing the test
15+
}
16+
return true; // Otherwise, fail the test
17+
});

packages/standalone-ui/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vue-tsc --noEmit && vite build",
9-
"preview": "vite preview"
9+
"preview": "vite preview",
10+
"test:e2e": "cypress open",
11+
"test:e2e:headless": "cypress run",
12+
"ci:e2e": "vite dev & wait-on http://localhost:6173 && cypress run"
1013
},
1114
"dependencies": {
1215
"@mdi/font": "^7.3.67",
@@ -18,9 +21,12 @@
1821
"vuetify": "^3.7.0"
1922
},
2023
"devDependencies": {
24+
"@types/cypress": "1.1.6",
2125
"@vitejs/plugin-vue": "^5.2.1",
26+
"cypress": "14.1.0",
2227
"typescript": "^5.7.2",
2328
"vite": "^6.0.9",
24-
"vue-tsc": "^1.8.0"
29+
"vue-tsc": "^1.8.0",
30+
"wait-on": "8.0.2"
2531
}
2632
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
![`platform-ui` E2E](https://github.com/patched-network/vue-skuilder/actions/workflows/e2e-tests.yml/badge.svg)
2+
![`standalone-ui` E2E](https://github.com/patched-network/vue-skuilder/actions/workflows/standalone-e2e-tests.yml/badge.svg)
23

34
General tooling for interactive tutoring systems, with experimentation toward
45
- mass-collaborative authoring

0 commit comments

Comments
 (0)