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

(test) O3-2943: E2E test for Immunizations workflow #2148

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 12 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
76 changes: 75 additions & 1 deletion e2e/specs/immunizations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.beforeEach(async ({ api }) => {
visit = await startVisit(api, patient.uuid);
});

test('Add an immunization', async ({ page }) => {
test('Add and edit an immunization', async ({ page }) => {
const immunizationsPage = new ImmunizationsPage(page);
const headerRow = immunizationsPage.immunizationsTable().locator('thead > tr');
const immunizationType = immunizationsPage.immunizationsTable().locator('tbody td:nth-child(2)');
Expand Down Expand Up @@ -55,6 +55,80 @@ test('Add an immunization', async ({ page }) => {
await expect(immunizationType).toContainText(/hepatitis b vaccination/i);
await expect(vaccinationDate).toContainText(/mar 8, 2024/i);
});

await test.step('When I click the expand All rows in the table header with the newly recorded immunization', async () => {
await page.getByRole('button', { name: /expand all rows/i }).click();
});

await test.step('Then I should see the immunization saved row in the table', async () => {
await expect(page.getByText(/dose number within series/i)).toBeVisible();
await expect(page.getByText(/vaccination date/i)).toBeVisible();
});

await test.step('And I click on the `Edit` button', async () => {
await page.getByRole('button', { name: /edit/i }).click();
});

await test.step('Then I should see the immunization form launch in the workspace in edit mode`', async () => {
await expect(page.getByText(/immunization form/i)).toBeVisible();
await expect(page.getByRole('cell', { name: /hepatitis b vaccination/i })).toBeVisible();
});

await test.step('When I change the immunization type to `measles vaccination`', async () => {
await page.getByRole('combobox', { name: /immunization/i }).click();
await page.getByText(/measles vaccination/i).click();
});

await test.step('And I change `08/03/2024` to `02/01/2025` as the updated vaccination date', async () => {
await page.getByLabel(/vaccination date/i).clear();
await page.getByLabel(/vaccination date/i).fill('02/01/2025');
await page.getByLabel(/vaccination date/i).press('Tab');
});

await test.step('And I change the immunization Dose number within series to `2`', async () => {
await page.getByRole('spinbutton', { name: /dose number within series/i }).clear();
await page.getByRole('spinbutton', { name: /dose number within series/i }).fill('2');
Muta-Jonathan marked this conversation as resolved.
Show resolved Hide resolved
});

Copy link
Member

Choose a reason for hiding this comment

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

Could you also modify the vaccination date?

await test.step('And I click on the `Save` button', async () => {
await page.getByRole('button', { name: /save/i }).click();
});

await test.step('Then I should see a success notification', async () => {
await expect(page.getByText(/vaccination saved successfully/i)).toBeVisible();
});

await test.step('Then I attempt to click the Collapse All Rows button in the table header if visible', async () => {
const collapseButton = page.getByRole('button', { name: /collapse all rows/i });
if (!(await collapseButton.isVisible())) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need this logic?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes locally this is not checked however on the CI needs to be checked because sometimes after reloading the page the collapse comes expanded instead

return;
}
await collapseButton.click();
});

await test.step('And I should see the updated immunization in the list', async () => {
await expect(page.getByRole('columnheader', { name: /vaccine/i })).toContainText(/vaccine/i);
await expect(page.getByText(/recent vaccination/i)).toBeVisible();
await expect(page.getByRole('cell', { name: /measles vaccination/i })).toBeVisible();
});

await test.step('When I attempt to click the expand All rows in the table header with the updated recorded immunization if visible', async () => {
const expandButton = page.getByRole('button', { name: /expand all rows/i });
if (!(await expandButton.isVisible())) {
return;
}
await expandButton.click();
});

await test.step('Then I should see the immunization updated Dose number saved row in the table as `2`', async () => {
await expect(page.getByText(/dose number within series/i)).toBeVisible();
await expect(page.getByRole('cell', { name: '2', exact: true })).toBeVisible();
});

await test.step('And I should see the immunization updated date saved row in the table as `02-Jan-2025`', async () => {
await expect(page.getByText(/vaccination date/i)).toBeVisible();
await expect(page.getByRole('cell', { name: '02-Jan-2025', exact: true })).toBeVisible();
});
});

test.afterEach(async ({ api }) => {
Expand Down
Loading