Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ describe('StepNavigation', () => {
expect(queryByRole('button', { name: 'Continue' })).not.toBeInTheDocument();
expect(queryByRole('button', { name: 'Discard' })).not.toBeInTheDocument();
});

it('does not render buttons on the receipt step', async () => {
const { findByRole, queryByRole } = render(
<TestComponent onCall={mutationSpy} />,
);

userEvent.click(await findByRole('button', { name: 'Continue' }));
userEvent.click(await findByRole('button', { name: 'Continue' }));
userEvent.click(await findByRole('button', { name: 'Continue' }));
userEvent.click(await findByRole('button', { name: 'Submit' }));
userEvent.click(await findByRole('button', { name: 'Yes, Continue' }));

await waitFor(() => {
expect(queryByRole('button', { name: 'Back' })).not.toBeInTheDocument();
});

expect(queryByRole('button', { name: 'Continue' })).not.toBeInTheDocument();
expect(queryByRole('button', { name: 'Submit' })).not.toBeInTheDocument();
expect(queryByRole('button', { name: 'Discard' })).not.toBeInTheDocument();
});
});

describe('DiscardButton', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ export const StepNavigation: React.FC = () => {
const { currentIndex, steps, editing } = useSalaryCalculator();
const { allValid } = useAutosaveForm();

if (!editing) {
// We don't want to render navigation if on view mode or the receipt step
if (!editing || currentIndex === steps.length - 1) {
return null;
}

return (
<Box display="flex" justifyContent="space-between" alignItems="center">
{currentIndex < steps.length - 1 && <DiscardButton />}
<DiscardButton />

<Stack direction="row" spacing={theme.spacing(1)}>
<BackButton />
Expand Down
Loading