Construct admin links correctly for staging/dev#24
Conversation
|
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughgetUsernameFromPayload in submit.go now returns (username, adminLink, isVerified); a global regex parses user_id to build adminLink. buildGenericIssueRequest uses adminLink for the "User Admin" link. New table-driven tests validate username, adminLink, and verification extraction. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
submit_test.go (1)
38-57: Missingnamefield in test cases.These two test cases are missing the
namefield, which will result in empty test names int.Run(""). This makes test output harder to interpret when debugging failures.Suggested fix
{ + name: "staging domain", in: map[string]string{ "user_id": "@bender:beeper-staging.com", }, out: usernameOutput{ username: "bender:beeper-staging.com", adminLink: "https://admin.beeper-staging.com/user/bender", isVerified: true, }, }, { + name: "unknown domain fallback", in: map[string]string{ "user_id": "@bender:beeper-anywhere.com", }, out: usernameOutput{ username: "bender:beeper-anywhere.com", adminLink: "https://admin.beeper.com/user/bender:beeper-anywhere.com", isVerified: true, }, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@submit_test.go` around lines 38 - 57, The two table-driven test entries are missing the test-case `name` field which causes t.Run("") to show empty names; update each of those test-case literals (the ones with in: map[string]string{"user_id": ...} and out: usernameOutput{...}) to include a descriptive `name` string (e.g., "beeper-staging verified" and "beeper-anywhere verified") so t.Run uses a meaningful label when running the test; ensure the `name` key matches the test-case struct field used by the test harness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@submit_test.go`:
- Around line 38-57: The two table-driven test entries are missing the test-case
`name` field which causes t.Run("") to show empty names; update each of those
test-case literals (the ones with in: map[string]string{"user_id": ...} and out:
usernameOutput{...}) to include a descriptive `name` string (e.g.,
"beeper-staging verified" and "beeper-anywhere verified") so t.Run uses a
meaningful label when running the test; ensure the `name` key matches the
test-case struct field used by the test harness.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 62cf67d2-749f-453d-b322-a73bf420e97a
📒 Files selected for processing (2)
submit.gosubmit_test.go
📜 Review details
🔇 Additional comments (3)
submit_test.go (1)
60-72: LGTM!Good use of table-driven tests. The test function correctly validates all three return values from
getUsernameFromPayload, and the struct comparison approach is clean and readable.submit.go (2)
923-947: LGTM!The implementation correctly addresses the PR objective. The regex properly captures the username and domain for known Beeper environments, and the fallback path handles unknown domains gracefully. The order of operations (set fallback first, then override if matched) is correct.
1144-1152: LGTM!The call site is correctly updated to use the new three-value return signature and properly uses
adminLinkinstead of constructing the URL from the username.
The admin links were wrong for non-production tickets. Also we had no tests so I added some. (Not run automatically by CI yet.)