fix(nav): replace static back-link hrefs with history.back() + fallback #303

Merged
marcel merged 7 commits from feat/issue-185-fix-nav-history-back into main 2026-04-22 12:32:57 +02:00
2 changed files with 41 additions and 3 deletions
Showing only changes of commit 261f631318 - Show all commits

View File

@@ -12,12 +12,12 @@ const authFile = path.join(__dirname, '.auth/user.json');
* E2E_PASSWORD (default: admin123)
*/
setup('authenticate', async ({ page }) => {
const username = process.env.E2E_USERNAME ?? 'admin';
const username = process.env.E2E_USERNAME ?? 'admin@familyarchive.local';
const password = process.env.E2E_PASSWORD ?? 'admin123';
await page.goto('/login');
await page.getByLabel('Benutzername').fill(username);
await page.getByLabel('Passwort').fill(password);
await page.getByLabel(/e-mail/i).fill(username);
await page.getByLabel(/passwort/i).fill(password);
await page.getByRole('button', { name: 'Anmelden' }).click();
await page.waitForURL('/');

View File

@@ -0,0 +1,38 @@
import { test, expect } from '@playwright/test';
test.describe('DocumentTopBar — back navigation', () => {
test('BackButton returns to /documents after navigating from the documents list', async ({
page
}) => {
// Navigate to home page first (mirrors the real user flow)
await page.goto('/');
await page.waitForSelector('[data-hydrated]');
// Click the Dokumente nav link (SPA navigation — pushes to history)
await page.click('a[href="/documents"]');
await page.waitForURL('/documents');
await page.waitForSelector('[data-hydrated]');
// Click first real document link (skip /documents/new and edit links)
const docLink = page.locator('a[href^="/documents/"]:not([href="/documents/new"])').first();
const count = await docLink.count();
if (count === 0) {
test.skip(true, 'No documents in test database');
}
const docHref = await docLink.getAttribute('href');
await docLink.click();
await page.waitForURL(new RegExp(docHref!.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
await page.waitForSelector('[data-hydrated]');
// Find and click the BackButton in the DocumentTopBar
const backBtn = page.locator('[data-topbar]').getByRole('button', { name: /zurück/i });
await expect(backBtn).toBeVisible();
await backBtn.click();
// Should be back at the documents list, not at /
await page.waitForURL(/\/documents($|\?)/);
expect(page.url()).toMatch(/\/documents($|\?)/);
});
});