Skip to content

feat(seeder): expand dev data variety for full feature coverage#30

Merged
tkahng merged 6 commits into
mainfrom
fix/seeder-data-variety
May 26, 2026
Merged

feat(seeder): expand dev data variety for full feature coverage#30
tkahng merged 6 commits into
mainfrom
fix/seeder-data-variety

Conversation

@tkahng

@tkahng tkahng commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses gaps identified in a seeder audit where several feature areas had no data to exercise them during development.

Products

  • 8 new ACTIVE products across new categories (soil, irrigation, pest control, fertiliser), bringing active count to 22 so storefront pagination is reachable
  • 1 DRAFT product and 1 ARCHIVED product for admin status filter testing; neither assigned to a collection

Inventory

  • Out-of-stock item: hose nozzle (qty = 0, DENY policy) — tests add-to-cart blocking
  • Low-stock item: neem oil concentrate (qty = 3) — tests low-stock indicators
  • Inventory transaction ledger populated with RECEIVED, SOLD, DAMAGED, ADJUSTED entries

Users & orders

  • Two new customers: [email protected] and [email protected] (password: password)
  • Alice: PAID order with WELCOME10 applied (discount_id + discount_amount set, used_count incremented)
  • Alice: PARTIALLY_FULFILLED order with one fulfillment (status SHIPPED) for one of two items
  • Bob: PAID order

Return requests

  • APPROVED (Alice, EXCHANGE resolution) and REJECTED (Bob, staff declined)
  • All four statuses — PENDING, COMPLETED, APPROVED, REJECTED — now present

B2B

  • REJECTED and EXPIRED quote statuses added (all 6 used statuses covered)
  • Company approval rule: orders ≥ $500 require MANAGER approval
  • Two departments (Procurement, Retail); B2B manager assigned to Procurement

Discounts

  • FREESHIP50: FREE_SHIPPING type, min order $50 — third discount type now seeded

Reviews

  • 1-star (Alice, verified) and 2-star (Bob, unverified) reviews
  • One HIDDEN review (B2B member, moderation testing)
  • Reviews now span 4 distinct users

Tests

Updated: product/collection count assertions, image count assertions, order status coverage, user list, discount code list, inventory level floor.

New tests for every gap category: out-of-stock, low-stock, inventory transactions, discounted order, PARTIALLY_FULFILLED, all return statuses, all quote statuses, approval rules, departments, review rating distribution, HIDDEN review, FREE_SHIPPING discount.

tkahng added 4 commits May 26, 2026 07:01
…d products

The home page fetches the 4 newest products (ORDER BY created_at DESC).
Quote-only products (null price) were seeded last, giving them the highest
created_at timestamps and causing all 4 front-page slots to show items with
no price. Seeding them first ensures priced products are the newest and appear
on the home page instead.

Adds a test that asserts none of the 4 newest products have a null price.
Adds the following to close gaps identified in the seeder audit:

Products
- 8 new ACTIVE products (seed starting mix, raised bed soil, kneeling pad,
  plant labels, drip irrigation kit, hose nozzle, neem oil, tomato fertiliser)
  bringing active count to 22 — storefront pagination is now exercisable
- 1 DRAFT product (bamboo grow stakes) and 1 ARCHIVED product (copper
  watering can); neither is assigned to a collection

Inventory
- Out-of-stock item: adjustable hose nozzle (qty = 0, DENY policy)
- Low-stock item: neem oil concentrate (qty = 3)
- Inventory transaction ledger seeded with RECEIVED, SOLD, DAMAGED,
  and ADJUSTED entries for four SKUs

Users & orders
- Two new customers: [email protected] and [email protected] (password: password)
- Alice order 1: PAID with WELCOME10 discount applied (discount_id +
  discount_amount set, used_count incremented)
- Alice order 2: PARTIALLY_FULFILLED with one item shipped (fulfillment
  status SHIPPED, one fulfillment item)
- Bob order 1: PAID (gloves + terracotta pot)

Return requests
- APPROVED return (Alice, EXCHANGE resolution — wrong item)
- REJECTED return (Bob, staff declined damage claim)
  All four statuses (PENDING, COMPLETED, APPROVED, REJECTED) now present

B2B
- 2 additional quote statuses: REJECTED and EXPIRED (all 6 used statuses covered)
- Company approval rule: orders >= $500 require MANAGER approval
- 2 departments: Procurement and Retail; B2B manager assigned to Procurement

Discounts
- FREESHIP50: FREE_SHIPPING type, min order $50 — covers the third
  discount type that was previously unseeded

Reviews
- Alice: 1-star on sunflower mix (verified purchase)
- Bob: 2-star on lavender (unverified)
- B2B member: 1-star on glazed planter, status HIDDEN (moderation testing)

Tests
- Updated row-count assertions (products 14→24, collection_products 14→22)
- Updated image counts (product images 31→47, blobs 35→51)
- New assertions for every gap category above
- Fixed front-page price test to operate on 4 newest products (not
  4 variant rows from a joined query)
The payment reconciliation scheduler queries for PENDING_PAYMENT orders
where stripe_session_id IS NOT NULL and created_at < 15 minutes ago.
The seeded order was 1 hour old with a fake session ID, causing the
scheduler to call Stripe.retrieveSession every 10 minutes in local dev
and log a warning on every run.

Nulling the session ID represents a valid state (checkout not yet started)
and keeps the scheduler from touching it. A test asserts no seeded
PENDING_PAYMENT order carries a stripe_session_id.
stripe_payment_intent_id was set on every PAID/FULFILLED/REFUNDED/PARTIALLY_FULFILLED
order using placeholder values (pi_test_seed_*). In the demo environment this would
cause adminRefundOrder() to call Stripe.createRefund() with an invalid ID the moment
an admin clicks Refund — resulting in a live Stripe API error.

Drop stripe_payment_intent_id from all order INSERTs. stripe_session_id is kept where
needed as a lookup key in seedAdditionalReturnRequests(); it carries no Stripe API risk
since syncPaymentFromStripe() guards against non-PENDING_PAYMENT status.

Add test: seeder_noPaidOrderHasStripePaymentIntentId asserts no seeded order has a
stripe_payment_intent_id set.
tkahng added 2 commits May 26, 2026 08:13
Bob's order was seeded with firstVariantOf(gloves) which resolves to
SKU-G-S-GRN (Small/Forest Green — the first inserted variant).
The return-request lookup queried by SKU-G-M-GRN, returning 0 rows
and throwing EmptyResultDataAccessException at startup.

Use variantIdBySku("SKU-G-M-GRN") in seedAdditionalOrders so the
order item and the return lookup reference the same variant.
Four tests had stale expected values that didn't account for the
additional seeding methods added in this branch:

- seeder_b2bQuoteRequestStatusesPresent: add REJECTED and EXPIRED
- seeder_productReviewsExist: 6→8 (two new PUBLISHED reviews)
- seeder_verifiedPurchaseReviewsPresent: 5→6 (Alice verified purchase)
- seeder_returnRequestStatusesPresent: add APPROVED and REJECTED
@tkahng tkahng merged commit 0494158 into main May 26, 2026
3 checks passed
@tkahng tkahng deleted the fix/seeder-data-variety branch May 29, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant