directus-main — auth & request flow
LoginForm.vue knows nothing about how login actually works — it just calls whatever
onSubmit function it's given. LoginPage.vue is the one that wires it to a real (simulated)
authClient. See System Architecture for where these pieces sit,
and Data Model for the Session shape setSession actually
stores.
auth.setSession(token, expiresAt) → router.push('/')
InvalidCredentialsError — LoginForm shows its message, stays on
/login
requiresAuth meta + no session → redirected to /login
/ — never shows the form again
Real bug, found while writing a test: the "redirected away from /login when already
authenticated" branch above had zero test coverage — unlike a genuinely untestable branch elsewhere in this app,
this one just hadn't gotten a test yet. Writing it exposed a real, previously-silent defect: earlier tests'
mounted App instances were never unmounted, and since they all shared one
router singleton, their stale RouterView registrations interfered with the new test.
Fixed with @vue/test-utils's enableAutoUnmount(afterEach), then applied to every test
file with the same latent risk — not just the one that had actually failed. See
Testing Strategy for the full test-layer picture this bug came out of.