Skip to content

Commit

Permalink
Templates integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-syslifters authored and MWedl committed Dec 20, 2024
1 parent 89e8b15 commit b49f05d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/frontend/test/e2e/integration/notes.test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ test('A User can create, write and delete a Note', async ({ page }) => {
});



// test('ffasf', async ({ page }) => {
// await page.goto('/projects');
// await page.getByTestId('profile-button').click();
// await page.getByTestId('profile-menu-modal').waitFor({ state: 'visible' });
// await page.getByTestId('enable-superuser').click();
// await page.getByLabel('Password').fill(IntegrationAdmin.password);
// await page.getByTestId('login-submit').click();
// });
// });
2 changes: 1 addition & 1 deletion packages/frontend/test/e2e/integration/projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ test('A User can delete a Project', async ({ page }) => {
await page.getByRole('button', { name: 'Delete' }).click();
await page.waitForSelector('text=Projects');

});
});
43 changes: 43 additions & 0 deletions packages/frontend/test/e2e/integration/templates.test.spec.ts
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();
});

0 comments on commit b49f05d

Please sign in to comment.