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

(fix) O3-2284: Fix failing patient registration test #763

Merged
merged 12 commits into from
Aug 7, 2023
2 changes: 1 addition & 1 deletion e2e/commands/patient-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const generateRandomPatient = async (api: APIRequestContext): Promise<Pat
],
attributes: [],
birthdate: '2020-2-1',
Piumal1999 marked this conversation as resolved.
Show resolved Hide resolved
birthdateEstimated: true,
birthdateEstimated: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. If we use birthdayEstimated as true, it will take the patient as a "patient with an unknown birthdate". So when we go to the edit patient page, it will automatically use the "Birthdate unknown" option.

image

(That change was added with 7dbf922. And the tests were failing after that)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS While it may not matter much, it's less ambiguous (and more likely to work everywhere) if we stick to ISO 8601 for dates, i.e., 2020-02-01.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's right. I changed the date format.

dead: false,
gender: 'M',
names: [
Expand Down
6 changes: 5 additions & 1 deletion e2e/pages/registration-and-edit-page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Locator, Page } from '@playwright/test';
import { Locator, Page, expect } from '@playwright/test';

export type PatientRegistrationSex = 'male' | 'female' | 'other' | 'unknown';

Expand Down Expand Up @@ -40,6 +40,10 @@ export class RegistrationAndEditPage {
await this.page.goto(editPatientUuid ? `patient/${editPatientUuid}/edit` : 'patient-registration');
}

async waitUntilTheFormIsLoaded() {
await expect(this.createPatientButton()).toBeEnabled();
}

async fillPatientRegistrationForm(formValues: PatientRegistrationFormValues) {
const tryFill = (locator: Locator, value?: string) => value && locator.fill(value);
formValues.sex && (await this.sexRadioButton(formValues.sex).check());
Expand Down
1 change: 1 addition & 0 deletions e2e/specs/edit-patient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test('Edit a patient', async ({ page, api }) => {

await test.step("When I visit the registration page to a patient's details", async () => {
await patientEditPage.goto(patient.uuid);
await patientEditPage.waitUntilTheFormIsLoaded();
});

await test.step('And then I click on fill new values into the registration form and then click the `Submit` button', async () => {
Expand Down
1 change: 1 addition & 0 deletions e2e/specs/register-new-patient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test('Register a new patient', async ({ page, api }) => {

await test.step('When I visit the registration page', async () => {
await patientRegistrationPage.goto();
await patientRegistrationPage.waitUntilTheFormIsLoaded();
});

await test.step('And then I click on fill new values into the registration form and then click the `Submit` button', async () => {
Expand Down
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This is an example environment file for configuring dynamic values.
E2E_BASE_URL=http://localhost:8080/openmrs
E2E_BASE_URL=https://dev3.openmrs.org/openmrs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if the example setup didn't point at dev3. We need to limit the usage of dev3 for automated testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just wanted to verify that it works with dev3. The patient registration didn't pass when running locally. It fails to load the patient-chart view after creating a patient. I'm still looking into fixing that bug.

image

I'm going to revert the line after it is resolved.

E2E_USER_ADMIN_USERNAME=admin
E2E_USER_ADMIN_PASSWORD=Admin123
E2E_LOGIN_DEFAULT_LOCATION_UUID=44c3efb0-2583-4c80-a79e-1f756a03c0a1
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config: PlaywrightTestConfig = {
testDir: './e2e/specs',
timeout: 3 * 60 * 1000,
expect: {
timeout: 40 * 1000,
timeout: 60 * 1000,
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
Expand Down