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

Add CI step for storybook test runner #935

Open
wants to merge 25 commits into
base: stable
Choose a base branch
from
Open

Conversation

martha
Copy link
Contributor

@martha martha commented Sep 18, 2024

Description

This PR adds a CI step for the Storybook test runner, which we can eventually use to run automated a11y tests. The a11y test config itself is commented out for now, though, since it causes the build to fail. Without that turned on, the test runner is just running each story and passing the test if it encounters no errors. See example build: https://github.com/greenriver/hmis-frontend/actions/runs/10947831708/job/30397456339?pr=935#step:10:1213

This PR adds new dependencies: concurrently, http-server, and wait-on. They are recommended by this recipe provided by Storybook for running the test runner in CI.

I believe, alternatively, it's possible to run tests in CI against a Chromatic instance (see this other recipe), but based on the existing "Run Chromatic" build step, it looks like we only want to run chromatic on push to a release branch and not on pull request.

Type of change

  • Bug fix
  • New feature (adds functionality)
  • Code clean-up / housekeeping
  • Dependency update
  • CI enhancement ✨

Checklist before requesting review

  • I have performed a self-review of my code
  • I have run the code that is being changed under ideal conditions, and it doesn't fail
  • My code includes comments and/or descriptive variable names to help other engineers understand the intent (or not applicable)
  • My code follows the style guidelines of this project (eslint)
  • I have updated the documentation (or not applicable)
  • If it's not obvious how to test this change, I have provided testing instructions in this PR or the related issue

@martha martha changed the title Test CI for storybook test runner Test CI for storybook test runner (WIP) Sep 19, 2024
@martha martha changed the title Test CI for storybook test runner (WIP) Add CI step for storybook test runner (WIP) Sep 19, 2024
@martha martha requested a review from gigxz September 19, 2024 19:59
@martha martha changed the title Add CI step for storybook test runner (WIP) Add CI step for storybook test runner Sep 19, 2024
onlyChanged: true
- name: Storybook test
Copy link
Collaborator

Choose a reason for hiding this comment

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

@martha I am wondering about the choice to user storybook test runner on CI as opposed to running tests via Chromatic on CI. The storybook gives the example that you might want to "Use [test runner] locally and Chromatic on your CI". I would guess that a benefit of Chromatic would be if the tests fail, maybe you can see some more detailed output on chromatic as opposed to just test logs. (Judging from chromatic docs about PR workflow it seems pretty advanced).

Linking https://github.com/open-path/Green-River/issues/6687 for reference too

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I didn't read all the way through your description 🙈

I believe, alternatively, it's possible to run tests in CI against a Chromatic instance (see this other recipe), but based on the existing "Run Chromatic" build step, it looks like we only want to run chromatic on push to a release branch and not on pull request.

That was set up mostly for the purpose of publishing the "release version" of the storybook. I don't have anything against using chromatic to run testing on PRs. (And I guess publishing, maybe that's the norm for chromatic usage).

Copy link
Contributor Author

@martha martha Oct 8, 2024

Choose a reason for hiding this comment

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

Sounds good, I updated the PR to run the tests against the Chromatic instance of Storybook.

We do still need the test runner to run the accessibility tests. Chromatic supports running interaction tests, but doesn't support a11y tests as far as I can tell. You can see this in the example build here. The test runner step shows a11y failures, but the Chromatic step succeeds. In the corresponding Chromatic build for that action, there are 51 "unreviewed changes" (bc I had temporarily turned on the "visual tests" setting) but there are no a11y-related failures or warnings.

@@ -0,0 +1,26 @@
// COMMENTED OUT for now until we want to actually turn on accessibility tests on CI
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the tests pass for you locally? test-storybook passed for me (which I was surprised by, if it included accessibility tests?) but I'm not 100% confident that I resolved the merge conflicts correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can see the accessibility failures both locally and on CI by uncommenting the contents of this file. See this build, for example.

Do you want to actually turn this on now and make all our CI tests fail until we fix the a11y issues? I had assumed not yet...

But maybe it would be a good idea to turn it on and factor it out into a separate build step, that way when it fails we can immediately recognize the failure is expected, instead of clicking into the gh action log to make sure it's failing on the expected step?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh okay I wasn't seeing them locally, but I'll try again. No I agree, lets not intentionally have CI fail.

Base automatically changed from release-134 to stable October 4, 2024 11:40
@martha martha changed the base branch from stable to release-137 October 7, 2024 20:36
Base automatically changed from release-137 to stable November 7, 2024 20:15
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.

2 participants