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: Improve snapshot infrastructure and organization #687

Merged
merged 17 commits into from
Jun 1, 2020

Conversation

anicholls
Copy link
Contributor

@anicholls anicholls commented May 29, 2020

Addresses infrastructure improvements in #683

  • Use component + variant name in story name so it's more obvious in Chromatic
  • Pull visual testing stories into their own Testing top level section within storybook.
  • Switch to CSF format for these stories
  • Update create-component to use CSF and create a visual testing story for you
  • Add helper to enable chromatic snapshots as it's easy to typo right now:
  • The CSF decorator can be used on an entire file of stories, or a single story. It only works for CSF formats.

  • All stories in a file:
    export default withSnapshotsEnabled({
      // CSF details (title, component, etc.)
    });
  • Specific story:
    export const MyVisualStory = () => {
      // story contents
    };
    
    withSnapshotsEnabled(MyVisualStory);

New "Testing" section:
image

@anicholls
Copy link
Contributor Author

One thought: I wonder if we could update our storybook config to automatically enable chromatic if the story is in the Testing| top level category.

@anicholls anicholls self-assigned this Jun 1, 2020
@cypress
Copy link

cypress bot commented Jun 1, 2020



Test summary

317 0 0 0


Run details

Project canvas-kit
Status Passed
Commit 4f86de8 ℹ️
Started Jun 1, 2020 7:46 PM
Ended Jun 1, 2020 7:50 PM
Duration 03:10 💡
OS Linux Ubuntu Linux - 18.04
Browser Electron 80

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@anicholls anicholls added 4.x ready for review Code is ready for review testing labels Jun 1, 2020
@anicholls anicholls added this to the v4.0.0 milestone Jun 1, 2020
@anicholls anicholls marked this pull request as ready for review June 1, 2020 19:40
*
* TODO: Clean up after optional chaining is enabled
*/
export const withSnapshotsEnabled: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I looked at making this a regular storybook decorator so you could do something like

export default {
  title: 'My Story',
  decorators: [withSnapshotsEnabled]
}

However, editing the storyFn.story object doesn't seem to work from within the decorator function. This must be a limitation of the Storybook decorator API.

@mannycarrera4
Copy link
Contributor

NB: Within our testing is it worth noting the difference between States as in hover, active, ect.. and then other stories where States mean visual states where the component changes based on props?

@anicholls anicholls merged commit 56aafbc into Workday:master Jun 1, 2020
@anicholls anicholls deleted the snapshot-improvements branch June 1, 2020 20:56
@anicholls
Copy link
Contributor Author

@mannycarrera4 Yeah it's worth considering. I don't think it's been a point of confusion so far though. Not sure what I would want to see instead.

alexandrzavalii pushed a commit to alexandrzavalii/canvas-kit that referenced this pull request Sep 14, 2020
* test: Add helper to enable chromatic snapshots

* test(button): Refactor visual testing stories to use CSF

* test(form-field): Refactor visual testing stories to use CSF

* test(pagination): Refactor visual testing stories to use CSF

* test(select): Refactor visual testing stories to use CSF

* test(popup): Refactor visual testing stories to use CSF

* test(toast): Refactor visual testing stories to use CSF

* test(form-field): Rename testing stories into their own section

* test(button): Rename testing stories into their own section

* test: Rename remainder of testing stories into their own section

* fix(form-field): Fix import

* refactor: Add category to create-component script and use CSF

* feat: Add CSF visual testing story to create-component script

* fix(form-field): Remove unused variable

* fix(form-field): Properly export theme stories

* refactor: Use a decorator for enabling snapshots

* feat: Add override to withSnapshotsEnabled so it can be used per story
alexandrzavalii pushed a commit to alexandrzavalii/canvas-kit that referenced this pull request Sep 14, 2020
* test: Add helper to enable chromatic snapshots

* test(button): Refactor visual testing stories to use CSF

* test(form-field): Refactor visual testing stories to use CSF

* test(pagination): Refactor visual testing stories to use CSF

* test(select): Refactor visual testing stories to use CSF

* test(popup): Refactor visual testing stories to use CSF

* test(toast): Refactor visual testing stories to use CSF

* test(form-field): Rename testing stories into their own section

* test(button): Rename testing stories into their own section

* test: Rename remainder of testing stories into their own section

* fix(form-field): Fix import

* refactor: Add category to create-component script and use CSF

* feat: Add CSF visual testing story to create-component script

* fix(form-field): Remove unused variable

* fix(form-field): Properly export theme stories

* refactor: Use a decorator for enabling snapshots

* feat: Add override to withSnapshotsEnabled so it can be used per story
@jaclynjessup jaclynjessup removed testing ready for review Code is ready for review labels Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants