test(32.2-05): admin SPA tests for the consent screen, login hint and My account item rows

- ConnectView.test.ts: every C1 state, the * rule, no auto-allow, Allow and
  Deny bodies through window.location.assign, forbidden schemes, switch
  account, 401/404 handling, focus and the profile fallback
- router, LoginView and AccountContributions tests extended for /connect,
  the login hint and item rows (null items unchanged, empty block, :title
  confirm, 404 item_gone, 409 action_stale)
This commit is contained in:
Jakub Zych
2026-11-21 02:00:16 +01:00
parent 7ecfa6087d
commit 1e00ed3d3e
4 changed files with 689 additions and 0 deletions

View File

@@ -183,3 +183,41 @@ describe('preview route (UI-SPEC S3, D-11)', () => {
expect(safeRedirect(router.currentRoute.value.query.redirect)).toBe('/acme/demo/widgets/12/preview')
})
})
describe('connect route (32.2 UI-SPEC C1)', () => {
it('sends an anonymous visitor of /connect to login with the request and returns there after sign-in', async () => {
mockApi({})
const router = createAdminRouter(createMemoryHistory())
await router.push('/connect?request=x')
expect(router.currentRoute.value.name).toBe('login')
expect(router.currentRoute.value.query.redirect).toBe('/connect?request=x')
expect(safeRedirect(router.currentRoute.value.query.redirect)).toBe('/connect?request=x')
// Signed in, the login screen of that redirect moves on to /connect.
await signIn()
const back = createAdminRouter(createMemoryHistory())
await back.push({ path: '/login', query: { redirect: router.currentRoute.value.query.redirect } })
expect(back.currentRoute.value.name).toBe('connect')
expect(back.currentRoute.value.fullPath).toBe('/connect?request=x')
expect(back.currentRoute.value.query.request).toBe('x')
})
it('is a standalone route that is neither public nor inside the shell', async () => {
await signIn()
const router = await routerAt('/connect?request=abc')
expect(router.currentRoute.value.name).toBe('connect')
expect(router.currentRoute.value.meta.shell).toBeFalsy()
expect(router.currentRoute.value.meta.public).toBeFalsy()
expect(routeControllerId(router.currentRoute.value)).toBe('')
})
it('keeps an encoded request id through the login redirect', async () => {
mockApi({})
const router = createAdminRouter(createMemoryHistory())
await router.push({ path: '/connect', query: { request: 'a b/c' } })
const redirect = router.currentRoute.value.query.redirect
expect(router.currentRoute.value.name).toBe('login')
expect(safeRedirect(redirect)).toBe(redirect)
expect(new URL(String(redirect), 'http://admin.invalid').searchParams.get('request')).toBe('a b/c')
})
})