Skip to content

test(e2e): add audit-logs admin-gate smoke#1551

Merged
Djauron merged 8 commits into
mainfrom
feat/e2e-audit-logs
May 19, 2026
Merged

test(e2e): add audit-logs admin-gate smoke#1551
Djauron merged 8 commits into
mainfrom
feat/e2e-audit-logs

Conversation

@Djauron
Copy link
Copy Markdown
Contributor

@Djauron Djauron commented May 19, 2026

Summary

  • Adds packages/tests/e2e/audit-logs.spec.ts — a read-only smoke covering /settings/audit-logs.
  • Pins the final URL after hydration so the loader's silent redirect({ to: '/' }) for non-admins cannot pass as a green test.
  • Asserts the <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.ts localStorage pre-seed in that PR. GitHub will auto-retarget this to main once #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:write clean (verified at push time).
  • cd packages/tests && bunx tsc --noEmit clean (verified pre-push).
  • CI green on the PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added end-to-end test coverage for the Admin Audit logs page to validate pagination controls, dynamic filtering functionality, and page loading behavior.

Review Change Stack

Djauron and others added 3 commits May 18, 2026 22:12
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>
Base automatically changed from feat/e2e-settings-suite to main May 19, 2026 12:25
Djauron and others added 2 commits May 19, 2026 14:26
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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d6dd94d-c637-4602-ab84-2787593229ca

📥 Commits

Reviewing files that changed from the base of the PR and between 618522a and 66d35c1.

📒 Files selected for processing (1)
  • packages/tests/e2e/audit-logs.spec.ts
📜 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)
  • GitHub Check: check / main
  • GitHub Check: e2e
🧰 Additional context used
📓 Path-based instructions (1)
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Tailwind CSS 4 with the tailwind-preset package for consistent styling across packages

Files:

  • packages/tests/e2e/audit-logs.spec.ts
🔇 Additional comments (3)
packages/tests/e2e/audit-logs.spec.ts (3)

1-23: LGTM!

'Tis well-crafted! The regex anchor on line 13 doth catch permission regressions whilst allowing query params to dance freely, and thy comments explain the unconditional chrome assertion with admirable clarity.


25-35: LGTM!


37-62: LGTM!

The UUID generation on line 51 ensures thy test stands alone midst the concurrent workers' clamor, and the base64 query assertion wisely checks presence rather than exact encoding.


📝 Walkthrough

Walkthrough

This 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.

Changes

Audit logs E2E coverage

Layer / File(s) Summary
Test setup and utilities
packages/tests/e2e/audit-logs.spec.ts
Playwright imports, Node crypto for UUID generation, and waitForHydration utility to ensure consistent page readiness across all test cases.
Page load and visibility
packages/tests/e2e/audit-logs.spec.ts
E2e test navigates to the audit-logs settings page, waits for hydration, asserts the URL persists on /settings/audit-logs to catch permission regressions, and confirms the page heading and pagination/filter UI text render correctly.
Pagination and filter interactions
packages/tests/e2e/audit-logs.spec.ts
E2e tests verify that clicking the pagination "50" control updates the URL limit search param, and that the "Add new filter" flow for entityId encodes the filter as a base64 q query param and renders the selected UUID in an active filter chip.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

M

Suggested reviewers

  • william-schlegel

Poem

✨ With Playwright's gentle hand, the audit logs now dance,
Pagination bows and filters take their stance,
UUID-encoded queries in the URL align,
Each test a verse of coverage—thy code doth shine! 🎭

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an E2E smoke test for the audit-logs admin page, which aligns with the changeset's addition of audit-logs.spec.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/e2e-audit-logs

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Djauron and others added 3 commits May 19, 2026 14:32
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>
Copy link
Copy Markdown
Contributor

@ChibiBlasphem ChibiBlasphem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Djauron Djauron enabled auto-merge (squash) May 19, 2026 13:45
@coderabbitai coderabbitai Bot added the M medium label May 19, 2026
@Djauron Djauron merged commit 43b3aaa into main May 19, 2026
5 of 6 checks passed
@Djauron Djauron deleted the feat/e2e-audit-logs branch May 19, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants