[core] change FeatureFlagState to {On,Off}
This commit is contained in:
@@ -54,17 +54,16 @@ describe('ToggleFeatureFlagButton', () => {
|
||||
});
|
||||
|
||||
it('should disable the feature flag', () => {
|
||||
const Component = () =>
|
||||
withApiRegistry(<ToggleFeatureFlagButton />, featureFlags);
|
||||
const rendered = render(<Component />);
|
||||
window.localStorage.setItem('featureFlags', '{"enable-welcome-box":1}');
|
||||
|
||||
const rendered = render(
|
||||
withApiRegistry(<ToggleFeatureFlagButton />, featureFlags),
|
||||
);
|
||||
|
||||
const button = rendered.getByTestId('button-switch-feature-flag-state');
|
||||
expect(button).toBeInTheDocument();
|
||||
|
||||
expect(window.localStorage.featureFlags).toBeUndefined();
|
||||
fireEvent.click(button);
|
||||
expect(window.localStorage.featureFlags).toBe('{"enable-welcome-box":1}');
|
||||
rendered.rerender(<Component />);
|
||||
fireEvent.click(button);
|
||||
expect(window.localStorage.featureFlags).toBe('{"enable-welcome-box":0}');
|
||||
});
|
||||
|
||||
@@ -24,9 +24,10 @@ const ToggleFeatureFlagButton: FC<{}> = () => {
|
||||
const flagState = flags.get('enable-welcome-box');
|
||||
|
||||
const handleClick = () => {
|
||||
const newValue = flagState
|
||||
? FeatureFlagState.NotEnabled
|
||||
: FeatureFlagState.Enabled;
|
||||
const newValue =
|
||||
flagState === FeatureFlagState.On
|
||||
? FeatureFlagState.Off
|
||||
: FeatureFlagState.On;
|
||||
flags.set('enable-welcome-box', newValue);
|
||||
window.location.reload();
|
||||
};
|
||||
@@ -38,7 +39,7 @@ const ToggleFeatureFlagButton: FC<{}> = () => {
|
||||
onClick={handleClick}
|
||||
data-testid="button-switch-feature-flag-state"
|
||||
>
|
||||
{flagState === FeatureFlagState.NotEnabled
|
||||
{flagState === FeatureFlagState.On
|
||||
? 'Disable "enable-welcome-box" feature flag'
|
||||
: 'Enable "enable-welcome-box" feature flag'}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user