diff --git a/README.md b/README.md index ff425db..69cb764 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,8 @@ yet, depending on when the review is made. | Wine detail page | Done | Facts, food pairing, the shared average, the rating distribution and student reviews at `/vin/:id` | | Student reviews (stored in the database) | Done | 0.5–5 stars and an optional comment, saved and shown at once on the wine page. They count in the shared average | | «Mine anmeldelser» page | Done | Shows the «Vil prøve» list. Own reviews come with login in the interface | -| User accounts in the backend | Done | Register, login, logout and «who am I», with sessions in PostgreSQL. Not in the interface yet | +| User accounts | Done | Register, log in and log out at `/konto`, with sessions in PostgreSQL and an `httpOnly` cookie | +| Reviews tied to accounts | Done | Writing a review requires login, and the username is shown as the author. Older anonymous reviews are kept as «Anonym student» | | Larger dataset on the VM | Done | Slim version: 1 007 wines and 150 000 ratings | | Continuous integration (CI) | Not yet started | Needs a self-hosted runner | @@ -110,8 +111,8 @@ This section describes what users can do. "Backend" means the API supports the f | Student reviews | Done | Done | 0.5–5 stars in half stars and an optional comment, stored in PostgreSQL. Hover the left half of a star for half a star, or use the arrow keys. The page updates at once without a reload. One review per student per wine | | Shared average and distribution | Done | Done | Student reviews count in the average together with X-Wines, also when sorting and filtering. The wine page shows how many gave each score | | Wishlist ("Vil prøve") | Planned | Done | Saved in the browser and shown on «Mine anmeldelser». Moves to the backend when login is in the interface | -| User accounts | Done | Planned | Register, login, logout and `me` in the API. Sessions in PostgreSQL with an `httpOnly` cookie. The interface comes next | -| Anonymous ID | Done | Done | Reviews use a random ID stored in the browser until login is in the interface | +| User accounts | Done | Done | Register, log in and log out at `/konto`. Errors are shown next to the field they are about, in Norwegian. Sessions in PostgreSQL with an `httpOnly` cookie | +| Reviews with login | Done | Done | Only logged-in users can write, change or delete a review, and only their own. Visitors see the reviews and a link to log in, which brings them back to the wine. `User.reviews` lists a user's reviews for the profile page | ## Architecture and technology choices @@ -246,7 +247,7 @@ We follow the principle from the course: measure, set a budget and show the numb ### Technical choices - Code splitting per page with `React.lazy`. The landing page does not load the code for search and the detail page. -- 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. +- The landing page loads all its content in one GraphQL query, with only the fields it shows. The only other request is `Me` (who is logged in), which every page shares and Apollo caches. An end-to-end test checks both. - Search, filtering, sorting and pagination run in the database. A page returns at most 50 wines. - The rating average is stored on the wine, so no query counts millions of rows. - DataLoader batches the lookups a page needs, so a page of wines runs one query per field instead of one per wine. @@ -278,7 +279,7 @@ and because the test was run over VPN. These are the "before" numbers. Compressi | 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, the wine page with reviews, the wishlist page, loading, empty and error states, and axe on each component | 269 in 28 files | | Unit (backend) | Vitest | Parsing of X-Wines CSV files, building SQL for search, filtering and sorting, review validation, and passwords, sessions and rate limiting | 92 in 11 files (6 skipped: they need a test database) | | End-to-end | Playwright with axe-core, desktop and mobile | Landing, search and detail pages with a stubbed API: one request per page load, debounce, search, filters, sorting, load more, reload, back button, from search to wine and back, the filter dialog on mobile, no hits, wine not found, API errors, keyboard use, reflow at 320 px, and no axe violations (WCAG 2.1 AA) | 50 (24 tests in 2 browser projects, and 2 for mobile only) | -| API | Not set up yet | Resolvers against a test database: search, filtering, sorting and pagination | Planned | +| API | Vitest with Apollo Server (`executeOperation`) | Login and reviews through real GraphQL requests, with a fake browser per user that keeps the cookie. The review tests run against a separate test database (`TEST_DATABASE_URL`), see [API](docs/api.md#database-tests) | Count again | Counted on 16 November 2026. The skipped backend tests run the user store against a real database, and need `TEST_DATABASE_URL`. @@ -367,7 +368,9 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a ### Next: towards the final submission -- [ ] Login in the interface: forms for register and login, and reviews tied to the account instead of the anonymous ID. +- [x] Login in the interface: forms for register and login, and reviews tied to the account instead of the anonymous ID. +- [ ] Favourites with a top 4, «Vil prøve» and «Har prøvd» stored per user. +- [ ] Profile page with the top 4, the lists and the user's reviews. - [ ] Wishlist stored in the backend, so it follows the user between devices. - [ ] Calmer landing page: less text, a separate «Om» page, and a burger menu on mobile. - [ ] CI, an enforced coverage threshold, and eslint-plugin-jsx-a11y. @@ -391,7 +394,8 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a - 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. - The database and its user are still called `vinmonopolet` and `vinmonopolet_app`, from before we switched dataset. Renaming would mean everyone rebuilding their database, so we kept the names. -- Anyone can create any number of anonymous IDs, so there is nothing stopping someone from leaving many reviews. Login will fix that. +- Reviews from before login have no account and are shown as «Anonym student». The old `student` table they belong to will be removed later. +- One e2e test, checking «Rødvin» in the filter dialog on mobile, fails since the error handling changes. Tracked in its own issue.