-
Notifications
You must be signed in to change notification settings - Fork 188
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-2428: E2E test for appointment scheduling #1062
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c85e691
Updated E2E tests for appointments
Vijaykv5 684effa
fix : Updated minor changes
Vijaykv5 b509bbb
fix : separated add,edit,delete appointments
Vijaykv5 1c5cbd1
feat : Update tests
Vijaykv5 16f590a
Comment out logic for selecting a location from the locations dropdown
denniskigen d463497
Comment out test case for cancelling a scheduled appointment
denniskigen a1b4310
Restore logic for Cancel case
denniskigen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { type Page } from '@playwright/test'; | ||
|
||
export class AppointmentsPage { | ||
constructor(readonly page: Page) {} | ||
|
||
readonly appointmentsTable = () => this.page.getByTestId('table'); | ||
|
||
async goto(uuid: string) { | ||
await this.page.goto(`/openmrs/spa/patient/${uuid}/chart/Appointments`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './home-page'; | ||
export * from './registration-and-edit-page'; | ||
export * from './patient-lists-page'; | ||
export * from './appointments-page'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { expect } from '@playwright/test'; | ||
import { generateRandomPatient, deletePatient, type Patient, startVisit, endVisit } from '../commands'; | ||
import { test } from '../core'; | ||
import { AppointmentsPage } from '../pages'; | ||
import { type Visit } from '@openmrs/esm-framework'; | ||
|
||
let patient: Patient; | ||
let visit: Visit; | ||
|
||
test.beforeEach(async ({ api }) => { | ||
patient = await generateRandomPatient(api); | ||
visit = await startVisit(api, patient.uuid); | ||
}); | ||
|
||
test('Add, edit and cancel an appointment', async ({ page, api }) => { | ||
const appointmentsPage = new AppointmentsPage(page); | ||
|
||
await test.step('When I go to the appointment tab in the patient chart', async () => { | ||
await appointmentsPage.goto(patient.uuid); | ||
}); | ||
|
||
await test.step('And I click on the “Add” button', async () => { | ||
await page.getByRole('button', { name: 'Add', exact: true }).click(); | ||
}); | ||
|
||
// FIXME: Login locations are failing to populate in this dropdown in the test environment | ||
// await test.step('And I select Mobile Clinic location', async () => { | ||
// await page.getByLabel('Select location').selectOption('Mobile Clinic'); | ||
// }); | ||
|
||
await test.step('And I select “Outpatient Department” service', async () => { | ||
await page.selectOption('select#service', { label: 'Outpatient Department' }); | ||
}); | ||
|
||
await test.step('And I make appointment as “Scheduled”', async () => { | ||
await page.getByLabel('Select an appointment type').selectOption('Scheduled'); | ||
}); | ||
|
||
await test.step('And I set date for tomorrow', async () => { | ||
const tomorrow = new Date(); | ||
tomorrow.setDate(tomorrow.getDate() + 1); | ||
await page.fill('input[placeholder="dd/mm/yyyy"]', tomorrow.toLocaleDateString('en-GB')); | ||
}); | ||
|
||
await test.step('And I set the “Duration” to 60', async () => { | ||
await page.getByLabel('Duration (minutes)').fill('60'); | ||
}); | ||
|
||
await test.step('And I add a note', async () => { | ||
await page | ||
.getByPlaceholder(/write any additional points here/i) | ||
.fill('A sample note for testing out the appointment scheduling flow'); | ||
}); | ||
|
||
await test.step('And I click Save button', async () => { | ||
await page.getByRole('button', { name: /save and close/i }).click(); | ||
}); | ||
|
||
await test.step('Then I should see a success message', async () => { | ||
await expect(page.getByText(/appointment scheduled/i)).toBeVisible(); | ||
}); | ||
|
||
await test.step('When I click the overflow menu on the table row with the newly created appointment', async () => { | ||
await page.getByRole('button', { name: 'Options' }).click(); | ||
}); | ||
|
||
await test.step('And I choose the "Edit" option from the popup menu', async () => { | ||
await page.getByRole('menuitem', { name: 'Edit' }).click(); | ||
}); | ||
|
||
await test.step('When I change to “Inpatient ward” location', async () => { | ||
await page.selectOption('select#service', { label: 'General Medicine service' }); | ||
}); | ||
|
||
await test.step('And I change to “General Medicine” Service', async () => { | ||
await page.getByLabel('Select a service').selectOption('General Medicine service'); | ||
}); | ||
|
||
await test.step('And I change the date to Today', async () => { | ||
const today = new Date(); | ||
today.setDate(today.getDate()); | ||
await page.fill('input[placeholder="dd/mm/yyyy"]', today.toLocaleDateString('en-GB')); | ||
}); | ||
|
||
await test.step('And I set the “Duration” of the appointment”', async () => { | ||
await page.getByLabel('Duration (minutes)').fill('80'); | ||
}); | ||
|
||
await test.step('And I change the note', async () => { | ||
await page | ||
.getByPlaceholder('Write any additional points here') | ||
.fill('A sample note for testing out the edit flow for scheduled appointments'); | ||
}); | ||
|
||
await test.step('And I click Save button', async () => { | ||
await page.getByRole('button', { name: /save and close/i }).click(); | ||
}); | ||
|
||
await test.step('Then I should see a success message', async () => { | ||
await expect(page.getByText(/appointment edited/i)).toBeVisible(); | ||
}); | ||
|
||
await test.step('When I click the "Today" tab', async () => { | ||
await page.getByRole('tab', { name: /today/i }).click(); | ||
}); | ||
|
||
await test.step('Then I click the options kebab menu in the appointment', async () => { | ||
await page.getByRole('button', { name: 'Options' }).click(); | ||
}); | ||
denniskigen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
await test.step('And I choose the "Cancel" option ', async () => { | ||
await page.getByRole('menuitem', { name: 'Cancel' }).click(); | ||
}); | ||
|
||
await test.step('When I click the "Cancel appointment" button to confirm', async () => { | ||
await page.getByRole('button', { name: 'danger Cancel appointment' }).click(); | ||
}); | ||
|
||
await test.step('Then I should see a success message', async () => { | ||
await expect(page.getByText(/appointment cancelled successfully/i)).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.afterEach(async ({ api }) => { | ||
await endVisit(api, visit.uuid); | ||
await deletePatient(api, patient.uuid); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as @denniskigen mentioned, this action changes the appointment date from what was set before (Tomorrow) to Today and thus requires in the preceding actions to switch the test to click on Today's tab before clicking the options menu...