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

test(app-project): mock Zooniverse APIs in stories with MSW #6406

Merged
merged 14 commits into from
Nov 14, 2024

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Oct 25, 2024

  • install MSW for the storybook.
  • add a mock API to the workflow selector stories.
  • add mock APIs to the subject picker stories.
  • skip a couple of Mocha tests that now fail with errors. all the tests should still pass.

Package

  • app-project

Linked Issue and/or Talk Post

How to Review

Running the dev storybook locally, there are a couple of new stories:

A story showing the subject picker component with subjects loaded in from a mock API. A story showing locked and unlocked workflow levels, when the assigned workflow is complete.

You can test the deployed storybook (NODE_ENV=production) with:

yarn build-storybook
npx serve ./storybook-static

I've skipped a couple of tests that are failing with errors. I'm not sure why they fail. I think it might be happening because stories are designed to run in a browser, but the tests run in Node. Mocha tests, with nock to mock the Panoptes API in Node, should still run and pass on this branch.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

@coveralls
Copy link

coveralls commented Oct 25, 2024

Coverage Status

coverage: 77.838% (-0.006%) from 77.844%
when pulling 6b8c9d9 on eatyourgreens:project-msw-mocks
into 5d3e4aa on zooniverse:master.

Copy link
Contributor Author

@eatyourgreens eatyourgreens Oct 25, 2024

Choose a reason for hiding this comment

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

I've used the same config here that I use to test client-side React components with Storybook 8, so this should be forward compatible.

@eatyourgreens eatyourgreens force-pushed the project-msw-mocks branch 2 times, most recently from 66caf17 to ef6d118 Compare October 25, 2024 14:45
]
})
const DefaultStory = composeStory(Default, Meta)
await applyRequestHandlers(DefaultStory.parameters.msw)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed in Storybook 7, but 8 handles it automatically for you.

@eatyourgreens eatyourgreens force-pushed the project-msw-mocks branch 2 times, most recently from b927fd2 to b1c0cd6 Compare October 25, 2024 17:17
@eatyourgreens eatyourgreens force-pushed the project-msw-mocks branch 2 times, most recently from 290f6b5 to 226be8a Compare November 11, 2024 12:31
@goplayoutside3 goplayoutside3 self-assigned this Nov 13, 2024
@goplayoutside3
Copy link
Contributor

Phew 😌 I messed up there for a minute by pushing changes before including the latest dependency bumps from the master branch.

I made two changes:

  1. Per fix(app-project): data-fetching for assigned workflow level #6219 (comment) I changed the SWROptions in useAssignedLevel() to revalidate on mount. Previously, the WorkflowSelector story on this branch did not properly unlock Levels 1+2 when the user is assigned a workflow id of an inactive workflow with level 3.
  2. I made some updates to the WorkflowSelector stories to use a select with options for userReadyState (its options array was incorrectly configured) and I renamed the two stories that use the workflow assignment feature to reflect the name of that feature.

@goplayoutside3 goplayoutside3 merged commit 9fca7dd into zooniverse:master Nov 14, 2024
8 checks passed
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.

3 participants