Skip to content
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

Redux Toolkit Query #39

Merged
merged 69 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
e9a3a88
Migrate LocalAuthority component from fetch in useEffect() to Redux T…
jg210 Feb 8, 2024
b8e704b
TODO
jg210 Feb 8, 2024
53d10fd
Start to use msw to mock server requests.
jg210 Feb 8, 2024
f5972bb
Fix Authorities.test.tsx by adding Provider for store.
jg210 Feb 8, 2024
7374802
whatwg-fetch caret in package-lock.json
jg210 Feb 8, 2024
8701908
Merge remote-tracking branch 'origin/master' into dev/rtk
jg210 Feb 8, 2024
7675d71
Render App component in a Provider.
jg210 Feb 8, 2024
fd100b4
Remove blank line.
jg210 Feb 8, 2024
7806d82
TODO
jg210 Feb 9, 2024
fe307a5
Use async react testing library method to wait for loading state to g…
jg210 Feb 9, 2024
35f50f5
TODO.
jg210 Feb 9, 2024
9206c95
Fix App.test.tsx. Need to use full URL in unit test, and msw was misc…
jg210 Feb 9, 2024
ac64b29
TODO.
jg210 Feb 9, 2024
158e768
TODO.
jg210 Feb 9, 2024
bf3f05a
Use RTK Query for Establishments too.
jg210 Feb 9, 2024
9205e4c
TODO.
jg210 Feb 9, 2024
87e1761
TODO.
jg210 Feb 9, 2024
51a5e45
Don't need to reset RTK query cache between test cases since new stor…
jg210 Feb 9, 2024
754a2e1
TODO
jg210 Feb 9, 2024
636a65e
Add logging of https://mswjs.io/docs/api/life-cycle-events
jg210 Feb 9, 2024
25721c5
App.test.tsx was failing since expectation inside msw handler was not…
jg210 Feb 9, 2024
ea95175
A better way of handling incorrect localAuthorityId in MSW handler.
jg210 Feb 9, 2024
e0dc25d
TODO.
jg210 Feb 9, 2024
bbbee23
Remove blank line and add comment.
jg210 Feb 9, 2024
39388c4
Remove comma.
jg210 Feb 9, 2024
2992add
TODO
jg210 Feb 9, 2024
60294ca
Update README to mention RTK query.
jg210 Feb 9, 2024
94df946
TODO.
jg210 Feb 10, 2024
8064f3c
Set refetchOnMountOrArgChange to 15 minutes for both endpoints. It do…
jg210 Feb 10, 2024
4df807e
Revert "Set refetchOnMountOrArgChange to 15 minutes for both endpoint…
jg210 Feb 10, 2024
1ded8f8
TODO
jg210 Feb 10, 2024
b4f485c
RTK Query api polling.
jg210 Feb 10, 2024
86c65c3
Set both pollingInterval and refetchOnMountOrArgChange to 15 minutes.
jg210 Feb 10, 2024
c1192c9
Need to use currentData not data in Table component, or UI will get i…
jg210 Feb 10, 2024
8bac84e
TODO
jg210 Feb 10, 2024
b655f90
TODO
jg210 Feb 10, 2024
0aa1c54
TODO
jg210 Feb 10, 2024
dd06789
TODO
jg210 Feb 10, 2024
79cbef2
TODO
jg210 Feb 10, 2024
381ad43
TODO
jg210 Feb 10, 2024
fec694a
TODO
jg210 Feb 13, 2024
918c7dc
TODO
jg210 Feb 13, 2024
6e17a30
https://mswjs.io/docs/best-practices/typescript#request-handlers
jg210 Feb 13, 2024
0d3f786
Add types to make previous commit clearer.
jg210 Feb 13, 2024
c56eb4d
TODO
jg210 Feb 13, 2024
35184dc
Typo in inline TODO comment.
jg210 Feb 13, 2024
a279ecc
Full coverage of FSA.tsx.
jg210 Feb 13, 2024
2026551
TODO
jg210 Feb 13, 2024
2341083
Refactor clicking on local authority.
jg210 Feb 13, 2024
a4e3d17
Wait for a LOCAL_AUTHORITY_ID_TOKEN_12345_ to appear in screen not ju…
jg210 Feb 13, 2024
e0ec100
Remove unused localAuthorityNameToId() function·
jg210 Feb 13, 2024
4a809b3
Need to use https://testing-library.com/docs/user-event/v13#selectopt…
jg210 Feb 13, 2024
a1f99c4
TODO
jg210 Feb 13, 2024
6b9120c
Non-working attempt at asserting when request made/cached. Hangs.
jg210 Feb 13, 2024
2a50297
Remove debug logging from Table.tsx
jg210 Feb 13, 2024
787865d
mock service worker 2.2.0.
jg210 Feb 14, 2024
fcbab3b
Fix caching unit test. The URL filtering wasn't done right. Should cl…
jg210 Feb 14, 2024
47388b7
Rename RATINGS_URL etc. to BASE_URL.
jg210 Feb 14, 2024
857a940
Add BASE_PATHNAME, for use in App.test.tsx.
jg210 Feb 14, 2024
2eda080
TODO
jg210 Feb 14, 2024
45bf72b
Assert requests are as expected when clicking on items. Remove 2s sle…
jg210 Feb 14, 2024
8e7785d
Testing polling and caching doesn't seem to be possible useFakeTimers…
jg210 Feb 14, 2024
679ce96
useFakeTimers() doesn't work for testing polling/caching.
jg210 Feb 14, 2024
986852d
Disable redux dev tools in production.
jg210 Feb 14, 2024
6b45479
Remove unused import from App.test.tsx.
jg210 Feb 14, 2024
009b7d4
Show when data retrieved in UI, as requested by https://www.food.gov.…
jg210 Feb 14, 2024
6343d4d
Fix/suppress intellij warnings in LocalAuthorityController.
jg210 Feb 14, 2024
8b07a44
Upload build reports to github actions.
jg210 Feb 14, 2024
d7a1500
TODO
jg210 Feb 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ jobs:
- name: check
run: ./gradlew --scan check

- name: archive build reports
uses: actions/upload-artifact@v4.3.0
with:
name: build reports
path: build/reports/

- name: cypress end-to-end tests - spring boot jar
run: |
. environment
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classDiagram
App --> "1" Table
Table --> "*" TableRow
```
The React [front end](src/frontend) uses react state and props. There's no redux, RTK, thunk, sagas etc. Type checking is done using [TypeScript](https://www.typescriptlang.org/).
The [front end](src/frontend) uses [React](https://react.dev/). It uses [React Tool Kit Query](https://redux-toolkit.js.org/rtk-query/overview) to connect to the API. Type checking is done using [TypeScript](https://www.typescriptlang.org/).

## Server

Expand Down
36 changes: 31 additions & 5 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
* Try out redux-toolkit.
* Assert correct id selected in list in App.test.tsx.
- https://cathalmacdonnacha.com/how-to-test-a-select-element-with-react-testing-library

* Use redux for App's localAuthorityId
- https://redux-toolkit.js.org/usage/usage-with-typescript

* Get rid of narrow white gap around bar graph bars.

* vitest failures don't appear in VSC.

* Export OpenAPI spec. from spring boot server and use it in front end
- generate RTK Query API
- can MSW mocks be typed automatically too?

* More cypress tests.

* Run cypress test for shadow jar too.
- separate job or making sure stop process reliably
- java -cp build/libs/spring-experiments-1.0-aws.jar uk.me.jeremygreen.springexperiments.SpringExperimentsApplication
- better, faking lambda-style requests somehow
* Analytics.

* Sentry.

* Add pip constraints file.

* Retries with exponential backoff for failed requests (e.g. from 429 from lambda rate limiting).
- https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#automatic-retries
- https://mswjs.io/docs/api/http#once should allow this to be tested?

* 0% rows generally have non-zero bar graph size
- from rounding
Expand Down Expand Up @@ -50,6 +63,10 @@
* Role better than access key for publishing?
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html?icmpid=docs_iam_console#Using_CreateAccessKey

* Polling of APIs could mean that a localAuthorityId disappears.
- with much much greater probability than is currently possible.
- but still not very likely

* Add favicon.ico.

* gradle bootRun task depends on react/npm tasks even though doesn't use their output.
Expand Down Expand Up @@ -78,13 +95,22 @@

* Use https://fb.me/react-error-boundaries to mask back traces.

* unit test cache expiry and polling
- might need to reduce below polling interval to make this possible?
- https://mswjs.io/docs/recipes/polling/
- not clear if MSW etc. work with useFakeTimers() - 8e7785d889323f7cdd464bfac074466d3d487ff3

* unit test changing Table localAuthorityId shows loading... state again

* Improved failed-connection handling.

* Verify json metadata in case get paged data.
- check meta.totalPages is 1.
- check meta.returncode is OK.
- check meta.totalCount is correct.

* A github action that shows native unit test report in nicer way.

* Always download data using paged APIs.

* Find way to automate npm audit
Expand Down