-
Notifications
You must be signed in to change notification settings - Fork 0
fix(frontend): standardize dashboard arrow icons (#973) #976
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -146,6 +146,22 @@ describe("CategoriesBrowse", () => { | |||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it("View All link includes an arrow icon (no text arrow)", async () => { | ||||||||||
| mockGetCategoryOverview.mockResolvedValue({ | ||||||||||
| ok: true, | ||||||||||
| data: MOCK_CATEGORIES, | ||||||||||
| }); | ||||||||||
| render(<CategoriesBrowse />, { wrapper: createWrapper() }); | ||||||||||
| await vi.waitFor(() => { | ||||||||||
| const viewAll = screen.getAllByRole("link").find( | ||||||||||
| (l) => l.getAttribute("href") === "/app/categories", | ||||||||||
| ); | ||||||||||
| expect(viewAll).toBeDefined(); | ||||||||||
| expect(viewAll!.querySelector("svg")).toBeInTheDocument(); | ||||||||||
|
||||||||||
| expect(viewAll!.querySelector("svg")).toBeInTheDocument(); | |
| const svgs = viewAll!.querySelectorAll("svg"); | |
| expect(svgs.length).toBe(1); | |
| expect(svgs[0]).toBeInTheDocument(); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||
| import { describe, it, expect, vi } from "vitest"; | ||||||||
| import { render, screen } from "@testing-library/react"; | ||||||||
| import { describe, expect, it, vi } from "vitest"; | ||||||||
| import { NutritionTip } from "./NutritionTip"; | ||||||||
|
|
||||||||
| // ─── Mocks ────────────────────────────────────────────────────────────────── | ||||||||
|
|
@@ -52,6 +52,13 @@ describe("NutritionTip", () => { | |||||||
| expect(link.getAttribute("href")).toMatch(/^\/learn\//); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("learn more link uses icon arrow instead of text arrow", () => { | ||||||||
| render(<NutritionTip />); | ||||||||
| const link = screen.getByText(/Learn more/); | ||||||||
| expect(link.querySelector("svg")).toBeInTheDocument(); | ||||||||
|
||||||||
| expect(link.querySelector("svg")).toBeInTheDocument(); | |
| const svgs = link.querySelectorAll("svg"); | |
| expect(svgs).toHaveLength(1); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |||||||
| const map: Record<string, string> = { | ||||||||
| "dashboard.recentlyViewedCompact": "Recently Viewed", | ||||||||
| "dashboard.viewAll": "View all", | ||||||||
| "dashboard.viewHistory": "View history →", | ||||||||
| "dashboard.viewHistory": "View history", | ||||||||
| }; | ||||||||
| return map[key] ?? key; | ||||||||
| }, | ||||||||
|
|
@@ -20,7 +20,7 @@ | |||||||
|
|
||||||||
| vi.mock("next/image", () => ({ | ||||||||
| // eslint-disable-next-line @next/next/no-img-element | ||||||||
| default: (props: React.ImgHTMLAttributes<HTMLImageElement>) => <img {...props} />, | ||||||||
| })); | ||||||||
|
|
||||||||
| // ─── Helpers ──────────────────────────────────────────────────────────────── | ||||||||
|
|
@@ -133,6 +133,15 @@ | |||||||
| expect(link).toHaveAttribute("href", "/app/search"); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("renders a single arrow icon in View history link (no text arrow)", () => { | ||||||||
| const products = [makeProduct(1)]; | ||||||||
| render(<RecentlyViewed products={products} />); | ||||||||
|
|
||||||||
| const link = screen.getByRole("link", { name: /View history/ }); | ||||||||
| expect(link.querySelector("svg")).toBeInTheDocument(); | ||||||||
|
||||||||
| expect(link.querySelector("svg")).toBeInTheDocument(); | |
| const svgs = link.querySelectorAll("svg"); | |
| expect(svgs).toHaveLength(1); |
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.
dashboard.viewAllis also used byRecentComparisons.tsx(link to/app/compare) which currently does not render an<ArrowRight>icon. After removing the→from this translation, that “View all” link will lose its arrow entirely, reintroducing inconsistency on the dashboard. Consider adding the icon there as well, or splitting the i18n keys so only icon-suffixed links use the arrowless label.