-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] e2e tests added for create and delete investigation (#3167)
- Loading branch information
1 parent
b2dd23d
commit 914ac83
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
opencti-platform/opencti-front/tests_e2e/investigation/createInvestigation.spec.ts
This file contains 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,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(); | ||
}); |
27 changes: 27 additions & 0 deletions
27
opencti-platform/opencti-front/tests_e2e/investigation/deleteInvestigation.spec.ts
This file contains 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,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(); | ||
}); |
25 changes: 25 additions & 0 deletions
25
opencti-platform/opencti-front/tests_e2e/model/investigation.pageModel.ts
This file contains 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,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(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
opencti-platform/opencti-front/tests_e2e/model/investigationForm.pageModel.ts
This file contains 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,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); | ||
} | ||
} |