Skip to content

Commit

Permalink
OZ-534: Refactor Ozone e2e test suite README into Ozone docs + Cleanu…
Browse files Browse the repository at this point in the history
…p code base
  • Loading branch information
kdaud committed Apr 4, 2024
1 parent 66ab49a commit 3317dda
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 183 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/foss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: '20.x'

- name: Cache dependencies
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
Expand All @@ -49,7 +49,7 @@ jobs:
run: npm run fossE2ETests

- name: Upload report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: '20.x'

- name: Cache dependencies
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Upload report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
Expand Down
84 changes: 8 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,11 @@
# Ozone E2E Test Suite
<h2 align="center">Ozone E2E Test Suite</h2>

[![Ozone E2E Tests](https://github.com/ozone-his/ozone-e2e/actions/workflows/pro.yml/badge.svg)](https://github.com/ozone-his/ozone-e2e/actions/workflows/pro.yml)
<p align="center">
Welcome to the end-to-end automated tests for all Ozone HIS workflow!
</p>

Welcome to Ozone automated test suite.
<h2 align="center">Developer Guide</h2>

- [Setup Steps](#setup-steps)
* [Step 1. Setup the project](#step-1-setup-the-project)
* [Step 2. Run Ozone e2e tests](#step-2-run-ozone-e2e)
- [Configurations](#configurations)
- [Project Structure](#project-structure)
- [Guide for writing tests](#guide-for-writing-tests)
- [GitHub Actions integration](#github-actions-integration)

<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>(Table of contents generated with markdown-toc)</a></i></small>

## Setup Steps

### Step 1. Setup the project

Clone the project

```sh
git clone https://github.com/ozone-his/ozone-e2e
```
Navigate into the project

```sh
cd ozone-e2e
```

Install dependencies
```sh
yarn install
```

### Step 2. Run Ozone e2e tests

```sh
npx playwright test
```
## Configurations

This is underdevelopement/WIP. At the moment, there exists a git-shared
`.env` file used for configuring environment variables.

By default, the test suite will run against Ozone dev server.
You can override it by changing the environment variables beforehand:

```sh
# Ex: Set the server URL here
export E2E_BASE_URL=https://ozone-dev.mekomsolutions.net
```

## Project Structure
The project uses the Playwright test runner and,
generally, follows a very simple project structure:

```
e2e
|__ tests
| ^ Contains test cases
|__ utils
| ^ Contains utilities needed to setup and tear down
| tests as well as methods required by the tests to run
```

## Guide for writing tests

When writing a new test case, create a new spec in `./e2e/tests`

## GitHub Actions integration
The pro.yml workflow is split into two jobs, one that runs upon _Git pull requests_, and _Git push(es)_. The other runs tests on an environment specified during runtime. The difference between the two is that, the later is run manually via GitHub Actions. Note: When manually running the tests, you need to choose the test environment at runtime.

<img src="readme/choose_test_environment.png" alt="Choose Test Environment" width="1000"/>

The foss.yml workflow contains one job that runs Ozone FOSS specific tests. Note: You need to provide O3, Odoo and SENAITE base URLs at runtime.

<img src="readme/user_inputs.png" alt="User Inputs" width="1000"/>
<p align="center">
A technical guide to help developer building and running the project can be found [here](https://docs.ozone-his.com/devs/e2e-tests).
</p>
39 changes: 15 additions & 24 deletions e2e/tests/testAnalyticsIntegration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { E2E_BASE_URL, E2E_ANALYTICS_URL } from '../utils/configs/globalSetup';
let homePage: HomePage;

test.beforeEach(async ({ page }) => {
const homePage = new HomePage(page);
homePage = new HomePage(page);
await homePage.initiateLogin();

await expect(page).toHaveURL(/.*home/);
});

test('Adding an OpenMRS patient syncs patient into patients table in Superset', async ({ page }) => {
const homePage = new HomePage(page);
// setup
homePage = new HomePage(page);
await homePage.goToSuperset();
await expect(page).toHaveURL(/.*superset/);
await homePage.selectDBSchema();
Expand Down Expand Up @@ -47,7 +47,6 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset',
let patientQuery = `SELECT * FROM patients WHERE identifiers like 'OpenMRS ID: ${patientIdentifier}';`;
await page.getByRole('textbox').fill(patientQuery);
await homePage.runSQLQuery();

let patientGivenName = await page.getByText(`${patientName.firstName}`);
let patientFamilyName = await page.getByText(`${patientName.givenName}`);
let patientGender = await page.getByText('M', { exact: true });
Expand All @@ -60,7 +59,8 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset',
});

test('Starting an OpenMRS visit syncs visit into visits table in Superset', async ({ page }) => {
const homePage = new HomePage(page);
// setup
homePage = new HomePage(page);
await homePage.createPatient();
await homePage.goToSuperset();
await expect(page).toHaveURL(/.*superset/);
Expand Down Expand Up @@ -91,11 +91,9 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn

await page.getByRole('tab', { name: 'Query history' }).click();
await homePage.clearSQLEditor();

let patientVisitQuery = `SELECT * FROM visits WHERE patient_uuid like '${patient_uuid}';`;
await page.getByRole('textbox').first().fill(patientVisitQuery);
await homePage.runSQLQuery();

let patientVisitType = await page.getByText('Facility Visit');
const patientGender = await page.getByText('M', {exact: true });
let patientAgeAtVisit = Number(await page.getByText('24', {exact: true }).nth(0).textContent());
Expand All @@ -108,7 +106,8 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn
});

test('Creating an OpenMRS order syncs order into orders table in Superset', async ({ page }) => {
const homePage = new HomePage(page);
// setup
homePage = new HomePage(page);
await homePage.createPatient();
await homePage.searchOpenMRSPatientID();
const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent();
Expand Down Expand Up @@ -155,7 +154,6 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn
let orderQuery = `SELECT * FROM orders WHERE patient_id=${patientIdValue};`;
await page.getByRole('textbox').first().fill(orderQuery);
await homePage.runSQLQuery();

let orderTypeName = await page.getByText('Test Order' );
let encounterTypeName = await page.getByText('Consultation', { exact: true });

Expand All @@ -166,7 +164,8 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn
});

test('Adding an OpenMRS encounter syncs encounter into encounters table in Superset', async ({ page }) => {
const homePage = new HomePage(page);
// setup
homePage = new HomePage(page);
await homePage.createPatient();
await homePage.searchOpenMRSPatientID();
const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent();
Expand Down Expand Up @@ -221,13 +220,11 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super
await page.getByRole('textbox').fill(encounterTypeUuidQuery);
await homePage.runSQLQuery();
let encounterTypeUuidValue = await page.locator('div.virtual-table-cell').textContent();

await page.getByRole('tab', { name: 'Results' }).click();
await homePage.clearSQLEditor();
let encounterQuery = `SELECT * FROM encounters WHERE encounter_id=${encounterIdValue} AND encounter_type_uuid like '${encounterTypeUuidValue}';`;
await page.getByRole('textbox').first().fill(encounterQuery);
await homePage.runSQLQuery();

let encounterTypeName = await page.getByText('Consultation', { exact: true });
let visitTypeName = await page.getByText('Facility Visit');

Expand All @@ -238,7 +235,8 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super
});

test('Adding an OpenMRS condition syncs condition into conditions table in Superset', async ({ page }) => {
const homePage = new HomePage(page);
// setup
homePage = new HomePage(page);
await homePage.createPatient();
await homePage.searchOpenMRSPatientID();
const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent();
Expand Down Expand Up @@ -282,7 +280,6 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super
let conditionQuery = `SELECT * FROM conditions WHERE patient_id=${patientIdValue};`;
await page.getByRole('textbox').first().fill(conditionQuery);
await homePage.runSQLQuery();

let clinicalStatus = await page.getByText('ACTIVE');
let onSetDate = await page.getByText('2023-07-27');

Expand Down Expand Up @@ -330,7 +327,6 @@ test('Adding an OpenMRS observation syncs observation into observations table in
let observationsQuery = `SELECT * FROM observations WHERE patient_uuid like '${patient_uuid}';`;
await page.getByRole('textbox').fill(observationsQuery);
await homePage.runSQLQuery();

let firstConceptName = await page.getByText('Circonférence du haut du bras').first();
let secondConceptName = await page.getByText('Taille (cm)').first();
let thirdConceptName = await page.getByText('Weight (kg)').first();
Expand All @@ -353,8 +349,7 @@ test('Adding an OpenMRS observation syncs observation into observations table in

test('Adding an OpenMRS appointment syncs appointment into appointments table in Superset', async ({ page }) => {
// setup
const homePage = new HomePage(page);

homePage = new HomePage(page);
await homePage.createPatient();
await homePage.searchOpenMRSPatientID();
const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent();
Expand All @@ -366,7 +361,6 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in
let appointmentsCountQuery = `SELECT COUNT(*) FROM appointments;`
await page.getByRole('textbox').first().fill(appointmentsCountQuery);
await homePage.runSQLQuery();

const initialNumberOfAppointments = await page.locator('div.virtual-table-cell').textContent();
let initialAppointmentsCount = Number(initialNumberOfAppointments);
await page.getByRole('tab', { name: 'Query history' }).click();
Expand Down Expand Up @@ -399,7 +393,6 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in
let appointmentQuery = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`;
await page.getByRole('textbox').first().fill(appointmentQuery);
await homePage.runSQLQuery();

let appointmentStatus = await page.getByText('Scheduled').first();

await expect(appointmentStatus).toContainText('Scheduled');
Expand All @@ -409,7 +402,7 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in

test('Voiding an OpenMRS observation updates observations dataset in Superset', async ({ page }) => {
// setup
const homePage = new HomePage(page);
homePage = new HomePage(page);
await homePage.createPatient();
await homePage.startPatientVisit();
const patient_uuid = await homePage.getPatientUUID();
Expand All @@ -421,13 +414,12 @@ test('Voiding an OpenMRS observation updates observations dataset in Superset',
await homePage.selectDBSchema();
await homePage.clearSQLEditor();
let obsVoidedQuery = `SELECT obs_voided FROM Observations WHERE patient_uuid like '${patient_uuid}';`;

await page.getByRole('textbox').first().fill(obsVoidedQuery);
await homePage.runSQLQuery();

let firstObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(1)');
let secondObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(2)');
let thirdObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(3)');

await expect(firstObsVoidedState).toContainText('false');
await expect(secondObsVoidedState).toContainText('false');
await expect(thirdObsVoidedState).toContainText('false');
Expand All @@ -439,7 +431,6 @@ test('Voiding an OpenMRS observation updates observations dataset in Superset',
// verify
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();

await page.getByRole('textbox').first().fill(obsVoidedQuery);
await homePage.runSQLQuery();

Expand All @@ -452,7 +443,7 @@ test('Voiding an OpenMRS observation updates observations dataset in Superset',
});

test.afterEach(async ({ page }) => {
const homePage = new HomePage(page);
homePage = new HomePage(page);
await homePage.deletePatient();
await page.close();
});
Loading

0 comments on commit 3317dda

Please sign in to comment.