Skip to content

Commit

Permalink
Add e2e tests to clinical views
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyjemutai committed Nov 8, 2024
1 parent fa2b1c8 commit 2f0733b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
6 changes: 3 additions & 3 deletions e2e/pages/home-page.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Page } from '@playwright/test';
import { type Page } from '@playwright/test';

export class HomePage {
constructor(readonly page: Page) {}

async goto() {
await this.page.goto(`home`);
async gotoHome() {
await this.page.goto('/openmrs/spa/clinical-views-builder');
}
}
69 changes: 69 additions & 0 deletions e2e/specs/clinical-views-configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { test, expect } from '@playwright/test';
import dotenv from 'dotenv';
import { HomePage } from '../pages';

dotenv.config();

test.describe('Clinical Views - Configure and Edit Tab Definition', () => {
test('should configure dashboard and edit tab definition', async ({ page }) => {
const homePage = new HomePage(page);

await test.step('Navigate to the Home page', async () => {
await homePage.gotoHome();
await expect(page).toHaveURL(`${process.env.E2E_BASE_URL}/spa/clinical-views-builder`);
});

await test.step('Click on "Create a new clinical view"', async () => {
await page.getByRole('button', { name: 'Create a new clinical view' }).click();
});

await test.step('Import dummy schema and verify options', async () => {
await page.getByRole('button', { name: 'Input dummy schema' }).click();

await expect(page.getByRole('button', { name: 'First Menu' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Second Menu' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Add Clinical view submenu' })).toBeVisible();
});
await test.step('Click "First Menu" and configure dashboard', async () => {
await page.getByRole('button', { name: 'First Menu' }).click();
await page.getByRole('button', { name: 'Configure dashboard' }).click();

await page.getByLabel('Select Widget').selectOption('encounter-list-table-tabs');

await page.locator('input#tabName').fill('TabA');
await page.locator('input#displayTitle').fill('TabB');

await page.getByRole('button', { name: 'Create Submenu' }).click();
await expect(page.locator('text=Success!')).toBeVisible({ timeout: 60000 });
});

await test.step('Configure columns', async () => {
await page.getByRole('button', { name: 'Configure columns' }).click();
await page.getByRole('combobox', { name: 'Form:' }).click();
await page.getByText('Mental Health Assessment Form').click();
await page.getByLabel('Select concept').selectOption('167006AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('e.g. Visit title').fill('a');
await page.getByRole('button', { name: 'Create Submenu' }).click();
});

await test.step('Edit tab definition', async () => {
await page.getByLabel('Edit tab definition').click();
await page.getByLabel('Tab name').fill('TitleA');
await page.getByLabel('Header title').fill('TitleB');
await page.getByRole('button', { name: 'Save', exact: true }).click();

await expect(page.locator('text=Tab edited successfully')).toBeVisible({ timeout: 60000 });
});

await test.step('Delete tab definition', async () => {
await page.getByLabel('Delete tab definition').click();
await expect(page.getByRole('heading', { name: 'Are you sure you want to' })).toBeVisible();
await expect(page.getByRole('dialog').getByText('Menu Slot : first-menu-slot')).toBeVisible();
await expect(page.getByText('Tab name : TitleA')).toBeVisible();
await expect(page.getByText('Header title : TitleB')).toBeVisible();

await page.getByRole('button', { name: 'Delete configuration' }).click();
await expect(page.getByText('Tab configuration deleted')).toBeVisible();
});
});
});
11 changes: 0 additions & 11 deletions e2e/specs/sample-test.spec.ts

This file was deleted.

0 comments on commit 2f0733b

Please sign in to comment.