Sort the list pages on "Min side" #147
Merged
+619
−73
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.
Closes #129
What
/mine/favoritter,/mine/vil-proveand/mine/har-provdcan be sorted with a «Sorter etter» select:?sortering=sortNEWESTdin-domOWN_RATINGbest-vurdertCOMMUNITY_RATINGnavnNAME/mine/dommer, so it survives a reload. An unknown value falls back to the default.docs/api.md).Also fixes lost arrow-key presses in the order select on
/mine/dommer(see below).Builds on the API from #128.
How
listSort.ts: the options, their labels and their URL values, with parse and serialise functions.MyListPageandMyReviewsPagekeep the order in state, and read it from the URL when the page opens. React Router updates the URL in a transition, so a select bound only to the URL was reset by React until then. Quick arrow-key presses were lost, and the Playwright test caught it. On the list pages,key={info.slug}gives each list its own state.keyArgsforUser.winesis now['list', 'sort', 'minRating'], so each order is cached apart.useMyWineListleaves outNEWEST(the API default). The default order then stays in the same cache entry as «Min side», and its first four wines still show at once.updateListPages: already handled every order of a list. A wine taken off a list leaves every order, and a list a wine joined is fetched again in every order. This is now covered by a test.Tests
MyListPage.test.tsx:apollo.test.ts: each order is cached apart, and a list without a sort is stored where «Min side» finds it.listCache.test.ts: every order of a list is updated.listSort.test.ts: the URL values round-trip, and they match what the wine page's back link accepts.e2e/lists.spec.ts: the arrow keys change the order (three presses in a row), the order survives a reload, back goes to «Min side», and no axe violations. The fake API can now sort by name.e2e/profile.spec.ts: on/mine/dommer, down and up in a row ends on «Nyeste først», the order is kept in the URL and survives a reload, and back goes to «Min side». The fake API now returns two reviews for/mine/dommer, in the order asked for. No other e2e test uses that page.Docs
docs/api.md: the «Min side» table has the orders and their URL values, there is a row forlistSort.ts, andkeyArgsis updated.docs/manual-testing.md: five new steps.How to test
npm run check, andnpx playwright test e2e/lists.spec.ts e2e/profile.spec.tsinfrontend/.demoand open «Se alle … du har prøvd»./mine/dommer, press the arrow keys quickly in the select. No press is lost.Review notes
MyPage.test.tsx), and maybe others, can time out on a busy machine, as it runs axe twice in one test. It passes innpm run check, and can be handled in a separate PR.AI
Claude used to create code and tests based on prompt, manually tested and checked that npm run check and npm run e2e goes through. Claude created PR text for easy summary, but have gone over and made some updates manually.