-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(compass-settings): update settings list and input component to …
…have more granular state subscription COMPASS-7098 (#4735) * chore(compass-settings): update settings list and input component to have more granular state subscription * chore(mocha-config-compass): set up preferences for all electron test environments
- Loading branch information
1 parent
2f7272d
commit a882c5c
Showing
15 changed files
with
300 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 25 additions & 16 deletions
41
packages/compass-settings/src/components/settings/oidc-settings.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,47 @@ | ||
import React from 'react'; | ||
import { render, screen, within } from '@testing-library/react'; | ||
import { cleanup, render, screen, within } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { spy } from 'sinon'; | ||
import { expect } from 'chai'; | ||
|
||
import { Provider } from 'react-redux'; | ||
import { OIDCSettings } from './oidc-settings'; | ||
import { configureStore } from '../../stores'; | ||
import { fetchSettings } from '../../stores/settings'; | ||
|
||
describe('OIDCSettings', function () { | ||
let container: HTMLElement; | ||
let onChangeSpy: sinon.SinonSpy; | ||
let store: ReturnType<typeof configureStore>; | ||
|
||
function getSettings() { | ||
return store.getState().settings.settings; | ||
} | ||
|
||
beforeEach(function () { | ||
onChangeSpy = spy(); | ||
render( | ||
<OIDCSettings | ||
onChange={onChangeSpy} | ||
preferenceStates={{}} | ||
currentValues={{} as any} | ||
/> | ||
beforeEach(async function () { | ||
store = configureStore(); | ||
await store.dispatch(fetchSettings()); | ||
const component = () => ( | ||
<Provider store={store}> | ||
<OIDCSettings /> | ||
</Provider> | ||
); | ||
render(component()); | ||
container = screen.getByTestId('oidc-settings'); | ||
}); | ||
|
||
['showOIDCDeviceAuthFlow'].forEach((option) => { | ||
afterEach(function () { | ||
cleanup(); | ||
}); | ||
|
||
['showOIDCDeviceAuthFlow', 'persistOIDCTokens'].forEach((option) => { | ||
it(`renders ${option}`, function () { | ||
expect(within(container).getByTestId(option)).to.exist; | ||
}); | ||
it(`calls onChange when ${option} is changed`, function () { | ||
expect(onChangeSpy.calledOnce).to.be.false; | ||
it(`changed ${option} value when option is clicked`, function () { | ||
const checkbox = within(container).getByTestId(option); | ||
const initialValue = getSettings()[option]; | ||
userEvent.click(checkbox, undefined, { | ||
skipPointerEventsCheck: true, | ||
}); | ||
expect(onChangeSpy.calledWith(option, true)).to.be.true; | ||
expect(getSettings()).to.have.property(option, !initialValue); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.