Skip to content

Commit 7fd9e79

Browse files
committed
feat(auth): implement comprehensive E2E tests for authentication flow and protected features, including session management and API mocking
1 parent 6dc7f11 commit 7fd9e79

19 files changed

+846
-221
lines changed

.github/workflows/client-cypress-tests.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7373
CI: true
7474

75-
# E2E tests (needs server)
75+
# E2E tests (needs server, no auth)
7676
cypress-e2e:
7777
runs-on: ubuntu-latest
7878
strategy:
@@ -109,36 +109,98 @@ jobs:
109109
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env
110110
echo "LOG_LEVEL=info" >> .env
111111
112-
- name: Run E2E tests with server
112+
- name: Run E2E tests with server (no auth)
113113
working-directory: packages/client
114114
run: |
115-
chmod +x scripts/test-e2e-with-server.sh
116-
./scripts/test-e2e-with-server.sh
115+
chmod +x scripts/test-e2e-server.sh
116+
./scripts/test-e2e-server.sh
117+
env:
118+
SERVER_PORT: 3000
119+
CLIENT_PORT: 5173
120+
121+
# E2E tests with authentication enabled
122+
cypress-e2e-auth:
123+
runs-on: ubuntu-latest
124+
services:
125+
postgres:
126+
image: pgvector/pgvector:pg16
127+
env:
128+
POSTGRES_USER: eliza_test
129+
POSTGRES_PASSWORD: eliza_test_password
130+
POSTGRES_DB: eliza_test
131+
ports:
132+
- 5433:5432
133+
options: >-
134+
--health-cmd pg_isready
135+
--health-interval 10s
136+
--health-timeout 5s
137+
--health-retries 5
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
containers: [1]
142+
steps:
143+
- name: Checkout code
144+
uses: actions/checkout@v4
145+
146+
- name: Set up Node.js
147+
uses: actions/setup-node@v4
148+
with:
149+
node-version: 23
150+
151+
- name: Set up Bun
152+
uses: oven-sh/setup-bun@v2
153+
with:
154+
bun-version: 1.2.21
155+
156+
- name: Install dependencies
157+
run: bun install
158+
159+
- name: Build packages (Turbo cached)
160+
run: bun run build
161+
162+
- name: Install Cypress binary
163+
working-directory: packages/client
164+
run: bunx cypress install
165+
166+
- name: Create .env file
167+
run: |
168+
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env
169+
echo "LOG_LEVEL=info" >> .env
170+
171+
- name: Run E2E tests with authentication
172+
working-directory: packages/client
173+
run: |
174+
chmod +x scripts/test-e2e-server-auth.sh
175+
./scripts/test-e2e-server-auth.sh
117176
env:
118177
SERVER_PORT: 3000
119178
CLIENT_PORT: 5173
120179

121180
# Summary job
122181
cypress-tests-summary:
123-
needs: [cypress-component, cypress-e2e]
182+
needs: [cypress-component, cypress-e2e, cypress-e2e-auth]
124183
runs-on: ubuntu-latest
125184
if: always()
126185
steps:
127186
- name: Check test results
128187
run: |
129188
component_result="${{ needs.cypress-component.result }}"
130189
e2e_result="${{ needs.cypress-e2e.result }}"
190+
e2e_auth_result="${{ needs.cypress-e2e-auth.result }}"
131191
132-
if [[ "$component_result" == "failure" || "$e2e_result" == "failure" ]]; then
192+
if [[ "$component_result" == "failure" || "$e2e_result" == "failure" || "$e2e_auth_result" == "failure" ]]; then
133193
echo "❌ Cypress tests failed"
134194
echo "Component tests: $component_result"
135-
echo "E2E tests: $e2e_result"
195+
echo "E2E tests (no auth): $e2e_result"
196+
echo "E2E tests (with auth): $e2e_auth_result"
136197
exit 1
137-
elif [[ "$component_result" == "cancelled" || "$e2e_result" == "cancelled" ]]; then
198+
elif [[ "$component_result" == "cancelled" || "$e2e_result" == "cancelled" || "$e2e_auth_result" == "cancelled" ]]; then
138199
echo "⏹️ Cypress tests were cancelled"
139200
exit 1
140201
else
141202
echo "✅ All Cypress tests passed"
142203
echo "Component tests: $component_result"
143-
echo "E2E tests: $e2e_result"
204+
echo "E2E tests (no auth): $e2e_result"
205+
echo "E2E tests (with auth): $e2e_auth_result"
144206
fi

bun.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4711,7 +4711,7 @@
47114711

47124712
"npm-run-path/path-key": ["[email protected]", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="],
47134713

4714-
"nx/chalk": ["[email protected].2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
4714+
"nx/chalk": ["[email protected].0", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A=="],
47154715

47164716
"nx/cli-cursor": ["[email protected]", "", { "dependencies": { "restore-cursor": "^3.1.0" } }, "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw=="],
47174717

@@ -4859,6 +4859,8 @@
48594859

48604860
"tsup/source-map": ["[email protected]", "", { "dependencies": { "whatwg-url": "^7.0.0" } }, "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA=="],
48614861

4862+
"tsup/tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
4863+
48624864
"tuf-js/make-fetch-happen": ["[email protected]", "", { "dependencies": { "@npmcli/agent": "^3.0.0", "cacache": "^19.0.1", "http-cache-semantics": "^4.1.1", "minipass": "^7.0.2", "minipass-fetch": "^4.0.0", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "negotiator": "^1.0.0", "proc-log": "^5.0.0", "promise-retry": "^2.0.1", "ssri": "^12.0.0" } }, "sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ=="],
48634865

48644866
"type-is/mime-types": ["[email protected]", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="],
@@ -5431,6 +5433,8 @@
54315433

54325434
"normalize-package-data/hosted-git-info/lru-cache/yallist": ["[email protected]", "", {}, "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="],
54335435

5436+
"nx/ora/log-symbols/chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
5437+
54345438
"nx/ora/log-symbols/is-unicode-supported": ["[email protected]", "", {}, "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw=="],
54355439

54365440
"nx/ora/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
@@ -5479,6 +5483,10 @@
54795483

54805484
"meow/read-pkg-up/read-pkg/normalize-package-data/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver" } }, "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g=="],
54815485

5486+
"nx/ora/log-symbols/chalk/ansi-styles": ["[email protected]", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
5487+
5488+
"nx/ora/log-symbols/chalk/supports-color": ["[email protected]", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
5489+
54825490
"pacote/sigstore/@sigstore/tuf/tuf-js/@tufjs/models": ["@tufjs/[email protected]", "", { "dependencies": { "@tufjs/canonical-json": "2.0.0", "minimatch": "^9.0.5" } }, "sha512-h5x5ga/hh82COe+GoD4+gKUeV4T3iaYOxqLt41GRKApinPI7DMidhCmNVTjKfhCWFJIGXaFJee07XczdT4jdZQ=="],
54835491

54845492
"pkg-dir/find-up/locate-path/p-locate/p-limit": ["[email protected]", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="],

packages/client/cypress.config.cjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ module.exports = defineConfig({
1111
screenshotOnRunFailure: true,
1212
viewportWidth: 1280,
1313
viewportHeight: 720,
14-
defaultCommandTimeout: 10000,
15-
requestTimeout: 10000,
16-
responseTimeout: 10000,
14+
defaultCommandTimeout: 15000, // Increased for auth tests
15+
requestTimeout: 15000, // Increased for real backend calls
16+
responseTimeout: 15000, // Increased for real backend responses
17+
pageLoadTimeout: 30000, // Increased for full page loads
1718
setupNodeEvents(on, config) {
1819
// Add any e2e specific plugins here
1920
return config;

packages/client/cypress/e2e/01-home-page.cy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
describe('Home Page', () => {
22
beforeEach(() => {
3+
// Setup global API mocks
4+
cy.setupApiMocks();
5+
36
// Mock API calls to prevent timeouts
47
cy.intercept('GET', '/api/system/version', {
58
statusCode: 200,

packages/client/cypress/e2e/02-chat-functionality.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
describe('Chat Functionality', () => {
22
beforeEach(() => {
3+
// Setup global API mocks
4+
cy.setupApiMocks();
5+
36
// Mock API calls to prevent timeouts
47
cy.intercept('GET', '/api/system/version', {
58
statusCode: 200,
@@ -183,7 +186,7 @@ describe('Chat Functionality', () => {
183186
cy.get('[data-testid="connection-status"]', { timeout: 10000 }).should('exist');
184187

185188
// Should be clickable (even if it doesn't do much)
186-
cy.get('[data-testid="connection-status"]').click();
189+
cy.get('[data-testid="connection-status"]').click({ force: true });
187190

188191
// Status should still exist after click
189192
cy.get('[data-testid="connection-status"]').should('exist');

packages/client/cypress/e2e/03-spa-routing.cy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe('SPA Routing', () => {
99
];
1010

1111
beforeEach(() => {
12+
// Setup global API mocks
13+
cy.setupApiMocks();
14+
1215
// Mock API calls to prevent timeouts
1316
cy.intercept('GET', '/api/system/version', {
1417
statusCode: 200,

0 commit comments

Comments
 (0)