mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-29 00:25:19 +00:00
This commit fixes several critical issues causing E2E test failures and timeouts: **Authentication fixes:** - Remove cross-spec session caching to prevent state conflicts in parallel test execution - Changed `login(user, true)` to `login(user, false)` in createFakeUserAndLogin() **API intercept standardization:** - Standardized all API intercept patterns to use `/api/v1/` prefix consistently - Fixed mixed patterns: `**/projects/*/views/*/tasks**` → `**/api/v1/projects/*/views/*/tasks**` - Added explicit GET/PUT method specifications to prevent intercept misses **Timeout reduction:** - Reduced excessive timeouts from 60-120s to 30-60s in cypress.config.ts - Reduced test-level timeouts from 30s to 15s where appropriate - Changed defaultCommandTimeout: 60000 → 30000, requestTimeout: 120000 → 60000 **Test isolation improvements:** - Added proper beforeEach cleanup in overview.spec.ts to prevent data leakage - Removed redundant individual truncate() calls in favor of systematic cleanup **Files changed:** - cypress.config.ts: Reduced global timeout values - cypress/support/authenticateUser.ts: Fixed cross-spec session caching - cypress/e2e/project/*.spec.ts: Standardized intercept patterns, reduced timeouts - cypress/e2e/task/*.spec.ts: Added cleanup hooks, standardized intercepts - cypress/e2e/sharing/linkShare.spec.ts: Fixed intercept patterns and timeouts These changes address the root causes of the 25-minute timeouts and "3 failed" issues seen in CI, improving test reliability and execution speed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
965 B
TypeScript
40 lines
965 B
TypeScript
|
|
// This authenticates a user and puts the token in local storage which allows us to perform authenticated requests.
|
|
// Built after https://github.com/cypress-io/cypress-example-recipes/tree/bd2d6ffb33214884cab343d38e7f9e6ebffb323f/examples/logging-in__jwt
|
|
|
|
import {UserFactory} from '../factories/user'
|
|
|
|
export function login(user, cacheAcrossSpecs = false) {
|
|
if (!user) {
|
|
throw new Error('Needs user')
|
|
}
|
|
// Caching session when logging in via page visit
|
|
cy.session(`user__${user.username}`, () => {
|
|
cy.request('POST', `${Cypress.env('API_URL')}/login`, {
|
|
username: user.username,
|
|
password: '1234',
|
|
}).then(({ body }) => {
|
|
window.localStorage.setItem('token', body.token)
|
|
})
|
|
}, {
|
|
cacheAcrossSpecs,
|
|
})
|
|
}
|
|
|
|
export function createFakeUser() {
|
|
return UserFactory.create(1)[0]
|
|
}
|
|
|
|
export function createFakeUserAndLogin() {
|
|
let user
|
|
before(() => {
|
|
user = createFakeUser()
|
|
})
|
|
|
|
beforeEach(() => {
|
|
login(user, false)
|
|
})
|
|
|
|
return user
|
|
}
|