Steuerkram/tests/e2e/specs/ereignisse.spec.js

76 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-check
// Hotspot: Ereignisliste über alle Bereiche (Issue #165).
//
// Die Liste zeigt nicht mehr nur den Nextcloud-Import, sondern auch Fehler und
// Warnungen aus dem übrigen System. Der Weg „Fehlermeldung im Browser → Eintrag
// in der Ereignisliste“ führt über eine Weiterleitung mit Flash-Meldung und ist
// deshalb nur mit Browser prüfbar; die Speicherlogik selbst deckt
// tests/81_EreignisseAlleFehlerTest.php ab.
//
// Die Tests legen keine Geschäftsdaten an. Ein Aufruf einer ungültigen URL
// erzeugt einen Protokolleintrag – genau das ist der geprüfte Effekt.
const { test, expect } = require('@playwright/test')
const { gotoOk } = require('../helpers/app')
test.describe('Ereignisse', () => {
test('Übersicht listet alle Bereiche und bietet Filter', async ({ page }) => {
await gotoOk(page, '/ereignisse')
await expect(page.locator('select[name="channel"]')).toHaveCount(1)
await expect(page.locator('select[name="level"]')).toHaveCount(1)
await expect(page.locator('#events-autoreload-toggle')).toHaveCount(1)
await expect(page.locator('select[name="channel"] option[value=""]')).toContainText('Alle Bereiche')
})
test('Beide Auswahlfelder stehen nebeneinander', async ({ page }) => {
// Global gilt `select { width: 100% }` – ohne eigene Breite bricht das
// zweite Feld im Flex-Formular in die nächste Zeile um.
await page.setViewportSize({ width: 1280, height: 800 })
await gotoOk(page, '/ereignisse')
const bereich = await page.locator('select[name="channel"]').boundingBox()
const grad = await page.locator('select[name="level"]').boundingBox()
expect(Math.abs(bereich.y - grad.y)).toBeLessThan(5)
expect(grad.x).toBeGreaterThan(bereich.x + bereich.width - 1)
})
test('Der alte Nextcloud-Pfad landet auf der gefilterten Übersicht', async ({ page }) => {
await page.goto('/ereignisse/nextcloud-import')
const url = new URL(page.url())
expect(url.pathname).toBe('/ereignisse')
expect(url.searchParams.get('channel')).toBe('nextcloud-import')
await expect(page.locator('select[name="channel"]')).toHaveValue('nextcloud-import')
})
test('Eine Fehlermeldung aus dem Browser erscheint in der Ereignisliste', async ({ page }) => {
// Erzeugt garantiert eine Fehlermeldung samt Weiterleitung (Issue #167).
await page.goto('/dashboard/buchungen/unsinn/2026')
await expect(page.locator('body')).toContainText('Unbekannte Auswertung.')
await gotoOk(page, '/ereignisse?level=error')
await expect(page.locator('body')).toContainText('Unbekannte Auswertung.')
await expect(page.locator('body')).toContainText('[meldungen]')
})
test('Filter nach Schweregrad blendet Infos aus', async ({ page }) => {
await gotoOk(page, '/ereignisse?level=error')
await expect(page.locator('select[name="level"]')).toHaveValue('error')
const zeilen = page.locator('#events-body table tbody tr')
const anzahl = await zeilen.count()
for (let i = 0; i < Math.min(anzahl, 10); i++) {
await expect(zeilen.nth(i)).toContainText('Fehler')
}
})
test('Der Daten-Endpunkt liefert dieselbe gefilterte Liste als JSON', async ({ page }) => {
const antwort = await page.request.get('/ereignisse/data?level=error')
expect(antwort.status()).toBe(200)
const daten = await antwort.json()
expect(typeof daten.count).toBe('number')
expect(typeof daten.html).toBe('string')
})
})