generated from openmrs/openmrs-esm-template-app
-
Notifications
You must be signed in to change notification settings - Fork 14
(test) O3-3863: E2E tests for user onboarding tutorials #23
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
Open
harshthakkr
wants to merge
7
commits into
openmrs:main
Choose a base branch
from
harshthakkr:test/e2e-tests-for-user-onboarding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f7e780a
test: Add e2e tests for user onboarding tutorials
harshthakkr 1cd4294
test: Add types
harshthakkr 7e4d248
test: Minor changes
harshthakkr 041bb71
Re-trigger E2E tests
jayasanka-sack fb3333f
test: Requested changes
harshthakkr 4b6d717
Add @carbon/feature-flags to Jest `transformIgnorePatterns`
denniskigen c80ac41
Remove test timeout
denniskigen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,2 @@ | ||
| export * from './patient-operations'; | ||
| export * from './visit-operations'; |
This file contains hidden or 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,61 @@ | ||
| import { type APIRequestContext, expect } from '@playwright/test'; | ||
| import type { Patient } from '../types'; | ||
|
|
||
| export const generateRandomPatient = async (api: APIRequestContext): Promise<Patient> => { | ||
| const identifierRes = await api.post('idgen/identifiersource/8549f706-7e85-4c1d-9424-217d50a2988b/identifier', { | ||
| data: {}, | ||
| }); | ||
| await expect(identifierRes.ok()).toBeTruthy(); | ||
|
|
||
| const { identifier } = await identifierRes.json(); | ||
|
|
||
| const patientRes = await api.post('patient', { | ||
| // TODO: This is not configurable right now. It probably should be. | ||
| data: { | ||
| identifiers: [ | ||
| { | ||
| identifier, | ||
| identifierType: '05a29f94-c0ed-11e2-94be-8c13b969e334', | ||
| location: '44c3efb0-2583-4c80-a79e-1f756a03c0a1', | ||
| preferred: true, | ||
| }, | ||
| ], | ||
| person: { | ||
| addresses: [ | ||
| { | ||
| address1: 'Bom Jesus Street', | ||
| address2: '', | ||
| cityVillage: 'Recife', | ||
| country: 'Brazil', | ||
| postalCode: '50030-310', | ||
| stateProvince: 'Pernambuco', | ||
| }, | ||
| ], | ||
| attributes: [], | ||
| birthdate: '2020-02-01', | ||
| birthdateEstimated: false, | ||
| dead: false, | ||
| gender: 'M', | ||
| names: [ | ||
| { | ||
| familyName: `Smith${Math.floor(Math.random() * 10000)}`, | ||
| givenName: `John${Math.floor(Math.random() * 10000)}`, | ||
| middleName: '', | ||
| preferred: true, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }); | ||
| await expect(patientRes.ok()).toBeTruthy(); | ||
| return await patientRes.json(); | ||
| }; | ||
|
|
||
| export const getPatient = async (api: APIRequestContext, uuid: string): Promise<Patient> => { | ||
| const patientRes = await api.get(`patient/${uuid}?v=full`); | ||
| return await patientRes.json(); | ||
| }; | ||
|
|
||
| export const deletePatient = async (api: APIRequestContext, uuid: string) => { | ||
| await api.delete(`patient/${uuid}`, { data: {} }); | ||
| }; |
This file contains hidden or 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,31 @@ | ||
| import { type APIRequestContext, expect } from '@playwright/test'; | ||
| import { type Visit } from '@openmrs/esm-framework'; | ||
| import dayjs from 'dayjs'; | ||
|
|
||
| export const startVisit = async (api: APIRequestContext, patientId: string): Promise<Visit> => { | ||
| const visitRes = await api.post('visit', { | ||
| data: { | ||
| startDatetime: dayjs().subtract(1, 'D').format('YYYY-MM-DDTHH:mm:ss.SSSZZ'), | ||
| patient: patientId, | ||
| location: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID, | ||
| visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed', | ||
| attributes: [], | ||
| }, | ||
| }); | ||
|
|
||
| expect(visitRes.ok()).toBeTruthy(); | ||
| return await visitRes.json(); | ||
| }; | ||
|
|
||
| export const endVisit = async (api: APIRequestContext, visit: Visit) => { | ||
| const visitRes = await api.post(`visit/${visit.uuid}`, { | ||
| data: { | ||
| location: visit.location.uuid, | ||
| startDatetime: visit.startDatetime, | ||
| visitType: visit.visitType.uuid, | ||
| stopDatetime: dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'), | ||
| }, | ||
| }); | ||
|
|
||
| return await visitRes.json(); | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,96 @@ | ||
| import { test } from '@playwright/test'; | ||
| import { HomePage } from '../pages'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| test('Basic overview tutorial', async ({ page }) => { | ||
| const homePage = new HomePage(page); | ||
|
|
||
| await test.step('When I visit the home page', async () => { | ||
| await homePage.goto(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Help` button', async () => { | ||
| await homePage.helpButton().click(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Tutorials` button', async () => { | ||
| await page.getByText(/tutorials/i).click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the Tutorials modal', async () => { | ||
| await expect(page.getByRole('heading', { name: /tutorials/i })).toBeVisible(); | ||
| await expect( | ||
| page.getByText(/find walkthroughs and video tutorials on some of the core features of openmrs./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Basic Overview` tutorial', async () => { | ||
| await page | ||
| .locator('li') | ||
| .filter({ hasText: /basic overview/i }) | ||
| .locator('a', { hasText: /walkthrough/i }) | ||
| .click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the first tooltip', async () => { | ||
| await expect( | ||
| page.getByText( | ||
| /welcome to openmrs! this is the main dashboard where you can navigate to various features of the system./i, | ||
| ), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the second tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/this is the search icon. use it to find patients in the system quickly./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the third tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/this is the add patient icon. click here to register a new patient into the system./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the fourth tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/the user icon. click here to change your user preferences and settings./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the fifth tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/this table displays active visits. here you can see all the ongoing patient visits./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the last tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/this table shows appointments. view and manage patient appointments from this section./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Finish` button', async () => { | ||
| await homePage.finishButton().click(); | ||
| }); | ||
| }); |
This file contains hidden or 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,111 @@ | ||
| import { test } from '@playwright/test'; | ||
| import { HomePage } from '../pages'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| test('Demo tutorial', async ({ page }) => { | ||
| const homePage = new HomePage(page); | ||
|
|
||
| await test.step('When I visit the home page', async () => { | ||
| await homePage.goto(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Help` button', async () => { | ||
| await homePage.helpButton().click(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Tutorials` button', async () => { | ||
| await page.getByText(/tutorials/i).click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the Tutorial modal', async () => { | ||
| await expect(page.getByRole('heading', { name: /tutorials/i })).toBeVisible(); | ||
| await expect( | ||
| page.getByText(/find walkthroughs and video tutorials on some of the core features of openmrs./i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Tutorial for demo purposes` tutorial', async () => { | ||
| await page | ||
| .locator('li') | ||
| .filter({ hasText: /tutorial for demo purposes/i }) | ||
| .locator('a', { hasText: /walkthrough/i }) | ||
| .click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the first tooltip', async () => { | ||
| await expect(page.getByText(/let us walk through the tutorial features together./i)).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the second tooltip', async () => { | ||
| await expect( | ||
| page.getByText( | ||
| /click on this link. this step is configured to be automatic and will take you to the next step. once the given query selector resolves an element on the page, it will proceed automatically./i, | ||
| ), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Appointments` button', async () => { | ||
| await page.evaluate(() => { | ||
| document.querySelector('.react-joyride__overlay')?.setAttribute('style', 'z-index: 1 !important'); | ||
| }); | ||
| await page.getByRole('link', { name: /appointments/i }).click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the third tooltip', async () => { | ||
| await expect(page.getByText(/congrats! you have reached the clinical appointments dashboard./i)).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the fourth tooltip', async () => { | ||
| await expect( | ||
| page.getByText( | ||
| /Now, let’s see how this behaves when elements take a bit longer to load. Set your network throttling to "Slow 3G" and hit "Next"./i, | ||
| ), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the fifth tooltip', async () => { | ||
| await expect( | ||
| page.getByText( | ||
| /Let's navigate to the laboratory page. Our next target is the "Tests Ordered" table. I’ll disappear once you reach the laboratory page and reappear when the table is loaded. See you there!/i, | ||
| ), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Laboratory` button', async () => { | ||
| await page.getByRole('link', { name: /laboratory/i }).click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the sixth tooltip', async () => { | ||
| await expect( | ||
| page.getByText( | ||
| /it's me again. by default, i'll wait for the element to appear, so you don't have to worry about slow components when writing a new tutorial./i, | ||
| ), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
|
|
||
| await test.step('Then I should see the seventh tooltip', async () => { | ||
| await expect( | ||
| page.getByText(/Now let's do a fun exercise. Can you find out how to view a patient's allergies on your own?/i), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('And I click the `Next` button', async () => { | ||
| await homePage.nextButton().click(); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
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.
I had to use this at multiple instances (mostly for a button click) because Playwright was unable to interact with the button as it was covered by a tooltip overlay.
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.
Hi @harshthakkr, Could you please send a screenshot of this scenario?
Uh oh!
There was an error while loading. Please reload this page.
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.
Screen.Recording.2025-03-13.at.10.37.51.AM.mov
Playwright Error
Error: locator.click: Test timeout of 180000ms exceeded.
Call log:
getByRole('button', { name: 'Search patient' })<button type="button" name="SearchPatientIcon" aria-labe…>…</button><div role="presentation" data-test-id="overlay" class…>…</div> from <div id="react-joyride-portal">…</div>