Closed nina-py closed 3 years ago
Just a follow-up on the tests: the unit tests are fine, however a couple of new integration tests I have written that use Apollo's MockedProvider
are failing with a network error. Although it's not supposed to, MockedProvider
attempts to make a network connection and then complains it cannot find anything (?). This is reproducible both on my laptop and during test runs on GitHub.
I have already spent quite a bit of time on this and may have to file an issue in the apollo-client
repo and see what they say, and alternatively look for a "default API" solution that may be used for test mocks as well. Meanwhile, I hope this PR can be reviewed with those tests skipped so as not to block development of further features that use the API.
console.error
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/home/runner/work/curation-tools-frontend/curation-tools-frontend/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:62:19)
at Request.<anonymous> (/home/runner/work/curation-tools-frontend/curation-tools-frontend/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:654:18)
at Request.emit (events.js:327:22)
at Request.EventEmitter.emit (domain.js:486:12)
at Request.onRequestError (/home/runner/work/curation-tools-frontend/curation-tools-frontend/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:315:20)
at ClientRequest.EventEmitter.emit (domain.js:486:12)
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:486:12) undefined
at VirtualConsole.<anonymous> (node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:65:53)
at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:654:18)
at Request.onRequestError (node_modules/request/request.js:877:8)
Goal
Show data from the API on the default Prospects tab.
Closes #96.
Todos:
[x] Added Apollo client, AWS packages to connect to AppSync
[x] Added Material-UI Lab package to get access to Alert component
[x] Added new layout components - Chip, TabPanel, TabLink, HandleApiResponse, and adjusted some of the existing ones to work correctly with the Prospects data.
[x] Pending prospects are now shown on the default Prospects tab.
[x] Added tests.
[x] Added comments throughout so that new and updated components are (mostly) documented.
Implementation Decisions
The scope of this PR is limited to the linked issue. However, to get this new page just right I have had to edit numerous existing components and add quite a bit of new code - apologies for the ~30 changed files! :)
Notably, routing was added to tabs and I have had to replace Badge with Chip for displaying the number of articles in a tab - the dimensions of the Badge component are not taken into account when centering tab labels so I needed something that would sit alongside the label.
App.tsx
contains some temporary code to set a current feed (en-US
) if none or an invalid feed name was provided in the URL. A couple of new tests are temporarily being skipped - working on those. A field or two are missing from the API and placeholders are used instead. Pagination is out of scope for this PR - I'm just fetching the first 50 records on the page.To get the app working with the API, specify the variables requested in
src/services/clients/AwsAppSync.ts
in an.env.local
or.env.development
file. Here is a screenshot: