Skip to content

Commit

Permalink
fix(app): fix restore default values button behavior (#15017)
Browse files Browse the repository at this point in the history
* fix(app): fix restore default values button behavior
  • Loading branch information
koji committed May 1, 2024
1 parent 4eac5a2 commit b73b082
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/organisms/ChildNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export function ChildNavigation({
{onClickButton != null && buttonText != null ? (
<Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing8}>
{secondaryButtonProps != null ? (
<SmallButton {...secondaryButtonProps} />
<SmallButton
data-testid="ChildNavigation_Secondary_Button"
{...secondaryButtonProps}
/>
) : null}

<SmallButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('ProtocolSetupParameters', () => {
.calledWith(expect.anything())
.thenReturn({ createRun: mockCreateRun } as any)
})

it('renders the parameters labels and mock data', () => {
render(props)
screen.getByText('Parameters')
Expand All @@ -63,27 +64,39 @@ describe('ProtocolSetupParameters', () => {
screen.getByText('Dry Run')
screen.getByText('a dry run description')
})

it('renders the ChooseEnum component when a str param is selected', () => {
render(props)
fireEvent.click(screen.getByText('Default Module Offsets'))
screen.getByText('mock ChooseEnum')
})

it('renders the other setting when boolean param is selected', () => {
render(props)
expect(screen.getAllByText('On')).toHaveLength(2)
fireEvent.click(screen.getByText('Dry Run'))
expect(screen.getAllByText('On')).toHaveLength(3)
})

it('renders the back icon and calls useHistory', () => {
render(props)
fireEvent.click(screen.getAllByRole('button')[0])
expect(mockGoBack).toHaveBeenCalled()
})

it('renders the confirm values button and clicking on it creates a run', () => {
render(props)
fireEvent.click(screen.getByRole('button', { name: 'Confirm values' }))
expect(mockCreateRun).toHaveBeenCalled()
})

it('should restore default values button is disabled when tapping confirm values button', async () => {
render(props)
const resetButton = screen.getByTestId('ChildNavigation_Secondary_Button')
fireEvent.click(screen.getByText('Confirm values'))
expect(resetButton).toBeDisabled()
})

it('renders the reset values modal', () => {
render(props)
fireEvent.click(
Expand Down
1 change: 1 addition & 0 deletions app/src/organisms/ProtocolSetupParameters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export function ProtocolSetupParameters({
secondaryButtonProps={{
buttonType: 'tertiaryLowLight',
buttonText: t('restore_defaults'),
disabled: isLoading || startSetup,
onClick: () => showResetValuesModal(true),
}}
/>
Expand Down

0 comments on commit b73b082

Please sign in to comment.