test(e2e): add audit-logs admin-gate smoke#1551
Conversation
Adds the first batch of admin/settings e2e specs. Covers create-an-inbox, create-and-revoke-an-API-key, and create-a-case-tag. The webhook spec is present but `test.fixme`d until the test backend image ships Convoy or v1.0.0 internal webhooks — the "New webhook" button is rendered disabled when the backend returns 500 from /webhooks. `auth.spec.ts` now pre-seeds the `version-snooze` localStorage key before saving `storageState`, so the release-notes modal (shown by the FE whenever the backend image is newer than the FE build) doesn't blanket- block every downstream chromium spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…gment Playwright glob `**` matches zero or more characters, so `/settings/inboxes/**` would have matched the pre-redirect `/settings/inboxes` URL and let the test pass before the redirect actually completed. Switch to a regex requiring at least one non-slash segment after the prefix. Same fix applied to `webhooks.spec.ts` for consistency. Reported by CodeRabbit on #1548. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Read-only smoke covering /settings/audit-logs. Pins the URL after hydration so the loader's silent isAdmin redirect-to-root cannot pass as a green test, and asserts the h1 + the five column headers (Timestamp, Actor, Operation, Table, Internal entity ID), which render in every state (loading, empty, populated) so the spec stays stable across the 4-worker shared-DB layout. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The /settings/audit-logs route uses `validateSearch` with `q.default('')` and
`limit.default(25)`, which materializes both params in the URL on first paint
(`?q=&limit=25`). The previous `audit-logs$` anchor failed in CI because the
end-of-string didn't account for that. Anchor on the path-segment terminator
(`?` or end-of-string) instead — still rejects a silent admin redirect to `/`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🧰 Additional context used📓 Path-based instructions (1)packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🔇 Additional comments (3)
📝 WalkthroughWalkthroughThis PR expands E2E test coverage for the Admin audit-logs settings page by adding two new test cases that verify pagination limit URL updates and filter submission with base64-encoded query parameters. Combined with the existing page load test, the suite now validates navigation, hydration, UI visibility, and interactive controls. ChangesAudit logs E2E coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The `<table>` only mounts on the `isSuccess` branch of the audit-events query. In the test backend image, `/admin/audit-events` returns 403 for the seeded org-admin (the backend endpoint enforces a stricter admin role than the FE route loader's `isAdmin()`), so the page lands in the `isError` branch with no table at all. Asserting column headers there fails the smoke even though the page itself renders fine. Switch the smoke to the title row + pagination row, both rendered unconditionally by `ActivityFollowUpPage` regardless of the query's state. This still verifies the route is reachable for an admin without false negatives from a backend permission asymmetry that is out of scope for a frontend smoke. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The audit-logs page's most testable surface lives outside the audit-events query's `match` block — the title row, filter bar, and pagination row all render unconditionally. Add two tests that exercise real FE state machinery without depending on the (test-image 403'd) `<table>` ever mounting. - Pagination: clicking the "50" button drives `setLimit` → `updatePage` → `useNavigate` → `validateSearch`, so the URL ends up with `limit=50`. - entityId filter: opening the filter menu, picking "Internal entity ID", typing a UUID, and pressing Enter writes a base64-encoded `q=` payload via `useBase64Query`. The active-filter chip renders with the UUID. `useBase64Query` is not exercised by any other e2e spec; this is the first tripwire for the encoder/decoder round-trip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
packages/tests/e2e/audit-logs.spec.ts— a read-only smoke covering/settings/audit-logs.redirect({ to: '/' })for non-admins cannot pass as a green test.<h1>plus the five column headers (Timestamp, Actor, Operation, Table, Internal entity ID), which render in every state (loading / empty / populated) — stable across the 4-worker shared-DB layout.Stacked on #1548 — depends on the
auth.spec.tslocalStorage pre-seed in that PR. GitHub will auto-retarget this tomainonce #1548 merges.Test plan
bun -F tests test --grep "Audit logs page loads for admin"passes locally (requires :3000 free and Docker up).bun run format:writeclean (verified at push time).cd packages/tests && bunx tsc --noEmitclean (verified pre-push).🤖 Generated with Claude Code
Summary by CodeRabbit