Some checks failed
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
- Replaced `PageReturnLink` with `PageReturnButton` for consistent back navigation across various pages. - Updated multiple components, including `ExercisePeekModal`, `PageFormEditorChrome`, and `ExerciseDetailPage`, to utilize the new return context features. - Enhanced CSS styles for the new return button to improve visual consistency. - Improved navigation logic in `TrainingFrameworkProgramEditPage` and `TrainingModuleEditPage` to ensure seamless user experience when navigating back to previous locations.
101 lines
3.1 KiB
JavaScript
101 lines
3.1 KiB
JavaScript
import { describe, expect, it, vi } from 'vitest'
|
|
import {
|
|
appReturnFromPlanningReturn,
|
|
buildExercisesListReturnContext,
|
|
buildMediaLibraryReturnContext,
|
|
buildNavReturnContext,
|
|
buildPlanningHubReturnContext,
|
|
buildTrainingRunReturnContext,
|
|
goNavReturn,
|
|
readNavReturnFromLocation,
|
|
resolveNavReturnTarget,
|
|
} from './navReturnContext.js'
|
|
|
|
describe('navReturnContext', () => {
|
|
it('buildNavReturnContext requires path and label', () => {
|
|
expect(buildNavReturnContext({ path: '/x', label: 'Zurück' })).toEqual({
|
|
v: 1,
|
|
path: '/x',
|
|
label: 'Zurück',
|
|
})
|
|
expect(buildNavReturnContext({ path: '', label: 'X' })).toBeNull()
|
|
})
|
|
|
|
it('buildExercisesListReturnContext', () => {
|
|
const ctx = buildExercisesListReturnContext()
|
|
expect(ctx.path).toBe('/exercises')
|
|
expect(ctx.kind).toBe('exerciseList')
|
|
})
|
|
|
|
it('readNavReturnFromLocation prefers appReturn', () => {
|
|
const ctx = buildExercisesListReturnContext()
|
|
expect(readNavReturnFromLocation({ state: { appReturn: ctx } })).toEqual(ctx)
|
|
})
|
|
|
|
it('readNavReturnFromLocation bridges planningReturn', () => {
|
|
const loc = {
|
|
state: {
|
|
planningReturn: {
|
|
v: 1,
|
|
selectedGroupId: '3',
|
|
planView: 'list',
|
|
calendarMonthStr: '',
|
|
startDate: '',
|
|
endDate: '',
|
|
planScope: 'group',
|
|
assignedToMeOnly: false,
|
|
},
|
|
},
|
|
}
|
|
const ctx = readNavReturnFromLocation(loc)
|
|
expect(ctx?.kind).toBe('planningHub')
|
|
expect(ctx?.path).toContain('/planning')
|
|
expect(ctx?.label).toBe('Zurück zur Planung')
|
|
})
|
|
|
|
it('appReturnFromPlanningReturn', () => {
|
|
const ctx = appReturnFromPlanningReturn({
|
|
v: 1,
|
|
selectedGroupId: '',
|
|
planView: 'calendar',
|
|
calendarMonthStr: '2026-05',
|
|
startDate: '',
|
|
endDate: '',
|
|
planScope: 'group',
|
|
assignedToMeOnly: false,
|
|
})
|
|
expect(ctx?.path).toContain('month=2026-05')
|
|
})
|
|
|
|
it('resolveNavReturnTarget uses fallback when no state', () => {
|
|
const fb = { path: '/planning/training-modules', label: 'Zurück zur Modul-Bibliothek' }
|
|
expect(resolveNavReturnTarget({ state: null }, fb)).toEqual({ ...fb, fromContext: false })
|
|
})
|
|
|
|
it('goNavReturn navigates to context path first', () => {
|
|
const navigate = vi.fn()
|
|
const ctx = buildExercisesListReturnContext()
|
|
goNavReturn(navigate, { state: { appReturn: ctx } }, null)
|
|
expect(navigate).toHaveBeenCalledWith('/exercises')
|
|
})
|
|
|
|
it('buildPlanningHubReturnContext', () => {
|
|
const ctx = buildPlanningHubReturnContext({ selectedGroupId: '7', planView: 'list' })
|
|
expect(ctx?.path).toContain('group=7')
|
|
expect(ctx?.kind).toBe('planningHub')
|
|
})
|
|
|
|
it('buildTrainingRunReturnContext', () => {
|
|
const ctx = buildTrainingRunReturnContext(42)
|
|
expect(ctx?.path).toBe('/planning/run/42')
|
|
expect(ctx?.kind).toBe('trainingRun')
|
|
expect(buildTrainingRunReturnContext('')).toBeNull()
|
|
})
|
|
|
|
it('buildMediaLibraryReturnContext', () => {
|
|
const ctx = buildMediaLibraryReturnContext()
|
|
expect(ctx?.path).toBe('/media')
|
|
expect(ctx?.kind).toBe('mediaLibrary')
|
|
})
|
|
})
|