Skip to content
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

fix(app): fix restore default values button behavior #15017

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random nit but line 138 could be a console.error and have a more descriptive log, such as "should not hit here, this is a bad param"

onClick: () => showResetValuesModal(true),
}}
/>
Expand Down
Loading