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

chore: upgrade to storybook 7.x #1726

Merged
merged 5 commits into from
Aug 17, 2023
Merged

chore: upgrade to storybook 7.x #1726

merged 5 commits into from
Aug 17, 2023

Conversation

booc0mtaco
Copy link
Contributor

@booc0mtaco booc0mtaco commented Aug 17, 2023

Summary:

  • remove extraneous / outdated storybook plugins
  • upgrade packages to the latest available for storybook
  • amend documentation pages to support MDX2 format
  • fix remaining bugs
  • update test files to support latest story-utils and other dependencies
  • liberally use act() around test setup actions

Test Plan:

  • Wrote automated tests
  • CI tests / new tests are not applicable
  • Manually tested my changes, but I want to keep the details secret
  • Manually tested my changes, and here are the details:
    • no snapshot changes and no failing/flaky tests introduced

- remove extraneous / outdated storybook plugins
- upgrade packages to the latest available for storybook
- amend documentation pages to support MDX2 format
- fix remaining bugs
- update test files to support latest story-utils and other dependencies
- liberally use `act()` around test setup actions
@booc0mtaco booc0mtaco requested a review from a team August 17, 2023 16:00
@github-actions
Copy link

github-actions bot commented Aug 17, 2023

size-limit report 📦

Path Size
components 95.55 KB (0%)
styles 32.68 KB (0%)

@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #1726 (1ec3ea0) into next (6904e29) will not change coverage.
The diff coverage is n/a.

❗ Current head 1ec3ea0 differs from pull request most recent head 655a8c9. Consider uploading reports for the commit 655a8c9 to get more accurate results

@@           Coverage Diff           @@
##             next    #1726   +/-   ##
=======================================
  Coverage   92.27%   92.27%           
=======================================
  Files         146      146           
  Lines        2575     2575           
  Branches      664      664           
=======================================
  Hits         2376     2376           
- Misses        183      198   +15     
+ Partials       16        1   -15     

see 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

package.json Outdated Show resolved Hide resolved
.babelrc.json Outdated Show resolved Hide resolved
@@ -9,16 +10,22 @@ import * as stories from './Accordion.stories';
const { Default } = composeStories(stories);

describe('<Accordion />', () => {
generateSnapshots(stories);
generateSnapshots(stories as StoryFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

I notice some usages of generateSnapshots require as StoryFile and others don't, do you know what's happening here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not exactly sure, but it could be the type changes related to some of the storybook libraries. The first sweep was to satisfy typescript to restore parity on yarn test, and we can see if something systematic is causing certain story files to need a type

Comment on lines +21 to +23
await act(async () => {
await user.click(accordionButton);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do these events have to be wrapped in act, how'd you come to realize this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after upgrading dependencies, yarn test would output gigantic errors in console. what's strange is that for some of these user events, if you add the act() around them, it will complain that it's redundant 👎

For whatever reason, not all user. calls need this, and on older versions of the libraries, none did. It doesnt make obvious sense which is which

@@ -7,7 +7,7 @@ const defaultArgs = {
label: 'Checkbox',
};

export default {
const meta: Meta<typeof Checkbox> = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In cases like this, there were type errors that prevented tests from passing. Following the docs from storybook, this is the recommended typing to apply. What's weird is that types didn't break down on ALL tests, so not sure when types would get lost yet.

It's likely we should make these consistent in one way or the other, and favor aligning with this pattern since it mirrors the docs

Copy link
Contributor

Choose a reason for hiding this comment

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

it's likely we should make these consistent in one way or the other, and favor aligning with this pattern since it mirrors the docs

👍

I did something similiar when upgrading the Learning platform to Storybook v7. I went though and changed every as Meta<Args> to satisfies Meta<Args> which is a bit better than as. Not saying satifies is better than const meta: Meta <...> just pointing out I ran into similar weirdness

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep yep, i recall that one, and tested it on a few places. I think there may be more issues with the story files since that didn't have an effect in some cases. It's a little bit mysterious...

@jeremiah-clothier
Copy link
Contributor

How does testing for the deployed storybook or zeroheight work?

@booc0mtaco
Copy link
Contributor Author

How does testing for the deployed storybook or zeroheight work?

@jeremiah-clothier I might not be answering your question but we can chat about it. For ZH, the link between it and storybook is either by embedded iframe, OR by the ZH integration, which are keyed on the individual story URLs/names respectively.

The testing for deployed storybook itself is pretty straightforward; the github action must be able to pass all the existing checks before it can be published.


I'll add a backlog item for making the test signatures consistent, and see if that resolves the need for the act() call

@booc0mtaco booc0mtaco merged commit d67240c into next Aug 17, 2023
5 checks passed
@booc0mtaco booc0mtaco deleted the aholloway/EFI-1030 branch August 17, 2023 19:54
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