From ed81811765a0a956ea44d6d3b999de06f45de924 Mon Sep 17 00:00:00 2001 From: Oscar Bakkeng Date: Sat, 7 Nov 2026 17:38:54 +0100 Subject: [PATCH 1/4] fix(search): make the load more border visible in dark mode The brand colour gave too little contrast against the dark background. Co-Authored-By: Claude Opus 5.5 --- frontend/src/features/search/SearchView.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/features/search/SearchView.module.css b/frontend/src/features/search/SearchView.module.css index 1b21cbf..cfa7ace 100644 --- a/frontend/src/features/search/SearchView.module.css +++ b/frontend/src/features/search/SearchView.module.css @@ -40,7 +40,7 @@ .moreButton { min-height: var(--tap-target); padding: 0 var(--space-6); - border: 2px solid var(--color-brand); + border: 2px solid var(--color-link); border-radius: var(--radius-pill); background: transparent; color: var(--color-text); From e750841135e11ce050166a48f8d0d973830e1e1c Mon Sep 17 00:00:00 2001 From: Oscar Bakkeng Date: Sat, 7 Nov 2026 17:38:54 +0100 Subject: [PATCH 2/4] test(e2e): wait for the skip link before pressing Tab Tab could run before React had rendered the link, which made the test fail now and then. Co-Authored-By: Claude Opus 5.5 --- frontend/e2e/landing.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/e2e/landing.spec.ts b/frontend/e2e/landing.spec.ts index 19ddd6d..876c48a 100644 --- a/frontend/e2e/landing.spec.ts +++ b/frontend/e2e/landing.spec.ts @@ -67,8 +67,10 @@ test.describe('Forsiden', () => { }); test('kan brukes med bare tastatur: hopp-lenke og søk', async ({ page }) => { + const skipLink = page.getByRole('link', { name: 'Hopp til hovedinnhold' }); + await expect(skipLink).toBeAttached(); // Tab before React has rendered would do nothing. await page.keyboard.press('Tab'); - await expect(page.getByRole('link', { name: 'Hopp til hovedinnhold' })).toBeFocused(); + await expect(skipLink).toBeFocused(); }); test('har ingen axe-brudd (WCAG 2.1 AA)', async ({ page }) => { From b6c46d931156e9b58baf35154ff498a2dbe97f61 Mon Sep 17 00:00:00 2001 From: Oscar Bakkeng Date: Sat, 7 Nov 2026 17:38:54 +0100 Subject: [PATCH 3/4] feat(wine): add wine detail page Shows facts, food pairing and the community rating in Norwegian, with grapes and food linking to the search. The wine card passes along where the user came from, so the back link returns to the same search. Ids that cannot match a wine give "Fant ikke vinen" without a request. Co-Authored-By: Claude Opus 5.5 --- frontend/e2e/wine.spec.ts | 131 +++++++++ frontend/src/app/App.test.tsx | 2 +- frontend/src/app/App.tsx | 6 +- frontend/src/components/ui/HeartIcon.tsx | 8 + frontend/src/components/ui/WineCard.test.tsx | 17 ++ frontend/src/components/ui/WineCard.tsx | 10 +- frontend/src/components/ui/index.ts | 1 + frontend/src/features/wine/WinePage.test.tsx | 250 ++++++++++++++++++ frontend/src/features/wine/WinePage.tsx | 14 + .../src/features/wine/WineView.module.css | 168 ++++++++++++ frontend/src/features/wine/WineView.tsx | 156 +++++++++++ .../features/wine/api/toWineDetails.test.ts | 89 +++++++ .../src/features/wine/api/toWineDetails.ts | 47 ++++ frontend/src/features/wine/api/useWine.ts | 32 +++ frontend/src/features/wine/api/wineQuery.ts | 25 ++ frontend/src/lib/format.test.ts | 20 ++ frontend/src/lib/format.ts | 17 ++ frontend/src/lib/types.ts | 14 + frontend/src/lib/wineLabels.test.ts | 36 +++ frontend/src/lib/wineLabels.ts | 73 +++++ 20 files changed, 1106 insertions(+), 10 deletions(-) create mode 100644 frontend/e2e/wine.spec.ts create mode 100644 frontend/src/components/ui/HeartIcon.tsx create mode 100644 frontend/src/features/wine/WinePage.test.tsx create mode 100644 frontend/src/features/wine/WinePage.tsx create mode 100644 frontend/src/features/wine/WineView.module.css create mode 100644 frontend/src/features/wine/WineView.tsx create mode 100644 frontend/src/features/wine/api/toWineDetails.test.ts create mode 100644 frontend/src/features/wine/api/toWineDetails.ts create mode 100644 frontend/src/features/wine/api/useWine.ts create mode 100644 frontend/src/features/wine/api/wineQuery.ts create mode 100644 frontend/src/lib/wineLabels.test.ts create mode 100644 frontend/src/lib/wineLabels.ts diff --git a/frontend/e2e/wine.spec.ts b/frontend/e2e/wine.spec.ts new file mode 100644 index 0000000..43011c9 --- /dev/null +++ b/frontend/e2e/wine.spec.ts @@ -0,0 +1,131 @@ +import AxeBuilder from '@axe-core/playwright'; +import { expect, test, type Page } from '@playwright/test'; + +/* E2E for the detail page. Runs against `vite preview` with a stubbed GraphQL API. */ +const wine = { + __typename: 'Wine', + id: '100062', + name: 'Origem Merlot', + type: 'Red', + grapes: ['Merlot'], + country: 'Brazil', + countryCode: 'BR', + regionName: 'Vale dos Vinhedos', + wineryName: 'Casa Valduga', + website: 'http://www.casavalduga.com.br', + elaborate: 'Varietal/100%', + harmonize: ['Beef', 'Pizza'], + abv: 13, + body: 'Full-bodied', + acidity: 'Medium', + vintages: [2020, 2005], + communityRating: 4.12, + communityRatingCount: 12, +}; + +const searchResult = { + data: { + wines: { + __typename: 'WineConnection', + totalCount: 1, + edges: [{ __typename: 'WineEdge', cursor: '1', node: wine }], + pageInfo: { __typename: 'PageInfo', hasNextPage: false, endCursor: '1' }, + }, + }, +}; + +async function stubApi(page: Page) { + await page.route('**/project2/graphql', (route) => { + const { operationName, variables } = route.request().postDataJSON() as { + operationName: string; + variables: { id?: string }; + }; + if (operationName === 'Wine') { + return route.fulfill({ + json: { data: { wine: variables.id === wine.id ? wine : null } }, + }); + } + return route.fulfill({ json: searchResult }); + }); +} + +test.describe('Detaljsiden', () => { + test('fra søk til vin og tilbake til samme søk', async ({ page }) => { + await stubApi(page); + await page.goto('./sok?q=merlot'); + + await page.getByRole('link', { name: 'Origem Merlot' }).click(); + + const heading = page.getByRole('heading', { level: 1, name: 'Origem Merlot' }); + await expect(heading).toBeFocused(); + await expect(page).toHaveTitle(/Origem Merlot/); + await expect(page.getByText('Rødvin · Brasil, Vale dos Vinhedos')).toBeVisible(); + + await page.getByRole('link', { name: 'Tilbake til søket' }).click(); + await expect(page).toHaveURL(/\/sok\?q=merlot$/); + await expect(page.getByRole('searchbox', { name: 'Søk etter vin' })).toHaveValue('merlot'); + }); + + test('tilbakelenken overlever omlasting', async ({ page }) => { + await stubApi(page); + await page.goto('./sok?q=merlot'); + await page.getByRole('link', { name: 'Origem Merlot' }).click(); + await expect(page.getByRole('link', { name: 'Tilbake til søket' })).toBeVisible(); + + await page.reload(); + + await expect(page.getByRole('link', { name: 'Tilbake til søket' })).toHaveAttribute( + 'href', + /\/sok\?q=merlot$/, + ); + }); + + test('«Passer til» starter et søk på matrett', async ({ page }) => { + await stubApi(page); + await page.goto('./vin/100062'); + + await page.getByRole('link', { name: 'Storfe' }).click(); + + await expect(page).toHaveURL(/\/sok\?mat=Beef$/); + }); + + test('husker «Vil prøve» etter omlasting', async ({ page }) => { + await stubApi(page); + await page.goto('./vin/100062'); + const button = page.getByRole('button', { name: 'Vil prøve' }); + + await button.click(); + await expect(button).toHaveAttribute('aria-pressed', 'true'); + await page.reload(); + + await expect(button).toHaveAttribute('aria-pressed', 'true'); + }); + + test('forklarer når vinen ikke finnes', async ({ page }) => { + await stubApi(page); + await page.goto('./vin/1'); + await expect(page.getByRole('heading', { level: 1, name: 'Fant ikke vinen' })).toBeVisible(); + await expect(page.getByRole('link', { name: 'Utforsk alle viner' })).toBeVisible(); + }); + + test('har ingen axe-brudd (WCAG 2.1 AA)', async ({ page }) => { + await stubApi(page); + await page.goto('./vin/100062'); + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Origem Merlot'); + const axe = await new AxeBuilder({ page }) + .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']) + .analyze(); + expect(axe.violations).toEqual([]); + }); + + test('har ingen horisontal scroll ved 320 px', async ({ page }) => { + await stubApi(page); + await page.setViewportSize({ width: 320, height: 640 }); + await page.goto('./vin/100062'); + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Origem Merlot'); + const overflow = await page.evaluate( + () => document.documentElement.scrollWidth > window.innerWidth, + ); + expect(overflow).toBe(false); + }); +}); diff --git a/frontend/src/app/App.test.tsx b/frontend/src/app/App.test.tsx index 829ca82..64b0663 100644 --- a/frontend/src/app/App.test.tsx +++ b/frontend/src/app/App.test.tsx @@ -22,7 +22,7 @@ function renderRoute(route: string) { describe('AppRoutes', () => { it.each([ ['/finnes-ikke', 'Fant ikke siden'], - ['/vin/1', 'Vin'], + ['/vin/abc', 'Fant ikke vinen'], ['/mine', 'Mine anmeldelser'], ])('shows the right page for %s', async (route, heading) => { renderRoute(route); diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index d0fc9c8..c1b1b76 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -6,6 +6,7 @@ import PlaceholderPage from './PlaceholderPage'; // Kodesplitting per rute: forsiden laster ikke koden for søk og detaljside. const LandingPage = lazy(() => import('../features/landing/LandingPage')); const SearchPage = lazy(() => import('../features/search/SearchPage')); +const WinePage = lazy(() => import('../features/wine/WinePage')); /** BASE_URL kommer fra `base` i vite.config.ts (f.eks. «/project2/»). */ const basename = import.meta.env.BASE_URL.replace(/\/$/, '') || '/'; @@ -16,10 +17,7 @@ export function AppRoutes() { }> } /> } /> - } - /> + } />