Skip to content

Commit

Permalink
test: make handle button active by downloading csv first
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Oct 9, 2024
1 parent 6c074d5 commit 3ab71f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const recoveryEndDate = Selector('#recovery-end-date');
const accordionItemTitle = 'div[role="heading"]';
const recoveryStartDateError = '#recovery-start-date-error';
const recoveryEndDateError = '#recovery-end-date-error';
const csvButton = Selector(
'button[data-testid="button-download-alteration-csv"]'
);
const handleButton = Selector('button').withText(
fi.applications.alterations.handling.actions.handle
);
Expand Down Expand Up @@ -110,16 +113,19 @@ test('Handler creates another alteration and tries to handle it with errors', as
)
);

// Attempt to submit the empty form, verify that validation fails
await t.click(handleButton);
// Verify that validation fails
await expectHandleButtonDisabled(t);
await t.click(csvButton);
await t.click(handleButton);

await t
.expect(
Selector('div').withText(
fi.applications.alterations.handling.error.calculationOutOfDate
).exists
)
.ok();

await t
.expect(
Selector('#recovery-justification-error').withText(
Expand Down Expand Up @@ -351,7 +357,9 @@ test('Handler handles the alteration from the last test properly', async (t: Tes
await t.typeText('#recovery-justification', 'Selvä kuin pläkki');

// Submit the handling form
await t.click(csvButton);
await t.click(handleButton);

const modal = Selector('div[role="dialog"]').withText(
fi.applications.alterations.handling.confirmation.recoverable.title
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const AlterationCsvButton: React.FC<AlterationCsvProps> = ({

return (
<Button
data-testid="button-download-alteration-csv"
theme={theme}
variant={secondary ? 'secondary' : 'primary'}
iconLeft={<IconDownload />}
Expand Down

0 comments on commit 3ab71f5

Please sign in to comment.