Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI tests for experimental code (#9860)
### 🤨 WHAT is this pull request doing? Fixes Shopify/archive-polaris-backlog-2024#1029 Duplicates CI checks for `{features: {polarisSummerEditions2023: true}}` <details> <summary>How to run tests in the CLI</summary> <br /> I implemented this using a <code>SE23</code> environment variable that can be set to <code>on</code> or <code>off</code>. (I don't use true/false to avoid confusion with strings vs booleans). To run tests with `{features: {polarisSummerEditions2023: true}}`: ``` SE23='on' yarn test ``` To run tests with `{features: {polarisSummerEditions2023: false}}` ``` yarn test // or SE23='off' yarn test ``` </details> <img width="400" alt="Screenshot 2023-08-01 at 1 51 24 PM" src="https://github.com/Shopify/polaris/assets/20652326/d760c8e1-7cf8-44e2-ba41-c3ba6c7fcf4d"> ### 🔨 How tests are fixed To add these checks, I had to fix all failing tests when `polarisSummerEditions2023: true`. To do this, I investigated the failing tests and followed these steps: 1. See if test can be fixed to pass on both without compromising the purpose of the test 2. If not, duplicate the test 3. Create a `polarisSummerEditions2023 false` describe block at the end of the file 4. Move the duplicated test there and pass `polarisSummerEditions2023: false` to `mountWithApp` to force the feature flag on every test run 5. In the original failing test, force `polarisSummerEditions2023: true` and fix the test #### Example for <code>CaretDownMinor</code> -> <code>ChevronDownMinor</code> changes</summary> ```diff it('is a test that will only pass post se23', () => { - const component = mountWithApp(<MyComponent />); - expect(component).toContainReactComponent(Icon, {source: CaretDownMinor}); + const component = mountWithApp(<MyComponent />, {features: {polarisSummerEditions2023: true}}); + expect(component).toContainReactComponent(Icon, {source: ChevronDownMinor}); }); + describe('polarisSummerEditions2023 false', () => { + it('is a test that will only pass pre se23', () => { + const component = mountWithApp(<MyComponent />, {features: {polarisSummerEditions2023: false}}); + expect(component).toContainReactComponent(Icon, {source: CaretDownMinor}); + }); ``` ### 🧽 How these should be cleaned up When we remove the `polarisSummerEditions2023` feature, we will need simply: 1. delete all the `polarisSummerEditions2023 false` describe blocks 2. remove the {features: {polarisSummerEditions2023: true} from `mountWithApp`s #### Clean up for example above</summary> ```diff it('is a test that will only pass post se23', () => { - const component = mountWithApp(<MyComponent />, {features: {polarisSummerEditions2023: true}}); +. const component = mountWithApp(<MyComponent />); expect(component).toContainReactComponent(Icon, {source: ChevronDownMinor}); }); - describe('polarisSummerEditions2023 false', () => { - it('is a test that will only pass pre se23', () => { - const component = mountWithApp(<MyComponent />, {features: {polarisSummerEditions2023: false}}); - expect(component).toBeNull(); - }); ``` ### How to 🎩 Make sure all CI checks pass 😎
- Loading branch information