Repository navigation
test: add cross cutting smoke test for a product catalog flow - #4296
Conversation
📝 WalkthroughWalkthroughAdds a new end-to-end smoke test ChangesV3 Product Catalog E2E Testing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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)
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 |
3cb3dc0 to
aaf74e8
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)
46-237: ⚡ Quick winStop the parent test after a setup subtest fails.
These
t.Runblocks all share outer state, so an earlyrequire.*failure only stops that one subtest and the rest keep running with emptyplanID/featureID/phaseKey. That turns one real failure into a pile of follow-on noise. Either keep this flow straight-line in the parent test, or gate each dependent step with the boolean result fromt.Run.One simple pattern
- t.Run("Should create a meter", func(t *testing.T) { + if !t.Run("Should create a meter", func(t *testing.T) { CreateMeterE2E(t, v1, meterSlug, eventType) - }) + }) { + t.FailNow() + }Apply the same pattern to the later dependent steps, or move the setup into small helper calls without subtests.
🤖 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 `@e2e/productcatalog_smoke_v3_test.go` around lines 46 - 237, Several setup subtests (e.g., the ones that call CreateMeterE2E, CreateFeatureE2E, CreatePlan, etc.) leave shared outer state (planID, featureID, phaseKey) and a failing require in a subtest does not stop the parent test, causing noisy follow-on failures; wrap each dependent subtest invocation with a boolean check on t.Run (or return that boolean) and call t.FailNow()/stop the parent when the setup subtest returns false, or alternatively convert the setup subtests into helper functions that return (ok, value) and explicitly abort the parent test on failure before continuing to functions like CreateMeterE2E, CreateFeatureE2E, c.CreatePlan, c.UpdatePlan, c.GetPlan, c.PublishPlan, c.CreateAddon, c.PublishAddon, c.AttachAddon, and c.ListPlanAddons so later steps never run with empty shared state.
🤖 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 `@e2e/productcatalog_smoke_v3_test.go`:
- Around line 46-237: Several setup subtests (e.g., the ones that call
CreateMeterE2E, CreateFeatureE2E, CreatePlan, etc.) leave shared outer state
(planID, featureID, phaseKey) and a failing require in a subtest does not stop
the parent test, causing noisy follow-on failures; wrap each dependent subtest
invocation with a boolean check on t.Run (or return that boolean) and call
t.FailNow()/stop the parent when the setup subtest returns false, or
alternatively convert the setup subtests into helper functions that return (ok,
value) and explicitly abort the parent test on failure before continuing to
functions like CreateMeterE2E, CreateFeatureE2E, c.CreatePlan, c.UpdatePlan,
c.GetPlan, c.PublishPlan, c.CreateAddon, c.PublishAddon, c.AttachAddon, and
c.ListPlanAddons so later steps never run with empty shared state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d2cd34e0-03cd-46ac-bbb9-bad435684aac
📒 Files selected for processing (3)
e2e/helpers.goe2e/productcatalog_smoke_v3_test.goe2e/v3helpers_test.go
aaf74e8 to
c9b4947
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)
30-31: ⚡ Quick winBind the client to the current subtest’s
t.Right now
newV3Client(t)captures the parent test handle once, so everyrequire.NoError(...)andt.Context()insidev3Client.do/decodeTypedis scoped to the outer test, not the active subtest. Re-creating the client inside eacht.Run(...), or rebinding it per subtest, will keep failures and cancellation attached to the right test. As per coding guidelines,**/*_test.go: prefert.Context()when atesting.Tortesting.TBis available instead of usingcontext.Background()to keep cancellation and lifecycle tied to the test harness.🤖 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 `@e2e/productcatalog_smoke_v3_test.go` around lines 30 - 31, The v3 client is created once with newV3Client(t) and captures the parent test handle, so v3Client.do and decodeTyped use the outer test's context; instead, re-create or rebind the client inside each subtest (call newV3Client(t) within each t.Run) or provide a small helper (e.g., v3Client.forTest(t) or pass t.Context() into v3Client.do/decodeTyped) so that require.NoError and t.Context() are scoped to the active subtest; update calls to v3Client.do/decodeTyped to accept/use the subtest's t.Context() if you choose rebinding instead of recreating the client.
🤖 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.
Inline comments:
In `@e2e/productcatalog_smoke_v3_test.go`:
- Around line 46-77: The two subtests use the v3 client calls c.CreateMeter
(apiv3.CreateMeterRequest) and c.CreateFeature (apiv3.CreateFeatureRequest) so
they never exercise the v1→v3 boundary; replace these calls with the existing v1
e2e helper functions used elsewhere in tests (the helpers that create a
v1-authored meter and a v1-authored feature) instead of c.CreateMeter and
c.CreateFeature, ensuring you still set meterID and featureID from the helper
responses and keep the same assertions (status == http.StatusCreated, non-nil
response, non-empty Id) so the smoke test validates v1-authored entities
consumed by v3 APIs.
- Around line 118-123: After calling c.UpdatePlan and loading the plan (via
UpdatePlan -> plan), add an assertion that the usage rate card retained its
Feature binding: inspect plan.Phases[0].RateCards to find the usage-type rate
card and assert its Feature field is not nil (or has the expected
Feature.ID/Name), e.g., locate the rate card with Type "usage" and
require.NotNil(t, rateCard.Feature) (or require.Equal for the expected
Feature.ID) to ensure the Feature binding survives the update/readback.
---
Nitpick comments:
In `@e2e/productcatalog_smoke_v3_test.go`:
- Around line 30-31: The v3 client is created once with newV3Client(t) and
captures the parent test handle, so v3Client.do and decodeTyped use the outer
test's context; instead, re-create or rebind the client inside each subtest
(call newV3Client(t) within each t.Run) or provide a small helper (e.g.,
v3Client.forTest(t) or pass t.Context() into v3Client.do/decodeTyped) so that
require.NoError and t.Context() are scoped to the active subtest; update calls
to v3Client.do/decodeTyped to accept/use the subtest's t.Context() if you choose
rebinding instead of recreating the client.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 71eb633e-7c77-45c1-b1f2-b4d9f2864d9e
📒 Files selected for processing (2)
e2e/productcatalog_smoke_v3_test.goe2e/v3helpers_test.go
c9b4947 to
f0ea4c6
Compare
f0ea4c6 to
4068dc2
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)
30-272: 💤 Low valueSolid cross-cutting smoke test — LGTM overall!
The flow is well-narrated by the subtest names, the doc comment up top mirrors the PR description nicely, and the happy-path + error-loop + addon-attach coverage hits exactly the seam an isolated suite would miss. Bonus points for re-reading the rate cards from the server before injecting the defective one (line 144-151) — that sidesteps the
"0.10"→"0.1"normalization trap cleanly, and the post-update assertion that the usage card kept itsFeaturebinding (line 124-133) closes a real gap.A couple of small things that aren't blockers but might be worth a thought for a follow-up:
validRateCards(line 138) sits between subtests as package-shaped state. Hoisting it into thevar (...)block at line 37-44 alongsideplanID/addonID/etc. would keep all the cross-subtest state in one obvious place.- Line 167's
append(append([]apiv3.BillingRateCard{}, validRateCards...), defective)is doing the right thing (defensive copy so we don't accidentally mutatevalidRateCardsvia shared backing array), butslices.Concat(validRateCards, []apiv3.BillingRateCard{defective})or a tiny helper would read more obviously.- Line 213-215 is correct (nil and empty both mean "cleared"), but you could collapse it to
assert.Empty(t, got.ValidationErrors)against the pointer to remove the conditional and make intent louder.🤖 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 `@e2e/productcatalog_smoke_v3_test.go` around lines 30 - 272, Hoist the package-scoped test state by moving validRateCards into the existing var(...) block near meterID/planID/etc so all cross-subtest state is declared together (symbol: validRateCards in TestV3ProductCatalogSmoke); replace the defensive append expression that builds the updated RateCards (the append(append([]apiv3.BillingRateCard{}, validRateCards...), defective) construction) with a clearer alternative such as slices.Concat(validRateCards, []apiv3.BillingRateCard{defective}) or a small helper function to make intent obvious; and simplify the post-update validation assertion by replacing the nil-check + assert.Empty branch on got.ValidationErrors with a single assert.Empty(t, got.ValidationErrors) call to make the expectation explicit.
🤖 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 `@e2e/productcatalog_smoke_v3_test.go`:
- Around line 30-272: Hoist the package-scoped test state by moving
validRateCards into the existing var(...) block near meterID/planID/etc so all
cross-subtest state is declared together (symbol: validRateCards in
TestV3ProductCatalogSmoke); replace the defensive append expression that builds
the updated RateCards (the append(append([]apiv3.BillingRateCard{},
validRateCards...), defective) construction) with a clearer alternative such as
slices.Concat(validRateCards, []apiv3.BillingRateCard{defective}) or a small
helper function to make intent obvious; and simplify the post-update validation
assertion by replacing the nil-check + assert.Empty branch on
got.ValidationErrors with a single assert.Empty(t, got.ValidationErrors) call to
make the expectation explicit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f529e4eb-57fb-4208-ab8c-fb7dd3eed71e
📒 Files selected for processing (2)
e2e/productcatalog_smoke_v3_test.goe2e/v3helpers_test.go
Overview
Adds a cross-cutting v3 product-catalog smoke test (
TestV3ProductCatalogSmoke)that ties together the entity-siloed plan / addon / plan-addon e2e suites. Existing
v3 e2e tests cover each domain in isolation; this one walks a realistic authoring
flow end-to-end and catches integration regressions the siloed tests can't see.
Flow:
loop: GET surfaces
validation_errors, publish is rejected with the same code.validation_errorsclearsNotes for reviewer
make etoe; locally:TZ=UTC OPENMETER_ADDRESS=http://localhost:8888 go test -count=1 -tags=dynamic -v -run '^TestV3ProductCatalogSmoke$' ./e2e/.Summary by CodeRabbit