Skip to content

Commit 318addc

Browse files
authored
fix(stage-wizard): show toggle button when feature flag is enabled (#4228)
1 parent 73b68d1 commit 318addc

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/pipeline-extra-settings.spec.tsx

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { SinonSandbox } from 'sinon';
77
import { spy, createSandbox } from 'sinon';
88

99
import { PipelineExtraSettings } from './pipeline-extra-settings';
10+
import preferences from 'compass-preferences-model';
11+
import sinon from 'sinon';
1012

1113
const renderPipelineExtraSettings = (
1214
props: Partial<ComponentProps<typeof PipelineExtraSettings>> = {}
@@ -67,27 +69,40 @@ describe('PipelineExtraSettings', function () {
6769
expect(within(container).getByTestId('pipeline-builder-toggle')).to.exist;
6870
});
6971

70-
it('calls onToggleSidePanel when clicked', function () {
71-
const onToggleSidePanelSpy = spy();
72-
renderPipelineExtraSettings({ onToggleSidePanel: onToggleSidePanelSpy });
73-
const container = screen.getByTestId('pipeline-toolbar-extra-settings');
74-
const button = within(container).getByTestId(
75-
'pipeline-toolbar-side-panel-button'
76-
);
77-
expect(button).to.exist;
78-
expect(onToggleSidePanelSpy.calledOnce).to.be.false;
79-
userEvent.click(button);
80-
expect(onToggleSidePanelSpy.calledOnce).to.be.true;
81-
});
72+
describe('stage wizard', function () {
73+
let sandbox: sinon.SinonSandbox;
74+
beforeEach(function () {
75+
sandbox = sinon.createSandbox();
76+
sandbox
77+
.stub(preferences, 'getPreferences')
78+
.returns({ useStageWizard: true } as any);
79+
});
80+
afterEach(function () {
81+
sandbox.restore();
82+
});
8283

83-
it('disables toggle side panel button in text mode', function () {
84-
renderPipelineExtraSettings({
85-
pipelineMode: 'as-text',
84+
it('calls onToggleSidePanel when clicked', function () {
85+
const onToggleSidePanelSpy = spy();
86+
renderPipelineExtraSettings({ onToggleSidePanel: onToggleSidePanelSpy });
87+
const container = screen.getByTestId('pipeline-toolbar-extra-settings');
88+
const button = within(container).getByTestId(
89+
'pipeline-toolbar-side-panel-button'
90+
);
91+
expect(button).to.exist;
92+
expect(onToggleSidePanelSpy.calledOnce).to.be.false;
93+
userEvent.click(button);
94+
expect(onToggleSidePanelSpy.calledOnce).to.be.true;
95+
});
96+
97+
it('disables toggle side panel button in text mode', function () {
98+
renderPipelineExtraSettings({
99+
pipelineMode: 'as-text',
100+
});
101+
expect(
102+
screen
103+
.getByTestId('pipeline-toolbar-side-panel-button')
104+
.getAttribute('aria-disabled')
105+
).to.equal('true');
86106
});
87-
expect(
88-
screen
89-
.getByTestId('pipeline-toolbar-side-panel-button')
90-
.getAttribute('aria-disabled')
91-
).to.equal('true');
92107
});
93108
});

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/pipeline-extra-settings.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { changePipelineMode } from '../../../modules/pipeline-builder/pipeline-m
1717
import type { PipelineMode } from '../../../modules/pipeline-builder/pipeline-mode';
1818
import { getIsPipelineInvalidFromBuilderState } from '../../../modules/pipeline-builder/builder-helpers';
1919
import { toggleSidePanel } from '../../../modules/side-panel';
20+
import { usePreference } from 'compass-preferences-model';
2021

2122
const containerStyles = css({
2223
display: 'flex',
@@ -57,6 +58,7 @@ export const PipelineExtraSettings: React.FunctionComponent<
5758
onToggleSettings,
5859
onToggleSidePanel,
5960
}) => {
61+
const showStageWizard = usePreference('useStageWizard', React);
6062
return (
6163
<div
6264
className={containerStyles}
@@ -105,15 +107,17 @@ export const PipelineExtraSettings: React.FunctionComponent<
105107
Text
106108
</SegmentedControlOption>
107109
</SegmentedControl>
108-
<IconButton
109-
title="Toggle Side Panel"
110-
aria-label="Toggle Side Panel"
111-
onClick={() => onToggleSidePanel()}
112-
data-testid="pipeline-toolbar-side-panel-button"
113-
disabled={pipelineMode === 'as-text'}
114-
>
115-
<Icon glyph="Filter" />
116-
</IconButton>
110+
{showStageWizard && (
111+
<IconButton
112+
title="Toggle Side Panel"
113+
aria-label="Toggle Side Panel"
114+
onClick={() => onToggleSidePanel()}
115+
data-testid="pipeline-toolbar-side-panel-button"
116+
disabled={pipelineMode === 'as-text'}
117+
>
118+
<Icon glyph="Filter" />
119+
</IconButton>
120+
)}
117121
<IconButton
118122
title="More Settings"
119123
aria-label="More Settings"

0 commit comments

Comments
 (0)