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

HAI-1917 Fix problem where form is not saved after filling contact information with user's own information #371

Merged
merged 1 commit into from
Sep 20, 2023
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
2 changes: 1 addition & 1 deletion src/domain/johtoselvitys/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const CustomerFields: React.FC<{
invoicingOperator: null,
sapCustomerNumber: null,
},
{ shouldValidate: true },
{ shouldValidate: true, shouldDirty: true },
);
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/domain/johtoselvitys/JohtoselvitysForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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(<JohtoselvitysContainer application={applications[0]} />);

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);
});
Loading