Add browser test for logout #56
Labels
No labels
app
backlog
bug
ci-cd
contribution welcome
duplicate
enhancement
good first issue
help wanted
question
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#54 Replace Dusk with Pest 4 browser testing (Playwright)
lvl0/dishplanner
Reference: lvl0/dishplanner#56
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Gap
POST /logouthas no browser test and no feature test — it is the only auth route with neither.Scope
Cover, in
tests/Browser/Auth/LogoutTest.php:/dashboard,/dishes,/schedule,/users) redirect to login afterwardsThe session/CSRF behaviour here is worth exercising in a real browser — there is a
/refresh-csrfroute, which suggests token handling has needed attention.Blocked by #54
Write in Pest browser syntax after the Dusk → Pest migration.
Acceptance
Done
All four acceptance criteria met.
Commits
95c5a72tests/Browser/Auth/LogoutTest.php+ sharedlogout()helper intests/Pest.phpc1d8008pest-browserhelper inshell.nixb543f5f/refresh-csrfCoverage added
tests/Browser/Auth/LogoutTest.php— 3 tests, 24 assertions:/dashboard,/dishes,/schedule,/usersall redirect to login afterwards (dataset)tests/Feature/AuthenticationTest.php:test_logout_invalidates_the_session— asserts the session ID changes and session data is flushed/refresh-csrftests — the route returned the live CSRF token to both guests and authenticated users, and had no coverage at all before thisFull suite is 160 tests (was 157); browser suite 34 passing.
Notes for future work
Two selector traps in the nav (
resources/views/components/layouts/app.blade.php), both of which cause Playwright to hang silently rather than fail:@clickattribute — a selector written asbutton[x-on\:click="..."]matches nothing.sm:hiddenmobile overlay). Bare-textpress('Logout')goes through the plugin'sGuessLocator→getByText()underunstrict, which silently picks the first match — the hidden one — then waits forever for it to become actionable.The shared
logout()helper intests/Pest.phpscopes to the desktop form with an explicit CSS selector to avoid both. Selectors containing CSS special characters run in Playwright strict mode, so an ambiguous one errors loudly instead of hanging — prefer those over bare text.Not covered: the full CSRF recovery flow (419 → Livewire
failhook → refetch → token swapped into the meta tag). That depends on client-side JS and needs a browser test; the feature tests only pin the route's response contract. Worth a follow-up ticket if that path is considered risky.shell.nix:pest-browserpreviously hardcoded the suite path, so passing a path doubled it and Pest died with "already uses the test case". It now accepts either form. Note this requires leaving and re-enteringnix-shellto take effect.