feat(mail): bot+mailbox=me validation and dynamic --as help tests#895
feat(mail): bot+mailbox=me validation and dynamic --as help tests#895xzcong0820 wants to merge 1 commit into
Conversation
Add validateBotMailboxNotMe helper to shortcuts/mail/helpers.go and wire it as a Validate callback into +message, +messages, +thread and +triage, so bot identity combined with the default --mailbox me is rejected early with a clear fixup hint instead of a late opaque API error. The --as help text was already dynamic via AddShortcutIdentityFlag; add TC-10/TC-11 tests in internal/cmdutil/identity_flag_test.go to pin that behaviour, and TC-1 through TC-9 in shortcuts/mail/mail_shortcut_validation_test.go to cover the new Validate callbacks. +watch is excluded: its AuthTypes is ["user"], so bot is never valid. sprint: S2
📝 WalkthroughWalkthroughThis PR improves bot identity handling in the CLI. It adds identity flag usage formatting tests for the ChangesBot identity and mailbox validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/cmdutil/identity_flag_test.go (2)
71-89: 💤 Low valueConsider adding visibility check for consistency.
The test properly validates the usage text, but existing tests in this file (lines 63-65) also verify that
flag.Hiddenis false. Adding this check would improve consistency with the established test pattern.🔍 Optional consistency enhancement
if flag == nil { t.Fatal("expected --as flag to be registered") } + if flag.Hidden { + t.Fatal("expected --as flag to be visible") + } wantUsage := "identity type: user"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/cmdutil/identity_flag_test.go` around lines 71 - 89, The test TestAddShortcutIdentityFlag_UserOnlyAuthTypes should also assert the flag's visibility like the other tests: after retrieving the flag via cmd.Flags().Lookup("as") add a check that flag.Hidden is false (or call t.Fatalf/t.Errorf with a clear message if it is true) to ensure the --as flag is not hidden; update this in the test alongside the existing Usage assertions and reference AddShortcutIdentityFlag and the flag variable for locating the change.
91-106: 💤 Low valueConsider adding visibility and default value checks for consistency.
The test properly validates the usage text, but existing tests (lines 63-68) also verify
flag.Hiddenis false and the default value is empty. Adding these checks would improve completeness and consistency with the established test pattern.🔍 Optional consistency enhancement
if flag == nil { t.Fatal("expected --as flag to be registered") } + if flag.Hidden { + t.Fatal("expected --as flag to be visible") + } + if got := flag.DefValue; got != "" { + t.Fatalf("default value = %q, want empty string", got) + } wantUsage := "identity type: user | bot"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/cmdutil/identity_flag_test.go` around lines 91 - 106, The test TestAddShortcutIdentityFlag_UserBotAuthTypes currently only checks the --as flag Usage; update it to also assert the flag's visibility and default value by verifying flag.Hidden is false and flag.Value.String() is empty. Locate the test function TestAddShortcutIdentityFlag_UserBotAuthTypes and after retrieving flag := cmd.Flags().Lookup("as"), add assertions similar to the existing pattern (as in the other tests around lines 63-68) to check flag.Hidden == false and flag.Value.String() == "" to ensure consistent coverage for AddShortcutIdentityFlag.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/cmdutil/identity_flag_test.go`:
- Around line 71-89: The test TestAddShortcutIdentityFlag_UserOnlyAuthTypes
should also assert the flag's visibility like the other tests: after retrieving
the flag via cmd.Flags().Lookup("as") add a check that flag.Hidden is false (or
call t.Fatalf/t.Errorf with a clear message if it is true) to ensure the --as
flag is not hidden; update this in the test alongside the existing Usage
assertions and reference AddShortcutIdentityFlag and the flag variable for
locating the change.
- Around line 91-106: The test TestAddShortcutIdentityFlag_UserBotAuthTypes
currently only checks the --as flag Usage; update it to also assert the flag's
visibility and default value by verifying flag.Hidden is false and
flag.Value.String() is empty. Locate the test function
TestAddShortcutIdentityFlag_UserBotAuthTypes and after retrieving flag :=
cmd.Flags().Lookup("as"), add assertions similar to the existing pattern (as in
the other tests around lines 63-68) to check flag.Hidden == false and
flag.Value.String() == "" to ensure consistent coverage for
AddShortcutIdentityFlag.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 34c46c79-140e-4b19-89de-318bc743ed12
📒 Files selected for processing (7)
internal/cmdutil/identity_flag_test.goshortcuts/mail/helpers.goshortcuts/mail/mail_message.goshortcuts/mail/mail_messages.goshortcuts/mail/mail_shortcut_validation_test.goshortcuts/mail/mail_thread.goshortcuts/mail/mail_triage.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #895 +/- ##
==========================================
+ Coverage 65.90% 66.09% +0.19%
==========================================
Files 520 520
Lines 49274 49292 +18
==========================================
+ Hits 32474 32580 +106
+ Misses 14026 13919 -107
- Partials 2774 2793 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@74234de12acb44177067a6f94976aab769bd3e5f🧩 Skill updatenpx skills add xzcong0820/larksuite-cli#feat/831a0c0 -y -g |
Generated by the harness-coding skill.
Sprints
Source specs
This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.
Summary by CodeRabbit
Release Notes
Improvements
Tests