Skip to content

Commit

Permalink
(chore): Update the filter form e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nethmi Rodrigo authored and Nethmi Rodrigo committed Sep 10, 2024
1 parent 2d28d9a commit 392e672
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 46 deletions.
34 changes: 0 additions & 34 deletions e2e/pages/form-builder-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';

export class FormBuilderPage {
constructor(readonly page: Page) {}
Expand Down Expand Up @@ -60,39 +59,6 @@ export class FormBuilderPage {
await this.page.goto('form-builder');
}

async buildFormInteractively() {
await this.interactiveBuilderTab().click();
await this.startBuildingButton().click();
await this.interactiveFormNameInput().fill('Covid-19 Screening');
await this.interactiveFormDescriptionInput().fill('A test form for recording COVID-19 screening information');
await this.createFormButton().click();
await expect(this.page.getByText(/form created/i)).toBeVisible();

await this.addPageButton().click();
await this.pageNameInput().fill('Screening');
await this.savePageButton().click();
await expect(this.page.getByText(/new page created/i)).toBeVisible();

await this.addSectionButton().click();
await this.sectionNameInput().fill('Testing history');
await this.saveSectionButton().click();
await expect(this.page.getByText(/new section created/i)).toBeVisible();

await this.page.getByRole('button', { name: /^testing history$/i }).click();
await this.addQuestionButton().click();
await this.questionLabelInput().fill('Have you been ever been tested for COVID-19?');
await this.questionIdInput().fill('everTestedForCovid19');
await this.questionTypeDropdown().selectOption('obs');
await this.renderingTypeDropdown().selectOption('radio');
await this.conceptSearchInput().fill('Tested for COVID 19');
await this.conceptSearchInput().press('Enter');
await this.answer().click();
await this.selectAnswersDropdown().click();
await this.page.getByRole('option', { name: 'No' }).click();
await this.page.getByRole('option', { name: 'Yes' }).click();
await this.saveQuestionButton().click();
}

async saveForm() {
const formName = `A sample test form ${Math.floor(Math.random() * 10000)}`;

Expand Down
20 changes: 8 additions & 12 deletions e2e/specs/forms-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ test('Filter forms based on publish status', async ({ page }) => {

// Test the filter functionality
await test.step('Then I click the filter dropdown', async () => {
await page.getByText('Filter by:').click();
await formBuilderPage.page.getByRole('combobox', { name: /Filter by:/i }).click();
});

await test.step('And I click the Unpublished option', async () => await page.getByText('Unpublished').click());
await test.step('And I click the Unpublished option', async () =>
await formBuilderPage.page.getByText(/Unpublished/i).click());

// Expect the publish status to be "No"
const tagElements = await page.$$('div[data-testid="no-tag"]');
const firstTagElement = tagElements[0];

// Get the inner text of the tag element
const innerText = await firstTagElement.innerText();
await test.step('Then the forms list should only show unpublished forms', () => {
expect(innerText).toBe('No');
});
// Expect the list of forms to not have any published forms
await expect(
formBuilderPage.page.getByRole('table').filter({ has: formBuilderPage.page.getByTestId(/yes-tag/i) }),
).toHaveCount(0);
});

test('Search forms by name', async ({ page }) => {
Expand Down Expand Up @@ -65,7 +61,7 @@ test('Clicking on a form should navigate me to the editor', async ({ page }) =>
});

await test.step('And I click the `A sample test form` form', async () => {
await page.getByText('A sample test form').click();
await formBuilderPage.page.getByText('A sample test form').click();
});

await test.step('Then I should be navigated to the editor page', async () => {
Expand Down

0 comments on commit 392e672

Please sign in to comment.