Skip to content

Commit

Permalink
[frontend] e2e tests added for create and delete investigation (#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBouzinFiligran committed Mar 28, 2024
1 parent b2dd23d commit 914ac83
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from '../fixtures/baseFixtures';
import InvestigationPage from '../model/investigation.pageModel';
import InvestigationFormPage from '../model/investigationForm.pageModel';

test('createInvestigation', async ({ page }) => {
// BEFORE
const investigationPage = new InvestigationPage(page);
const investigationForm = new InvestigationFormPage(page);

await investigationPage.open();

// GIVEN
await investigationPage.openNewInvestigationForm();

await investigationForm.fillNameInput('add investigation test');
await investigationForm.fillDescriptionInput('add investigation test description');

// WHEN
await investigationForm.getSubmitButton().click();

// THEN
await expect(page.getByRole('rowgroup')).toBeVisible();
await expect(page.getByText('add investigation test')).toBeVisible();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import InvestigationPage from '../model/investigation.pageModel';
import InvestigationFormPage from '../model/investigationForm.pageModel';
import { test, expect } from '../fixtures/baseFixtures';

test('deleteInvestigation', async ({ page }) => {
// BEFORE
const investigationPage = new InvestigationPage(page);
const investigationForm = new InvestigationFormPage(page);

await investigationPage.open();

// GIVEN
await investigationPage.openNewInvestigationForm();

await investigationForm.fillNameInput('add investigation test');
await investigationForm.fillDescriptionInput('add investigation test description');

await investigationForm.getSubmitButton().click();

// WHEN
await investigationPage.openUpdateOrDeleteInvestigationPopover('add investigation test');
await investigationPage.selectDeleteOptionFromInvestigationPopover();
await investigationPage.submitDeleteInvestigation();

// THEN
await expect(page.getByText('add investigation test'), 'Should be deleted from the list').not.toBeVisible();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Page } from '@playwright/test';

export default class InvestigationPage {
constructor(private page: Page) {}

open() {
return this.page.goto('/dashboard/workspaces/investigations');
}

openNewInvestigationForm() {
return this.page.getByLabel('Add').click();
}

openUpdateOrDeleteInvestigationPopover(investigationName: string) {
return this.page.locator('li').filter({ hasText: investigationName }).getByTestId('popover').click();
}

selectDeleteOptionFromInvestigationPopover() {
return this.page.getByRole('menuitem', { name: 'Delete' }).click();
}

submitDeleteInvestigation() {
return this.page.getByRole('button', { name: 'Delete' }).click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Page } from '@playwright/test';

export default class InvestigationFormPage {
constructor(private page: Page) {}

getNameInput() {
return this.page.getByLabel('Name');
}

getDescriptionInput() {
return this.page.getByTestId('text-area');
}

getSubmitButton() {
return this.page.getByRole('button', { name: 'Create' });
}

async fillNameInput(value: string) {
await this.getNameInput().click();
return this.getNameInput().fill(value);
}

async fillDescriptionInput(value: string) {
await this.getDescriptionInput().click();
return this.getDescriptionInput().fill(value);
}
}

0 comments on commit 914ac83

Please sign in to comment.