Skip to content

Commit

Permalink
🧪 test(eid): Cover deleting patients after they have been selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jan 9, 2025
1 parent 24d8ca8 commit f9ae4b5
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions test/app/client/patient/eids.app-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {fireEvent} from '@testing-library/dom';

import call from '../../../../imports/api/endpoint/call';
import insert from '../../../../imports/api/endpoint/patients/insert';
import remove from '../../../../imports/api/endpoint/patients/remove';
import createUserWithPassword from '../../../../imports/api/user/createUserWithPassword';

import {exampleEidXML} from '../../../../imports/api/_dev/populate/eids';
Expand Down Expand Up @@ -234,4 +235,105 @@ client(__filename, () => {

await findByText('streetandnumber-eid');
});

it('should handle deleted patients (open)', async () => {
const username = randomUserId();
const password = randomPassword();
const app = setupApp();
await createUserWithPassword(username, password);

const {findAllByRole, findByRole, findByText, user} = app;

const sex = 'female';

const formData = newPatientFormData({sex});

const {
niss,
firstname,
lastname,
birthdate,
photo,
streetandnumber,
zip,
municipality,
} = formData;

const patientId = await call(insert, formData);

const eidXML = exampleEidXML({
nationalnumber: niss,
dateofbirth: birthdate.replaceAll('-', ''),
photo,
name: lastname,
gender: sex,
firstname,
streetandnumber,
zip,
municipality,
});

await dropFiles(app, eidXML);

await findByRole('heading', {name: 'Select record to work with.'});

const buttons = await findAllByRole('button', {
name: new RegExp(` ${lastname} ${firstname} `, 'i'),
});
await user.click(buttons[0]!);

await user.click(await findByRole('button', {name: 'Next (1)'}));

await findByText(/^open$/i, {selector: 'button:not([disabled])'});

await call(remove, patientId);

await findByText(/^open$/i, {selector: 'button[disabled]'});
});

it('should handle deleted patient (update)', async () => {
const username = randomUserId();
const password = randomPassword();
const app = setupApp();
await createUserWithPassword(username, password);

const {findAllByRole, findByRole, findByText, user} = app;

const formData = newPatientFormData({
streetandnumber: 'streetandnumber-initial',
});

const {firstname, lastname} = formData;

const patientId = await call(insert, formData);

const eidXML = exampleEidXML({
name: lastname,
firstname,
streetandnumber: 'streetandnumber-eid',
});

await dropFiles(app, eidXML);

await findByRole('heading', {name: 'Select record to work with.'});

const buttons = await findAllByRole('button', {
name: new RegExp(` ${lastname} ${firstname} `, 'i'),
});
await user.click(buttons[0]!);

await user.click(await findByRole('button', {name: 'Next (1)'}));

await user.click(await findByRole('button', {name: 'Next'}));

await findByRole('button', {name: 'Update'});

await call(remove, patientId);

await user.click(await findByRole('button', {name: 'Update'}));

await findByText('Updating patient with eid info failed: [not-found].');

await findByText(/^open$/i, {selector: 'button[disabled]'});
});
});

0 comments on commit f9ae4b5

Please sign in to comment.