diff --git a/src/domain/johtoselvitys/Contacts.tsx b/src/domain/johtoselvitys/Contacts.tsx index 735d1af59..5d2e9f0c8 100644 --- a/src/domain/johtoselvitys/Contacts.tsx +++ b/src/domain/johtoselvitys/Contacts.tsx @@ -124,7 +124,7 @@ const CustomerFields: React.FC<{ invoicingOperator: null, sapCustomerNumber: null, }, - { shouldValidate: true }, + { shouldValidate: true, shouldDirty: true }, ); } } diff --git a/src/domain/johtoselvitys/JohtoselvitysForm.test.tsx b/src/domain/johtoselvitys/JohtoselvitysForm.test.tsx index 8dc20c97a..9ad8d259c 100644 --- a/src/domain/johtoselvitys/JohtoselvitysForm.test.tsx +++ b/src/domain/johtoselvitys/JohtoselvitysForm.test.tsx @@ -9,6 +9,7 @@ import { HankeData } from '../types/hanke'; import hankkeet from '../mocks/data/hankkeet-data'; import applications from '../mocks/data/hakemukset-data'; import { JohtoselvitysFormValues } from './types'; +import * as applicationApi from '../application/utils'; afterEach(cleanup); @@ -603,3 +604,17 @@ test('Validation error is shown if no work is about checkbox is selected', async ); expect(screen.queryByText('Kenttä on pakollinen')).toBeInTheDocument(); }); + +test('Form is saved when contacts are filled with orderer information', async () => { + const saveApplication = jest.spyOn(applicationApi, 'saveApplication'); + const { user } = render(); + + await user.click(screen.getByRole('button', { name: /yhteystiedot/i })); + await user.click( + screen.getByTestId('applicationData.customerWithContacts.customer.fillOwnInfoButton'), + ); + await user.click(screen.getByRole('button', { name: /edellinen/i })); + + expect(screen.queryByText(/hakemus tallennettu/i)).toBeInTheDocument(); + expect(saveApplication).toHaveBeenCalledTimes(1); +});