Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update /resources endpoints to consume from Django API localhost:8000 #102

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

Merged
merged 8 commits into from
Apr 26, 2020

Conversation

lpatmo
Copy link
Member

@lpatmo lpatmo commented Apr 6, 2020

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Documentation Update

Description

Updated the /resources listing and single resource page to consume from a locally running Django API app (localhost:8000) at github.com/codebuddies/backend

Related Tickets & Documents

Right now we need to pass in an authorization bearer token in order to see a listing of resources, but we should make that public. Only "create" should be protected. See: codebuddies/backend#128

Before & After

Before: localhost:3001 (db.json)
After: localhost:8000 (github.com/codebuddies/backend)

@lpatmo lpatmo requested a review from a team April 6, 2020 07:29
@angelocordon
Copy link
Contributor

angelocordon commented Apr 20, 2020

@lpatmo - are we expecting local development for frontend to be using the API as well now?

If so, (doesn't have to be part of this PR), but we should have a discussion on how to properly test this integration then.

@lpatmo
Copy link
Member Author

lpatmo commented Apr 21, 2020

@angelocordon Yes, we are! The local API is running in development at the same moment. :) I just realized we should have this documented in the README... and I might just record a quick video on Twitch stream to demonstrate the setup right now, so one moment on that!

@lpatmo
Copy link
Member Author

lpatmo commented Apr 21, 2020

Please let me know if there are questions I didn't answer in https://www.youtube.com/watch?v=t43vYwxzG-E&t=210s -- happy to re-record (or answer the questions)!

@lpatmo
Copy link
Member Author

lpatmo commented Apr 21, 2020

Also, I just reread your comment and realized you made a point about properly testing this 😅-- I wrote tests for the backend (codebuddies/backend#128) already so I know that the API requests are covered! Are you saying we should add some integration tests on the frontend too to cover a user being able to see resources when they load the page?

@angelocordon
Copy link
Contributor

We should have a discussion on how we should properly set up integration tests but I don't think that would fit in this PR. Maybe we can start a discussion in Slack and once we figure out a strategy we can create an issue.

But in the meantime, I see that we don't have any tests for ResourceCard or ResourcePage :)

@lpatmo
Copy link
Member Author

lpatmo commented Apr 22, 2020

Yeah, ideally I think this should be testing that on the ResourcePage, when I make a GET request if the request is successful I see certain items on the page, and if the request isn't successful I see an error on the page.

I can try adding that test in this PR, or create a new issue for it. The next thing I was going to work on was the front-end implementation of creating a resource, which also needs its own test. :)

@angelocordon
Copy link
Contributor

I think a low hanging fruit here would be to test what the ResourceCard should be rendering. We also should/could (?) mock out that GET request to test out the ResourcePage.

@lpatmo lpatmo force-pushed the issue-101 branch 4 times, most recently from 068df0b to b05bd32 Compare April 22, 2020 17:47
@lpatmo
Copy link
Member Author

lpatmo commented Apr 22, 2020

Pushed up a test checking that resources are being loaded on the page! :)

H/t Henry and Chris in the #reactjs channel for taking a look and helping me debug an issue with the test last night!

image

@gauravchl
Copy link
Member

@lpatmo @angelocordon What do you think if we deploy one instance of backend server as a staging server? So whoever is working on frontend can connect to backend staging server from localhost without setting up backend locally.

@angelocordon-omada
Copy link
Contributor

angelocordon-omada commented Apr 23, 2020

@gauravchl I think it might be more worth looking for a local mocked server. Ideally, we wouldn't need to connect to an outside network while developing and testing locally. We should have a staging server though but for a different reason.

For example:
https://learning.postman.com/docs/postman/mock-servers/setting-up-mock/

It might work if we can get the latest collection from the backend API and have a mock server using that collection instead of needing to build a Docker instance of the API locally.

@lpatmo
Copy link
Member Author

lpatmo commented Apr 24, 2020

So whoever is working on frontend can connect to backend staging server from localhost without setting up backend locally.

@gauravchl Are you thinking of something like:
npm start --staging to spin up the local frontend app, but with all the API endpoints making requests to https://stagingapi.codebuddies.org/api/v1/resources

https://learning.postman.com/docs/postman/mock-servers/setting-up-mock/

Does this also mean we need to make our postman file in https://github.com/codebuddies/backend/tree/master/postman up to date?

Side question -- did either of you run into any trouble running the docker command in https://github.com/codebuddies/backend? Just curious!

@gauravchl
Copy link
Member

@angelocordon Postman mocking server looks interesting! Didn't know before.

@gauravchl Are you thinking of something like:
npm start --staging to spin up the local frontend app, but with all the API endpoints making requests to https://stagingapi.codebuddies.org/api/v1/resources

@lpatmo Yup

Side question -- did either of you run into any trouble running the docker command in https://github.com/codebuddies/backend? Just curious!

@lpatmo Actually I'm having trouble getting good internet here so I didn't try to setup backend to pull docker images :)

@lpatmo
Copy link
Member Author

lpatmo commented Apr 24, 2020

Actually I'm having trouble getting good internet here so I didn't try to setup backend to pull docker images :)

Oof, I'm sorry -- didn't realize docker would consume a lot of bandwidth. I'll prioritize deploying a staging API, unless something like https://learning.postman.com/docs/postman/mock-servers/setting-up-mock/ is easier. (Never done it before, but I vaguely remember watching Bill do it at one point with dockerhub so I should be able to figure it out, right? :P)

@angelocordon angelocordon added this to the v3.0.1 milestone Apr 26, 2020
@lpatmo lpatmo mentioned this pull request Apr 26, 2020
@lpatmo lpatmo added do not merge Notify maintainers not to merge a PR (yet) and removed do not merge Notify maintainers not to merge a PR (yet) labels Apr 26, 2020
Copy link
Contributor

@angelocordon angelocordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Linda Peng and others added 5 commits April 26, 2020 12:05
At the time of writing, CRA uses Jest 24 and React Testing Library.
This adds the latest version of Jest for us to use instead of using
react-scripts.

Update Github workflow to use Jest instead of react-script.
Add Babel Runtime and Transform Runtime Plugin to handle async
calls in our tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants