diff --git a/e2e/specs/immunizations.spec.ts b/e2e/specs/immunizations.spec.ts index b8de61d676..eec28ee9dc 100644 --- a/e2e/specs/immunizations.spec.ts +++ b/e2e/specs/immunizations.spec.ts @@ -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)'); @@ -55,6 +55,48 @@ 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 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'); + }); + + 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('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(); + }); }); test.afterEach(async ({ api }) => {