Skip to content

Commit

Permalink
[CI][Tests] Consolidate se23 tests (#10243)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Part of #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
  • Loading branch information
sophschneider committed Sep 18, 2023
1 parent be90502 commit d091b9e
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 148 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/ci-experimental.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,80 +83,69 @@ describe('<SecondaryNavigation />', () => {
});
});

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(
<SecondaryNavigation {...mockPropsWithDisabledItem} />,
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(
<SecondaryNavigation {...mockPropsWithDisabledItem} />,
);

expect(component.findAll(Item)[2]).toHaveReactProps({
onMouseEnter: undefined,
onMouseLeave: undefined,
});
});

it('adds showVerticalHoverPointer prop to the hovered item', () => {
const component = mountWithApp(<SecondaryNavigation {...mockProps} />, {
features: {polarisSummerEditions2023: true},
});
it('adds showVerticalHoverPointer prop to the hovered item', () => {
const component = mountWithApp(<SecondaryNavigation {...mockProps} />);

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(<SecondaryNavigation {...mockProps} />, {
features: {polarisSummerEditions2023: true},
});
it('adds showVerticalLine prop to all the Item components before the matched item', () => {
const component = mountWithApp(<SecondaryNavigation {...mockProps} />);

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(<SecondaryNavigation {...mockProps} />, {
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(<SecondaryNavigation {...mockProps} />);

// 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,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ describe('<Nav.Item />', () => {
{
location: 'foo',
},
{features: {polarisSummerEditions2023: true}},
);

expect(item).toContainReactComponent(Icon, {
Expand All @@ -188,7 +187,6 @@ describe('<Nav.Item />', () => {
{
location: 'bar',
},
{features: {polarisSummerEditions2023: true}},
);

expect(item).toContainReactComponent(Icon, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe('<Option />', () => {

const input = mountWithApp(
<Option {...defaultProps} onClick={spy} allowMultiple />,
{features: {polarisSummerEditions2023: true}},
).find('input')!;
input.trigger('onClick');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function PolarisTestProvider({

const featuresConfig = useMemo(
() => ({
polarisSummerEditions2023: false,
polarisSummerEditions2023: true,
...features,
}),
[features],
Expand Down
21 changes: 0 additions & 21 deletions polaris-react/src/components/Tooltip/tests/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ describe('<Tooltip />', () => {
<Tooltip content="Inner content">
<Link>link content</Link>
</Tooltip>,
{features: {polarisSummerEditions2023: true}},
);

findWrapperComponent(tooltip)!.trigger('onMouseOver');
Expand Down Expand Up @@ -510,26 +509,6 @@ describe('<Tooltip />', () => {
});
});
});

// se23 - default border radius 1 replaced with 2
describe('polarisSummerEditions2023 false', () => {
it('renders content with the default border radius', () => {
const tooltip = mountWithApp(
<Tooltip content="Inner content">
<Link>link content</Link>
</Tooltip>,
{features: {polarisSummerEditions2023: false}},
);

findWrapperComponent(tooltip)!.trigger('onMouseOver');

expect(tooltip.find(TooltipOverlay)).toContainReactComponent('div', {
style: expect.objectContaining({
'--pc-tooltip-border-radius': 'var(--p-border-radius-1)',
}) as React.CSSProperties,
});
});
});
});

function findWrapperComponent(tooltip: any) {
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/tests/utilities/react-testing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const mountWithApp = createMount<
<PolarisTestProvider
i18n={translations}
features={{
polarisSummerEditions2023: process.env.SE23 === 'on',
polarisSummerEditions2023: true,
...features,
}}
{...rest}
Expand Down

0 comments on commit d091b9e

Please sign in to comment.