Compare commits
1 Commits
8b422c8f06
...
62f62a89a1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62f62a89a1 |
@@ -1,26 +1,48 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document edit history E2E tests.
|
* Document edit history E2E tests.
|
||||||
* Relies on the 'Document creation' and 'Document editing' tests in documents.spec.ts
|
* Creates its own test document (two versions) in beforeAll so these tests
|
||||||
* having run first (they create and edit "E2E Testbrief (überarbeitet)").
|
* are fully independent of any other spec file.
|
||||||
* Assumes auth setup has run.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async function openHistoryDoc(page: import('@playwright/test').Page) {
|
let docPath: string;
|
||||||
await page.goto('/?q=E2E+Testbrief');
|
|
||||||
await page.waitForSelector('[data-hydrated]');
|
|
||||||
const href = await page
|
|
||||||
.getByRole('link', { name: /E2E Testbrief/ })
|
|
||||||
.first()
|
|
||||||
.getAttribute('href');
|
|
||||||
await page.goto(href!);
|
|
||||||
await page.waitForSelector('[data-hydrated]');
|
|
||||||
}
|
|
||||||
|
|
||||||
test.describe('Document history panel', () => {
|
test.describe('Document history panel', () => {
|
||||||
test('history section appears after creating and editing a document', async ({ page }) => {
|
test.beforeAll(async ({ browser }) => {
|
||||||
await openHistoryDoc(page);
|
// Create a fresh browser context that uses the stored auth session
|
||||||
|
const context = await browser.newContext({
|
||||||
|
storageState: path.join(__dirname, '.auth/user.json'),
|
||||||
|
locale: 'de-DE'
|
||||||
|
});
|
||||||
|
const page = await context.newPage();
|
||||||
|
|
||||||
|
// 1. Create a new document
|
||||||
|
await page.goto('/documents/new');
|
||||||
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
await page.getByLabel('Titel').fill('E2E History Test Dokument');
|
||||||
|
await page.getByRole('button', { name: /Speichern/i }).click();
|
||||||
|
// Wait for redirect to the new document's UUID-based URL (not /documents/new)
|
||||||
|
await page.waitForURL(/\/documents\/[0-9a-f-]{36}$/);
|
||||||
|
docPath = new URL(page.url()).pathname;
|
||||||
|
|
||||||
|
// 2. Edit the document to create a second version
|
||||||
|
await page.goto(`${docPath}/edit`);
|
||||||
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
await page.getByLabel('Titel').fill('E2E History Test Dokument (bearbeitet)');
|
||||||
|
await page.getByRole('button', { name: /Speichern/i }).click();
|
||||||
|
await page.waitForURL(/\/documents\/[0-9a-f-]{36}$/);
|
||||||
|
|
||||||
|
await context.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('history section appears and shows two versions', async ({ page }) => {
|
||||||
|
await page.goto(docPath);
|
||||||
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
|
||||||
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
||||||
await expect(historyToggle).toBeVisible();
|
await expect(historyToggle).toBeVisible();
|
||||||
@@ -34,7 +56,8 @@ test.describe('Document history panel', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('diff view highlights changed field after title edit', async ({ page }) => {
|
test('diff view highlights changed field after title edit', async ({ page }) => {
|
||||||
await openHistoryDoc(page);
|
await page.goto(docPath);
|
||||||
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
|
||||||
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
||||||
await historyToggle.click();
|
await historyToggle.click();
|
||||||
@@ -52,7 +75,8 @@ test.describe('Document history panel', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('compare mode lets user compare any two versions', async ({ page }) => {
|
test('compare mode lets user compare any two versions', async ({ page }) => {
|
||||||
await openHistoryDoc(page);
|
await page.goto(docPath);
|
||||||
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
|
||||||
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
const historyToggle = page.getByRole('button', { name: /Verlauf/i });
|
||||||
await historyToggle.click();
|
await historyToggle.click();
|
||||||
@@ -71,6 +95,10 @@ test.describe('Document history panel', () => {
|
|||||||
await expect(selectA).toBeVisible();
|
await expect(selectA).toBeVisible();
|
||||||
await expect(selectB).toBeVisible();
|
await expect(selectB).toBeVisible();
|
||||||
|
|
||||||
|
// Select version 1 for A and version 2 for B
|
||||||
|
await selectA.selectOption({ index: 1 });
|
||||||
|
await selectB.selectOption({ index: 2 });
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.getByRole('button', { name: /Vergleichen/i })
|
.getByRole('button', { name: /Vergleichen/i })
|
||||||
.last()
|
.last()
|
||||||
|
|||||||
Reference in New Issue
Block a user