-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89e8b15
commit b49f05d
Showing
3 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
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
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
43 changes: 43 additions & 0 deletions
43
packages/frontend/test/e2e/integration/templates.test.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,43 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { DemoDataState, DemoDataType } from '../util/demo_data'; | ||
|
||
test('A User can Create a Template with German and English Translations', async ({ page }) => { | ||
const testState = new DemoDataState(); | ||
await page.goto('/templates/'); | ||
await page.getByTestId('create-button').click(); | ||
await page.getByTestId('title-en-US').getByRole('textbox').waitFor(); | ||
const templateId = page.url().split('/').at(4); | ||
testState.addId(DemoDataType.Template, templateId); | ||
await page.getByTestId('title-en-US').getByRole('textbox').clear(); | ||
await page.getByTestId('title-en-US').getByRole('textbox').fill('My Vulnerability'); | ||
// Add German Translation | ||
await page.getByRole('tablist').getByRole('button').click(); | ||
await page.getByText('German (de-AT)').click(); | ||
await page.getByTestId('title-de-AT').getByRole('textbox').clear(); | ||
await page.getByTestId('title-de-AT').getByRole('textbox').fill('Meine Schwachstelle'); | ||
await page.getByTestId('save-toolbar').click(); | ||
await page.getByText('Everything saved').waitFor(); | ||
}); | ||
|
||
test('Template Translations are displayed correctly', async ({ page }) => { | ||
const testState = new DemoDataState(); | ||
const templateId = testState.templates[testState.templates.length - 1]; | ||
await page.goto(`/templates/${templateId}`); | ||
expect(await page.getByTestId('title-en-US').getByRole('textbox').textContent()).toBe('My Vulnerability'); | ||
await page.getByRole('tab', { name: 'German (de-AT)' }).click(); | ||
expect(await page.getByTestId('title-de-AT').getByRole('textbox').textContent()).toBe('Meine Schwachstelle'); | ||
}); | ||
|
||
test('A User can delete a Template', async ({ page }) => { | ||
const testState = new DemoDataState(); | ||
const templateId = testState.templates[testState.templates.length - 1]; | ||
await page.goto(`/templates/${templateId}`); | ||
await page.getByTestId('title-en-US').getByRole('textbox').waitFor(); | ||
if(await page.getByText('It seems like you are editing').isVisible()) { | ||
await page.getByRole('button', { name: 'Edit Anyway' }).click(); | ||
} | ||
await page.getByTestId('options-dots').click(); | ||
await page.getByText('Delete').click(); | ||
await page.getByRole('button', { name: 'Delete' }).click(); | ||
await page.getByRole('heading', { name: 'Templates' }).waitFor(); | ||
}); |