-
Notifications
You must be signed in to change notification settings - Fork 48
Add wishlist support #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Abdul-Haseeb-Kamboh
wants to merge
12
commits into
spree:main
Choose a base branch
from
Abdul-Haseeb-Kamboh:feat/wishlist-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add wishlist support #184
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d3932fe
Add wishlist support
Abdul-Haseeb-Kamboh 55d480e
fix(wishlist): resolve typecheck failures and polish wishlist UX/acce…
Abdul-Haseeb-Kamboh 14477bc
Merge branch 'main' into feat/wishlist-support
Abdul-Haseeb-Kamboh 7362c10
Fix syntax errors
Abdul-Haseeb-Kamboh 438d49f
resolve wishlist item title/image mapping and honor variant media
Abdul-Haseeb-Kamboh 7e6575a
use variant-first image fallback and primary media enrichment
Abdul-Haseeb-Kamboh 40bdbf4
Merge branch 'main' into feat/wishlist-support
Abdul-Haseeb-Kamboh 4556c55
fix(tests): isolate ProductDetails SKU test from wishlist auth context
Abdul-Haseeb-Kamboh 2133aac
use SDK wishlist/product types and remove primary_media fallback
Abdul-Haseeb-Kamboh 2eae62d
Merge remote-tracking branch 'origin/main' into feat/wishlist-support
Abdul-Haseeb-Kamboh 5ac262c
simplify item enrichment for SDK 1.2.1
Abdul-Haseeb-Kamboh 47e2e78
avoid N+1 product calls by expanding items.product
Abdul-Haseeb-Kamboh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { expect, type Page, test } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * Wishlist E2E coverage. | ||
| * | ||
| * 1) Guests are redirected to account sign-in/register when trying to wishlist. | ||
| * 2) Authenticated customers can add and remove wishlist items and see empty state. | ||
| */ | ||
|
|
||
| const BASE = "/us/en"; | ||
|
|
||
| test("guest is redirected to account when clicking wishlist on PDP", async ({ | ||
| page, | ||
| }): Promise<void> => { | ||
| await page.goto(`${BASE}/products`); | ||
|
|
||
| const firstProduct = page.locator('a[href*="/products/"]').first(); | ||
| await expect(firstProduct).toBeVisible({ timeout: 15_000 }); | ||
| await firstProduct.click(); | ||
| await page.waitForURL(/\/products\/[^/]+/); | ||
|
|
||
| const productPath = new URL(page.url()).pathname; | ||
|
|
||
| await page.getByRole("button", { name: /add to wishlist/i }).click(); | ||
|
|
||
| await expect(page).toHaveURL(/\/us\/en\/account\?redirect=/); | ||
|
|
||
| const redirectParam = new URL(page.url()).searchParams.get("redirect"); | ||
| expect(redirectParam).toBe(productPath); | ||
| }); | ||
|
|
||
| test("authenticated user can add and remove a wishlist item", async ({ | ||
| page, | ||
| }): Promise<void> => { | ||
| const email = `wishlist-e2e-${Date.now()}@example.com`; | ||
| const password = "Password123!"; | ||
|
|
||
| await registerUser(page, email, password); | ||
|
|
||
| await page.goto(`${BASE}/products`); | ||
| const firstProduct = page.locator('a[href*="/products/"]').first(); | ||
| await expect(firstProduct).toBeVisible({ timeout: 15_000 }); | ||
| await firstProduct.click(); | ||
| await page.waitForURL(/\/products\/[^/]+/); | ||
|
|
||
| const addButton = page.getByRole("button", { name: /add to wishlist/i }); | ||
| await expect(addButton).toBeVisible(); | ||
| await addButton.click(); | ||
|
|
||
| await expect( | ||
| page.getByRole("button", { | ||
| name: /added to wishlist|remove from wishlist/i, | ||
| }), | ||
| ).toBeVisible({ timeout: 10_000 }); | ||
|
|
||
| await page.goto(`${BASE}/wishlist`); | ||
| await expect( | ||
| page.getByRole("heading", { name: /my wishlist/i }), | ||
| ).toBeVisible(); | ||
|
|
||
| const removeButton = page.getByRole("button", { name: /^remove$/i }).first(); | ||
| await expect(removeButton).toBeVisible(); | ||
| await removeButton.click(); | ||
|
|
||
| await expect( | ||
| page.getByRole("heading", { name: /your wishlist is empty/i }), | ||
| ).toBeVisible({ timeout: 10_000 }); | ||
| }); | ||
|
|
||
| async function registerUser( | ||
| page: Page, | ||
| email: string, | ||
| password: string, | ||
| ): Promise<void> { | ||
| await page.goto(`${BASE}/account/register`); | ||
|
|
||
| await page.getByLabel(/^first name$/i).fill("Wishlist"); | ||
| await page.getByLabel(/^last name$/i).fill("Tester"); | ||
| await page.getByLabel(/^email$/i).fill(email); | ||
| await page.locator("#password").fill(password); | ||
| await page.locator("#passwordConfirmation").fill(password); | ||
|
|
||
| await page.getByRole("checkbox", { name: /i agree to the/i }).check(); | ||
| await page.getByRole("button", { name: /^create account$/i }).click(); | ||
|
|
||
| await expect(page).toHaveURL(/\/us\/en\/account$/); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/app/[country]/[locale]/(storefront)/account/(authenticated)/wishlist/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { WishlistPageContent } from "@/components/wishlist/WishlistPageContent"; | ||
|
|
||
| export default function AccountWishlistPage() { | ||
| return <WishlistPageContent />; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve the guest wishlist flow.
This route is nested under the protected account layout, which redirects unauthenticated
/account/*paths to/account. As a result,WishlistPageContent’s guest sign-in state and itsredirectquery are never reached; guests clicking/wishlist, the header link, or footer link land on the generic account page and lose their destination. Exempt this route from the layout redirect or preserve the wishlist URL when redirecting to sign-in.🤖 Prompt for AI Agents