-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[ThemeProvider] Use the new context api #1396
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
Conversation
if (contextOne && 'logo' in contextOne) { | ||
themeContext = contextOne as CreateThemeContext; | ||
appProviderContext = contextTwo; | ||
appProviderContext = contextTwo as CreateAppProviderContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateThemeContext
and CreateAppProviderContext
don't have as much overlap anymore
it('is called when a keypress event is registered on the button', () => { | ||
const fakeEventData = {key: 'foo'}; | ||
const spy = jest.fn(); | ||
shallowWithAppProvider(<Button onKeyPress={spy}>Test</Button>).simulate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simulate was causing this test and the two below to stall and run indefinitely so I choose to use trigger
instead
expect(dateSelector.prop('filterMaxKey')).toBe(filterMaxKey); | ||
}); | ||
|
||
it('does not render Select with operator options', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DateSelector does render a select 😄
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('sets focused state to true when the navigation button is focused', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were purely visual tests, testing the inner state of the component
57e8ead
to
026f6d3
Compare
@@ -0,0 +1,21 @@ | |||
import * as React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This never had coverage and was causing codecov
to dip below 90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You think it would be worth adding tests to ensure the polaris
prop gets passed to the wrapped component?
|
||
describe('withAppProvider', () => { | ||
it('throws when polaris is not defined', () => { | ||
const consoleSpy = jest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to suppress the error message being throw
unsubscribe: mockUnsubscribe, | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this is so much more clear 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sorry for the delay on this
…11525) ### WHY are these changes introduced? Fix for [#1396](Shopify/polaris-internal#1396). ### WHAT is this pull request doing? Fixes incorrect border radius styles for `Button` inside the `ButtonGroup` where the `connectedTop` prop is applied. Also modifies the logic that originally applied a negative left margin for all segmented buttons to only apply on `variant="primary"` buttons. This was causing spacing issues where the width of the ButtonGroup was 1px smaller than the sibling element that it was supposed to match a 0 border radius with. <details> <summary>ButtonGroup connectedTop — before</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/cc8a6f6b-f0c7-4b06-a3d7-3a415e38d5d6" alt="ButtonGroup connectedTop — before"> </details> <details> <summary>ButtonGroup connectedTop — after</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/d3b037d3-835f-4ea3-91ef-4ee191a58186" alt="ButtonGroup connectedTop — after"> </details> ### How to 🎩 [Spin URL](https://admin.web.button-group-fix.lo-kim.us.spin.dev/store/shop1/settings/branding) - Scroll down to "Logo" card section - Click "Add a default logo" - Click the high five image and press done 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
…hopify#11525) ### WHY are these changes introduced? Fix for [Shopify#1396](Shopify/polaris-internal#1396). ### WHAT is this pull request doing? Fixes incorrect border radius styles for `Button` inside the `ButtonGroup` where the `connectedTop` prop is applied. Also modifies the logic that originally applied a negative left margin for all segmented buttons to only apply on `variant="primary"` buttons. This was causing spacing issues where the width of the ButtonGroup was 1px smaller than the sibling element that it was supposed to match a 0 border radius with. <details> <summary>ButtonGroup connectedTop — before</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/cc8a6f6b-f0c7-4b06-a3d7-3a415e38d5d6" alt="ButtonGroup connectedTop — before"> </details> <details> <summary>ButtonGroup connectedTop — after</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/d3b037d3-835f-4ea3-91ef-4ee191a58186" alt="ButtonGroup connectedTop — after"> </details> ### How to 🎩 [Spin URL](https://admin.web.button-group-fix.lo-kim.us.spin.dev/store/shop1/settings/branding) - Scroll down to "Logo" card section - Click "Add a default logo" - Click the high five image and press done 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
WHY are these changes introduced?
Part of #1377
WHAT is this pull request doing?
mountWithAppProvider
How to 🎩
Copy-paste this code in
playground/Playground.tsx
: