Skip to content

test: add cross cutting smoke test for a product catalog flow - #4296

Merged
tothandras merged 1 commit into
mainfrom
chore/add-baseline-e2e-test-flow
May 6, 2026
Merged

tothandras merged 1 commit into
mainfrom
chore/add-baseline-e2e-test-flow

Conversation

@rolosp

@rolosp rolosp commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Create a meter
  • Create a feature bound to the meter
  • Create a draft plan with a single flat rate card
  • Update the plan to carry flat + usage (with feature) + graduated rate cards
  • Add a defective rate card (cadence-misaligned) and confirm the draft-with-errors
    loop: GET surfaces validation_errors, publish is rejected with the same code.
  • Remove the defective rate card and confirm validation_errors clears
  • Create a draft addon and publish it.
  • Attach the published addon to the still-draft plan.
  • Publish the plan and confirm the attached addon survives the transition.

Notes for reviewer

  • Runs as part of make etoe; locally: TZ=UTC OPENMETER_ADDRESS=http://localhost:8888 go test -count=1 -tags=dynamic -v -run '^TestV3ProductCatalogSmoke$' ./e2e/.

Summary by CodeRabbit

  • Tests
    • Added a comprehensive end-to-end smoke test for the v3 product catalog workflow: cross-version creation of meter/feature, draft plan creation and updates with flat/usage/graduated rate cards, injection and clearance of validation errors, addon publish and attachment, and final plan publish verification.
  • Tests
    • Added a test helper to generate valid usage-type rate cards for feature-linked pricing scenarios.

@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new end-to-end smoke test TestV3ProductCatalogSmoke exercising cross-version flows (v1 meter/feature creation → v3 plan/addon lifecycle, validation error injection/removal) and a helper validUsageRateCard to build usage-labeled rate cards referencing features.

Changes

V3 Product Catalog E2E Testing

Layer / File(s) Summary
Test Helper
e2e/v3helpers_test.go
Adds validUsageRateCard(keyPrefix, featureID string) apiv3.BillingRateCard, composing a usage-labeled rate card that references a feature ID.
Smoke Test - Setup / Fixtures
e2e/productcatalog_smoke_v3_test.go
Introduces TestV3ProductCatalogSmoke(t *testing.T) and local variables for tracking created artifact IDs and keys.
Smoke Test - Create Meter & Feature (v1)
e2e/productcatalog_smoke_v3_test.go
Creates a meter and a feature bound to that meter via v1 endpoints; captures IDs and asserts responses.
Smoke Test - Plan Draft with Flat Rate (v3)
e2e/productcatalog_smoke_v3_test.go
Creates a draft v3 plan initially containing a single flat rate card.
Smoke Test - Add Usage & Graduated Rate Cards
e2e/productcatalog_smoke_v3_test.go
Updates the draft plan to include flat, usage (feature-referenced), and graduated rate cards and validates plan state.
Smoke Test - Inject Defective Rate Card & Validate
e2e/productcatalog_smoke_v3_test.go
Introduces a defective rate card to create validation_errors, verifies publish is blocked and errors surface.
Smoke Test - Remove Defect & Re-validate
e2e/productcatalog_smoke_v3_test.go
Removes the defective rate card, confirms validation_errors clear, and that publish can proceed.
Smoke Test - Addon Lifecycle & Attachment
e2e/productcatalog_smoke_v3_test.go
Creates a draft addon, publishes it, attaches it to the plan, and verifies the addon remains attached after plan publish.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • openmeterio/openmeter#4268: Introduces rate-card validation behavior (feature references / metered feature rules) that these E2E tests exercise.

Suggested labels

release-note/ignore

Suggested reviewers

  • chrisgacsal
🚥 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 summarizes the main change: adding a cross-cutting smoke test for product catalog flow, which directly aligns with the TestV3ProductCatalogSmoke function and test scenarios added.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
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 chore/add-baseline-e2e-test-flow

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.

@rolosp
rolosp force-pushed the chore/add-baseline-e2e-test-flow branch from 3cb3dc0 to aaf74e8 Compare May 6, 2026 09:51
@rolosp
rolosp marked this pull request as ready for review May 6, 2026 09:51
@rolosp
rolosp requested a review from a team as a code owner May 6, 2026 09:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)

46-237: ⚡ Quick win

Stop the parent test after a setup subtest fails.

These t.Run blocks all share outer state, so an early require.* failure only stops that one subtest and the rest keep running with empty planID/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 from t.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

📥 Commits

Reviewing files that changed from the base of the PR and between 80d86ac and aaf74e8.

📒 Files selected for processing (3)
  • e2e/helpers.go
  • e2e/productcatalog_smoke_v3_test.go
  • e2e/v3helpers_test.go

@rolosp rolosp added the release-note/misc Miscellaneous changes label May 6, 2026
@rolosp rolosp changed the title test: add a smoke test for a large product catalog flow test: add a smoke test for a meter and product catalog flow May 6, 2026
@rolosp rolosp changed the title test: add a smoke test for a meter and product catalog flow test: add cross cutting smoke test for a product catalog flow May 6, 2026
@rolosp
rolosp force-pushed the chore/add-baseline-e2e-test-flow branch from aaf74e8 to c9b4947 Compare May 6, 2026 12:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)

30-31: ⚡ Quick win

Bind the client to the current subtest’s t.

Right now newV3Client(t) captures the parent test handle once, so every require.NoError(...) and t.Context() inside v3Client.do/decodeTyped is scoped to the outer test, not the active subtest. Re-creating the client inside each t.Run(...), or rebinding it per subtest, will keep failures and cancellation attached to the right test. As per coding guidelines, **/*_test.go: prefer t.Context() when a testing.T or testing.TB is available instead of using context.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

📥 Commits

Reviewing files that changed from the base of the PR and between aaf74e8 and c9b4947.

📒 Files selected for processing (2)
  • e2e/productcatalog_smoke_v3_test.go
  • e2e/v3helpers_test.go

Comment thread e2e/productcatalog_smoke_v3_test.go Resolved
Comment thread e2e/productcatalog_smoke_v3_test.go Resolved
@rolosp
rolosp force-pushed the chore/add-baseline-e2e-test-flow branch from c9b4947 to f0ea4c6 Compare May 6, 2026 12:42
tothandras
tothandras previously approved these changes May 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
e2e/productcatalog_smoke_v3_test.go (1)

30-272: 💤 Low value

Solid 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 its Feature binding (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 the var (...) block at line 37-44 alongside planID/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 mutate validRateCards via shared backing array), but slices.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

📥 Commits

Reviewing files that changed from the base of the PR and between f0ea4c6 and 4068dc2.

📒 Files selected for processing (2)
  • e2e/productcatalog_smoke_v3_test.go
  • e2e/v3helpers_test.go

@tothandras
tothandras merged commit c72f53d into main May 6, 2026
28 checks passed
@tothandras
tothandras deleted the chore/add-baseline-e2e-test-flow branch May 6, 2026 14:13

This branch was previously deployed

1 inactive deployment
dev — 4068dc2c Deployed May 6, 2026 by rolosp via Migration Checks #14138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants