diff --git a/README.md b/README.md index a1f70e8..8fb22a9 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Submission 3 should be the first complete prototype, with search, browsing, sort | Frontend deployed on the VM | Done | Deep links such as `/project2/sok` work on reload | | Backend running on the VM | Done | Started with `nohup`, see [VM guide](docs/vm.md) | | Apollo Client in the frontend | Done | | -| Search page with results | Next | Placeholder page at `/sok` | -| Filtering and sorting in the user interface | Planned | Already supported by the API | +| Search page with results | Done | Search with debounce, number of hits and "Last inn flere" at `/sok` | +| Filtering and sorting in the user interface | Next | The API and URL filters work, but the panel is missing | | Wine detail page | Planned | Placeholder page at `/vin/:id` | | Student reviews (stored in the database) | Planned | | | Larger dataset on the VM | Planned | | @@ -98,11 +98,11 @@ This section describes what users can do. "Backend" means the API supports the f | Feature | Backend | UI | Description | |---|---|---|---| -| Search | Done | Planned | Ignores case and accents. Matches name, winery, region and grapes | +| Search | Done | Done | Ignores case and accents. Matches name, winery, region and grapes as one phrase. Waits 300 ms after the last key press | | Filtering | Done | Planned | Type, country, grapes, food pairing, minimum rating and alcohol range. Shows the number of wines for each option | | Sorting | Done | Planned | Top rated, most rated, name and alcohol. Always sorts the whole result, not only the loaded page | -| Pagination | Done | Planned | Cursor-based. The user loads more results with a button, not with infinite scroll | -| Search state in the URL | Not needed | Done | `?q=&type=&land=&drue=&mat=&sort=`. Survives reloads and works with the back button | +| Pagination | Done | Done | Cursor-based. The user loads more results with a button, not with infinite scroll. Focus moves to the first new wine | +| Search state in the URL | Not needed | Done | `?q=&type=&land=&drue=&mat=&sort=`. Survives reloads. Typing replaces the history entry, so the back button leaves the search instead of stepping through every word | | Wine detail page | Done (`wine(id)`) | Planned | Name, winery, region, grapes, alcohol, food pairing, both ratings, and the latest student reviews | | Student reviews | Planned | Planned | Die roll from 1 to 6 and an optional comment, stored in PostgreSQL, the new rating is shown at once without a reload (Apollo cache update) | | Wishlist ("Vil prøve") | Planned | Done, stored in the browser | Moves to the backend when users and reviews are in place | @@ -134,8 +134,9 @@ Each row explains what we chose, why, and what else we considered. Added as the | Styling | CSS Modules and design tokens in `styles/tokens.css` | No runtime cost and no extra dependency. Tokens make dark mode and consistent colours easy | Tailwind, styled-components | | API | GraphQL with Apollo Server on Express | Required by the course. The client asks only for the fields it shows, which saves data | REST | | Database | PostgreSQL with the `pg_trgm` extension | Fast text search with `ILIKE` also on many rows. Already available on the VM | MongoDB, SQLite | -| Pagination | Cursor-based | Stable when sorting. No duplicates or gaps when new data is added | Offset-based | +| Pagination | Cursor-based, pages merged in the Apollo cache | Stable when sorting. No duplicates or gaps when new data is added | Offset-based | | Search, filtering and sorting | In the database | Scales to large datasets. The frontend never loads the whole catalogue | Filtering in the browser | +| Search state flow | Field text in React state, debounced into the URL, and the query reads only the URL | One source of truth for the search, so reload, shared links and the back button all give the same result | Sending a request directly from the input | | Testing | Vitest, React Testing Library, Playwright, axe | Vitest shares configuration with Vite. Playwright tests real browsers, also on mobile | Jest, Cypress | | Deployment | Apache serves static files, the backend runs with `nohup` | Matches the course VM | systemd service (possible improvement) | @@ -197,7 +198,7 @@ Our goal is WCAG 2.1 level AA. We design for users with reduced vision, hearing, ### Some known gaps -- The search page, filters and detail page are not built yet, so they are not tested. +- The filter panel and detail page are not built yet, so they are not tested. - We have not tested with a screen reader yet. - eslint-plugin-jsx-a11y is not set up yet. - The filter panel on mobile will need a dialog with correct focus handling. This is planned. @@ -219,16 +220,16 @@ We follow the principle from the course: measure, set a budget and show the numb - The landing page loads all its data in one GraphQL query, with only the fields it shows. An end-to-end test checks that only one request is sent. - Search, filtering, sorting and pagination run in the database. A page returns at most 50 wines. - The Apollo cache, so we do not fetch the same data twice. +- Debounce on the search field (300 ms). An end-to-end test checks that a whole word sends only one search. **Planned:** -- Debounce on the search field (about 300 ms), so we do not send a request for every key press. - Compression (gzip or Brotli) and cache headers in Apache. ### Budget and measurements | Metric | Budget | Measured | Date | How we measure | |---|---|---|---|---| -| JavaScript on the landing page (gzip) | Less than 150 kB | 152,82 kB (over budget after adding Apollo Client) | 6 Nov 2026 | Sum of the gzip sizes from `npm run build` for the files the landing page loads | +| JavaScript on the landing page (gzip) | Less than 150 kB | 154,01 kB (over budget after adding Apollo Client) | 6 Nov 2026 | Sum of the gzip sizes from `npm run build` for the files the landing page loads | | Data transferred when loading the landing page | Less than 300 kB | Not measured yet | | Chrome DevTools, Network tab, cache disabled, on the VM | | Data transferred in a fixed search scenario | Less than 500 kB | Not measured yet | | Same method. Needs the search page | | Lighthouse (mobile) | Performance at least 90, accessibility 100 | Performance 39, accessibility 100, best practices 100, SEO 100 | 30 Oct 2026 | Lighthouse in Chrome DevTools, incognito, against the VM | @@ -242,18 +243,16 @@ and because the test was run over VPN. These are the "before" numbers. We will m | Level | Tools | What we test | Number of tests | |---|---|---|---| -| Unit and components (frontend) | Vitest, React Testing Library, user-event, vitest-axe | URL parameters, formatting, mapping of API data, data hooks, components, the landing page, loading, empty and error states, and axe on each component | 70 | +| Unit and components (frontend) | Vitest, React Testing Library, user-event, vitest-axe | URL parameters, formatting, mapping of API data, data hooks, components, the landing page, loading, empty and error states, and axe on each component | 134 | | Unit (backend) | Vitest | Parsing of X-Wines CSV files, and building SQL for search, filtering and sorting | 2 test files | -| End-to-end | Playwright with axe-core, desktop and mobile | One GraphQL request for the landing page (stubbed API), search from the landing page, keyboard use, reflow at 320 px, and no axe violations (WCAG 2.1 AA) | 12 (6 tests in 2 browser projects) | +| End-to-end | Playwright with axe-core, desktop and mobile | Landing page and search page with a stubbed API: one request per page load, debounce, search, load more, reload, back button, no hits, API errors, keyboard use, reflow at 320 px, and no axe violations (WCAG 2.1 AA) | 26 (13 tests in 2 browser projects) | | API | Not set up yet | Resolvers against a test database: search, filtering, sorting and pagination | Planned | Counted on 6 November 2026. -**Coverage (frontend, 6 November 2026):** lines 84.26 %, branches 60.69 %, functions 83.33 %, statements 70.19 %. +**Coverage (frontend, 6 November 2026):** lines 98.32 %, branches 79.6 %, functions 95 %, statements 87.71 %. Vitest enforces a minimum of 80 % for lines, functions and statements and 75 % for branches (`vitest.config.ts`). -The coverage run currently fails these limits. The main reasons are hooks without their own tests -(for example `useWishlist`) and placeholder pages for search and wine details that will be replaced. We will add the missing tests before raising the limits further, and we do not lower the limits to make the run pass. We leave out `main.tsx`, test files, test helpers and mock data, because they contain no application logic. @@ -340,7 +339,7 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a ### Next: complete the beta 1. [x] Add Apollo Client to the frontend, with the endpoint `${import.meta.env.BASE_URL}graphql`. -2. [ ] Search page: search field with debounce, list of results, number of hits, "Last inn flere", and empty and error states. +2. [x] Search page: search field with debounce, list of results, number of hits, "Last inn flere", and empty and error states. 3. [ ] Filter panel with counts from `filterOptions`, and sorting. All choices stored in the URL. 4. [x] Connect the landing page to the backend. 5. [ ] Wine detail page. @@ -358,7 +357,8 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a ### Some known issues - Some documents in `docs/` still describe the old Vinmonopolet plan and the old test endpoint `/api/hello`. They will be updated. -- Frontend test coverage is below our enforced limits (statements 70.19 %, branches 60.69 %). Tests for `useWishlist` and the remaining components are planned. +- Search matches the text as one phrase, so "noir pinot" finds nothing. Country is not part of the search text, because the country filter covers it. +- The cursors in the API hold an offset, which is slower deep into large results. To be solved together with the larger dataset.