Skip to content

docs: add more chromatic/storybook info#7337

Merged
benelan merged 3 commits intomainfrom
benelan/add-more-snapshot-doc
Jul 20, 2023
Merged

docs: add more chromatic/storybook info#7337
benelan merged 3 commits intomainfrom
benelan/add-more-snapshot-doc

Conversation

@benelan
Copy link
Copy Markdown
Contributor

@benelan benelan commented Jul 18, 2023

Related Issue: #7333

Summary

  • Add contributing information about running chromatic

@benelan benelan added the skip visual snapshots Pull requests that do not need visual regression testing. label Jul 18, 2023
@benelan benelan requested a review from a team as a code owner July 18, 2023 22:33
@github-actions github-actions Bot added the docs Issues relating to documentation updates only. label Jul 18, 2023
- The `simple` story and any other significant configuration should have a matching `darkModeRTL_TestOnly` story
- In order to reduce snapshot count, dark mode and RTL visual tests have been combined

Any stories used for snapshot testing should have animations disabled using the `--calcite-duration-factor` CSS variable so they don't cause diffs on every build. `NoTest` stories are the only ones that should have animations. See [`loader`'s stories](../src/components/loader/loader.stories.ts) as an example for how to setup stories for components with animation. For example:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick: setup stories ➡️ set up stories.

- The `simple` story and any other significant configuration should have a matching `darkModeRTL_TestOnly` story
- In order to reduce snapshot count, dark mode and RTL visual tests have been combined

Any stories used for snapshot testing should have animations disabled using the `--calcite-duration-factor` CSS variable so they don't cause diffs on every build. `NoTest` stories are the only ones that should have animations. See [`loader`'s stories](../src/components/loader/loader.stories.ts) as an example for how to setup stories for components with animation. For example:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about the stories that don't have a test-related suffix? I believe those are also used for screenshot tests.

I think we can automatically disable all animations in Chromatic builds by using preview/manager templates + the screenshot test build flag:

// main.ts
module.exports = {
  // ...
  previewHead: (head) => (`
    ${head}
    ${
      process.env.STORYBOOK_SCREENSHOT_TEST_BUILD ? 
        `<style>
          :root {
            --calcite-duration-factor: 0;
          }
        </style>` 
        : ""  
    }
  `),
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What about the stories that don't have a test-related suffix? I believe those are also used for screenshot tests.

Yeah they are.

Ooh nice I can give that a try

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is also this: https://www.chromatic.com/docs/ischromatic#use-in-storybookpreviewjs

I just didn't know about the previeHead thing

benelan added 2 commits July 20, 2023 12:28
…shot-doc

* origin/main:
  chore: release next
  fix(tooltip): ensure --calcite-app-z-index-tooltip is applied (#7345)
  docs: add warning notice to internal storybook (#7338)
  chore: remove references to removed cleanup script (#7339)
  chore: drop Airtable syncing action (#7340)
  chore: release next
  fix(color-picker): maintains correct numbering system when entering invalid RGB value (#7327)
  ci: notify teams about calcite-components releases only (#7317)
  build(deps): Bump rollup from 2.77.1 to 3.26.0 (#7264)
  build(deps): Bump eslint-plugin-jsdoc from 46.4.3 to 46.4.4 (#7329)
  build(deps): Bump semver and @types/semver (#7309)
@benelan benelan merged commit dbd2fd5 into main Jul 20, 2023
@benelan benelan deleted the benelan/add-more-snapshot-doc branch July 20, 2023 19:50
@github-actions github-actions Bot added this to the 2023 July Priorities milestone Jul 20, 2023
benelan added a commit that referenced this pull request Jul 21, 2023
…visual diffs (#7348)

**Related Issue:**
#7337 (comment)

## Summary

Uses `--calcite-duration-factor` to disable animations for all snapshots
when running in Chromatic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues relating to documentation updates only. skip visual snapshots Pull requests that do not need visual regression testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants