Add searchable admin audit history
This commit is contained in:
27
tests/admin-audit.spec.js
Normal file
27
tests/admin-audit.spec.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
|
||||
test('audit tab filters, pages and links filtered exports', async ({ page }) => {
|
||||
const requests = [];
|
||||
await page.route('**/api/**', async route => {
|
||||
const url = new URL(route.request().url()); requests.push(url.pathname + url.search);
|
||||
let body = { ok: true };
|
||||
if (url.pathname === '/api/admin/me') body = { ok: true, enabled: true, admin: true };
|
||||
if (url.pathname === '/api/admin/audit') body = {
|
||||
ok: true, total: 62, offset: Number(url.searchParams.get('offset')) || 0,
|
||||
events: [{ id: 9, ts: 1791900000, actor: 'admin', action: 'notes.save.lyrics', target: 'dQw4w9WgXcQ', detail: { rev: 4 } }],
|
||||
};
|
||||
if (url.pathname === '/api/admin/flags') body = { ok: true, open: 0, flags: [] };
|
||||
if (url.pathname === '/api/admin/media') body = { ok: true, media: [] };
|
||||
if (url.pathname === '/api/uploads') body = { ok: true, uploads: [] };
|
||||
await route.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
|
||||
});
|
||||
await page.goto('/admin.html#audit');
|
||||
await expect(page.locator('#p-audit')).toBeVisible();
|
||||
await expect(page.locator('#auditTable')).toContainText('notes.save.lyrics');
|
||||
await page.locator('#auditActor').fill('admin'); await page.locator('#auditAction').fill('lyrics');
|
||||
await page.locator('#auditFilterForm button[type=submit]').click();
|
||||
await expect.poll(() => requests.filter(x => x.startsWith('/api/admin/audit?')).length).toBeGreaterThan(1);
|
||||
await expect(page.locator('#auditJson')).toHaveAttribute('href', /actor=admin.*action=lyrics.*format=json/);
|
||||
await page.locator('#auditNext').click();
|
||||
await expect(page.locator('#auditCount')).toContainText('51–');
|
||||
});
|
||||
Reference in New Issue
Block a user