fix(frontend/tests): update users.test for invite flow + allowed_accounts#358
Conversation
Four users.test.ts cases were stale on `feat/multicloud-web-frontend` and are failing on every PR-merge ref against it (including #336, #352, others). The tests assert the pre-#348 / pre-#347 behaviour: 1. `loadUsers › should load users and groups` 2. `loadUsers › should render groups after loading` `mockGroups` is missing the `allowed_accounts: []` field that the backend now ships on every group (multi-cloud account-scoping work). The actual groups from `api.listGroups` carry the field, so the deep-equal assertion against the fixture diverges. 3. `openCreateUserModal › should make password required` 4. `saveUser › should validate empty password for new user` Issue #348 ("invite users without a password and let them set it on first login") made password optional on create. userModals.ts now explicitly sets `passwordInput.required = false` (line 36) so the form-level HTML validation doesn't block the invite flow, and saveUser intentionally calls `api.createUser` with an empty password to trigger the backend invite-email path. Both old tests asserted the opposite behaviour and now fail. Fix: - Add `allowed_accounts: []` to the two `mockGroups` entries. - Invert "should make password required" → "should not mark password as required (blank invites the user)" asserting `required === false`. - Replace "should validate empty password" → "should allow empty password for new user (invite flow, issue #348)" asserting createUser was called with an empty password and no error toast was rendered. Unblocks the frontend-build-sentinel workflow on PRs against `feat/multicloud-web-frontend`. 1633 frontend tests pass.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTest suite updated to reflect invite-based user creation: group fixtures now include ChangesUser Invite Flow Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
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)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Four cases in
users.test.tsare stale onfeat/multicloud-web-frontendand failing on every PR-merge ref against the base — see https://github.com/LeanerCloud/CUDly/actions/runs/25825557119 (PR #336) and the same failure on https://github.com/LeanerCloud/CUDly/actions/runs/25825131269 (PR #352). Blocks thefrontend-build-sentinelworkflow across every open PR. Same shape as #337 (the factory_test.go merge glitch): pre-existing on base, every PR inherits it.Failures and fixes
loadUsers › should load users and groups(L1023)mockGroupsis missingallowed_accounts: []that the backend now ships on every groupallowed_accounts: []to both fixture entriesloadUsers › should render groups after loading(L1036)mockGroupsshape mismatchopenCreateUserModal › should make password required(L1464)passwordInput.required = falseso the form-level HTML validation doesn't block the invite flowrequired === falsesaveUser › should validate empty password for new user(L1666)api.createUseris called with empty password, backend emails a set-password link)api.createUseris called withpassword: ''and no error toast rendersNo production code changes — this is a test-only catch-up for behavior that already shipped in #347 (allowed_accounts) and #348 (invite-without-password).
Test plan
npx jest --testPathPattern="users.test"on the fix branch — 1633 passing, 0 failing.frontend-build-sentinelshould go green.Notes
api.createUserwas called with empty password) rather than just removing the test, so a future regression that re-introduces the empty-password block would still fail this case.Summary by CodeRabbit