Replace mall fixture favorites with customer-scoped endpoints, and send signed-out shoppers back to the page they left after sign-in. Co-authored-by: Cursor <cursoragent@cursor.com>
3.1 KiB
3.1 KiB
1. Persistence and backend contract
- 1.1 Add migration
0015_favorites.sqlwith explicit product/shop foreign keys, exactly-one-target check, cascading deletes, customer indexes, and partial unique indexes for each target kind. - 1.2 Add shared discriminated favorite summary/query types and
listFavorites,addProductFavorite,removeProductFavorite,addShopFavorite, andremoveShopFavoritemethods to@vmall/shared. - 1.3 Implement
apps/api/src/modules/favorite/repository, service, DTO, handlers, and module registration with customer-only target-resource routes. - 1.4 Implement visible-target validation, idempotent upserts/deletes, ownership filtering, pagination totals, optional target filtering, and SQL-hydrated product/shop summaries.
2. Backend behavioral proof
- 2.1 Add isolated API integration coverage for exactly-one-target and uniqueness constraints, customer ownership, missing/unavailable targets, repeated add/remove, product/shop listing, target filtering, pagination, and unavailable-target hiding.
- 2.2 Run the focused favorites integration tests and then run
cargo test -p vmall-apitwice to prove list tests remain green against the non-truncated shared test database.
3. Adapter and live-domain wiring
- 3.1 Implement the five favorite client methods in
apps/mall/mock/api.tswith per-session mutable fixture state and the same idempotent/filter/pagination behavior. - 3.2 Add the
favoritesdomain and exact shared-client method picks to Mall API selection and enable it in the default/live runtime configuration. - 3.3 Add or adjust bilingual favorite loading, mutation, and failure strings through the existing Mall locale source without introducing per-page hard-coded copy.
4. Mall favorite surfaces
- 4.1 Replace product-detail local heart state with authenticated filtered lookup and idempotent live add/remove, preserving the detail URL through sign-in and disabling concurrent clicks.
- 4.2 Replace store-detail local favorite state with the same persisted authenticated behavior for shop targets.
- 4.3 Replace
apps/mall/pages/user/favorites.vuefixture joins and local deletion with paginated product/shop API results and persisted removal. - 4.4 Replace buyer-dashboard
MOCK_FAVORITESpreview and count derivation with a bounded live product-favorites query and remove all page-level favorites fixture imports.
5. Verification and tracker cleanup
- 5.1 Seed or create a deterministic customer product and shop favorite, run the API plus Mall, and browser-smoke add, reload persistence, buyer-center listing/removal, store favorite, and anonymous sign-in redirect.
- 5.2 Build all three frontends because the shared API contract changes:
pnpm --filter @vmall/mall build,pnpm --filter @vmall/shop-admin build, andpnpm --filter @vmall/admin build. - 5.3 Mark Favorites implemented in
docs/TBD-marketing.md, update the README mock boundary, check every OpenSpec task, and runopenspec change validate add-favorites --strictplusopenspec validate --all --strict.