From d091b9eda5be35cf63505e51e40fde275e32965c Mon Sep 17 00:00:00 2001 From: Sophie Schneider Date: Mon, 28 Aug 2023 09:03:49 -0400 Subject: [PATCH] [CI][Tests] Consolidate se23 tests (#10243) ### WHY are these changes introduced? Part of https://github.com/Shopify/polaris/issues/10191 ### WHAT is this pull request doing? - Force test providers to `polarisSummerEditions2023: true`, this is temporary until we clean up the AppProvider - Delete `.github/workflows/ci.yml` - Rename `.github/workflows/ci-experimental.yml` to `.github/workflows/ci.yml` - Consolidate any tests that use the flag ### Tophat - Make sure there isn't an experimental CI check anymore and that CI passes --- .github/workflows/ci-experimental.yml | 65 ------------ .github/workflows/ci.yml | 4 +- .../tests/SecondaryNavigation.test.tsx | 99 +++++++++---------- .../components/Item/tests/Item.test.tsx | 2 - .../components/Option/tests/Option.test.tsx | 1 - .../PolarisTestProvider.tsx | 2 +- .../components/Tooltip/tests/Tooltip.test.tsx | 21 ---- .../tests/utilities/react-testing.tsx | 2 +- 8 files changed, 48 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/ci-experimental.yml diff --git a/.github/workflows/ci-experimental.yml b/.github/workflows/ci-experimental.yml deleted file mode 100644 index 066bcfb77f5..00000000000 --- a/.github/workflows/ci-experimental.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: CI experimental - -on: - push: - branches: - - main - - next - pull_request: - -jobs: - build: - name: 'Validate with Node v${{ matrix.node-version }}' - runs-on: ubuntu-latest - strategy: - matrix: - node-version: ['16.17.0', '18.12.0'] - steps: - - name: Checkout branch - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - name: Free up space on GitHub image - run: | - # Based on the official advice: - # https://github.com/actions/virtual-environments/issues/2840#issuecomment-790492173 - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - - name: Setup Node with v${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: yarn - - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - **/.eslintcache - **/.turbo - node_modules/.cache/turbo - polaris.shopify.com/.next/cache - key: ${{ runner.os }}-node${{ matrix.node-version }}-test-experimental-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-node${{ matrix.node-version }}-test-experimental- - - - name: Install dependencies - run: yarn --frozen-lockfile - - - name: Build packages - run: yarn build - - - name: Lint - run: yarn lint - - - name: Type check - run: yarn type-check - - - name: Test - env: - SE23: 'on' - run: yarn test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d68b7e33c8..71b2576ca63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,9 +43,9 @@ jobs: **/.turbo node_modules/.cache/turbo polaris.shopify.com/.next/cache - key: ${{ runner.os }}-node${{ matrix.node-version }}-test-v2-${{ github.sha }} + key: ${{ runner.os }}-node${{ matrix.node-version }}-test-v3-${{ github.sha }} restore-keys: | - ${{ runner.os }}-node${{ matrix.node-version }}-test-v2- + ${{ runner.os }}-node${{ matrix.node-version }}-test-v3- - name: Install dependencies run: yarn --frozen-lockfile diff --git a/polaris-react/src/components/Navigation/components/Item/components/SecondaryNavigation/tests/SecondaryNavigation.test.tsx b/polaris-react/src/components/Navigation/components/Item/components/SecondaryNavigation/tests/SecondaryNavigation.test.tsx index d5d59925e5b..38a6be76e81 100644 --- a/polaris-react/src/components/Navigation/components/Item/components/SecondaryNavigation/tests/SecondaryNavigation.test.tsx +++ b/polaris-react/src/components/Navigation/components/Item/components/SecondaryNavigation/tests/SecondaryNavigation.test.tsx @@ -83,80 +83,69 @@ describe('', () => { }); }); - describe('with polarisSummerEditions2023 feature flag enabled', () => { - it('renders Item with onMouseLeave and onMouseEnter undefined when the item is disabled', () => { - const mockPropsWithDisabledItem = { - ...mockProps, - subNavigationItems: [ - mockProps.subNavigationItems[0], - mockProps.subNavigationItems[1], - { - ...mockProps.subNavigationItems[2], - disabled: true, - }, - ], - }; - - const component = mountWithApp( - , + it('renders Item with onMouseLeave and onMouseEnter undefined when the item is disabled', () => { + const mockPropsWithDisabledItem = { + ...mockProps, + subNavigationItems: [ + mockProps.subNavigationItems[0], + mockProps.subNavigationItems[1], { - features: {polarisSummerEditions2023: true}, + ...mockProps.subNavigationItems[2], + disabled: true, }, - ); + ], + }; - expect(component.findAll(Item)[2]).toHaveReactProps({ - onMouseEnter: undefined, - onMouseLeave: undefined, - }); + const component = mountWithApp( + , + ); + + expect(component.findAll(Item)[2]).toHaveReactProps({ + onMouseEnter: undefined, + onMouseLeave: undefined, }); + }); - it('adds showVerticalHoverPointer prop to the hovered item', () => { - const component = mountWithApp(, { - features: {polarisSummerEditions2023: true}, - }); + it('adds showVerticalHoverPointer prop to the hovered item', () => { + const component = mountWithApp(); - const hoveredIndex = 2; - component.findAll(Item)[hoveredIndex].trigger('onMouseEnter'); + const hoveredIndex = 2; + component.findAll(Item)[hoveredIndex].trigger('onMouseEnter'); - component.findAll(Item).forEach((item, index) => { - expect(item).toHaveReactProps({ - showVerticalHoverPointer: index === hoveredIndex, - }); + component.findAll(Item).forEach((item, index) => { + expect(item).toHaveReactProps({ + showVerticalHoverPointer: index === hoveredIndex, }); }); + }); - it('adds showVerticalLine prop to all the Item components before the matched item', () => { - const component = mountWithApp(, { - features: {polarisSummerEditions2023: true}, - }); + it('adds showVerticalLine prop to all the Item components before the matched item', () => { + const component = mountWithApp(); - const indexWithMatchedItem = 1; + const indexWithMatchedItem = 1; - component.findAll(Item).forEach((item, index) => { - const shouldShowVerticalLine = index < indexWithMatchedItem; - expect(item).toHaveReactProps({ - showVerticalLine: shouldShowVerticalLine, - }); + component.findAll(Item).forEach((item, index) => { + const shouldShowVerticalLine = index < indexWithMatchedItem; + expect(item).toHaveReactProps({ + showVerticalLine: shouldShowVerticalLine, }); }); + }); - it('adds showVerticalLine prop to all the Item components before the hovered item when hovered item is before the matched item', () => { - const component = mountWithApp(, { - features: {polarisSummerEditions2023: true}, - }); + it('adds showVerticalLine prop to all the Item components before the hovered item when hovered item is before the matched item', () => { + const component = mountWithApp(); - // Make sure the hovered item is before the matched item - const hoveredIndex = 0; - component.findAll(Item)[hoveredIndex].trigger('onMouseEnter'); + // Make sure the hovered item is before the matched item + const hoveredIndex = 0; + component.findAll(Item)[hoveredIndex].trigger('onMouseEnter'); - const indexWithMatchedItem = 1; + const indexWithMatchedItem = 1; - component.findAll(Item).forEach((item, index) => { - const shouldShowVerticalLine = index < indexWithMatchedItem; + component.findAll(Item).forEach((item, index) => { + const shouldShowVerticalLine = index < indexWithMatchedItem; - expect(item).toHaveReactProps({ - showVerticalLine: shouldShowVerticalLine, - }); + expect(item).toHaveReactProps({ + showVerticalLine: shouldShowVerticalLine, }); }); }); diff --git a/polaris-react/src/components/Navigation/components/Item/tests/Item.test.tsx b/polaris-react/src/components/Navigation/components/Item/tests/Item.test.tsx index c06cf61c7e8..7635861b13b 100644 --- a/polaris-react/src/components/Navigation/components/Item/tests/Item.test.tsx +++ b/polaris-react/src/components/Navigation/components/Item/tests/Item.test.tsx @@ -162,7 +162,6 @@ describe('', () => { { location: 'foo', }, - {features: {polarisSummerEditions2023: true}}, ); expect(item).toContainReactComponent(Icon, { @@ -188,7 +187,6 @@ describe('', () => { { location: 'bar', }, - {features: {polarisSummerEditions2023: true}}, ); expect(item).toContainReactComponent(Icon, { diff --git a/polaris-react/src/components/OptionList/components/Option/tests/Option.test.tsx b/polaris-react/src/components/OptionList/components/Option/tests/Option.test.tsx index 3b6f8b30f41..731483e10ed 100644 --- a/polaris-react/src/components/OptionList/components/Option/tests/Option.test.tsx +++ b/polaris-react/src/components/OptionList/components/Option/tests/Option.test.tsx @@ -58,7 +58,6 @@ describe('