Filter the script library and show customer context across pages

This commit is contained in:
2026-11-18 09:28:11 +01:00
parent f8e5865412
commit 97ef5783c1
7 changed files with 97 additions and 22 deletions
+20 -2
View File
@@ -419,6 +419,10 @@ for (const library of [true, false]) {
test('publishes versions in the library and keeps the earlier script readable', async ({ page }) => {
const revisions = [{ ...script, script_sha256: hash(script.script_utf8) }];
const otherScripts = [
{ ...revisions[0], revision_id: randomUUID(), name: 'Windows Übersicht', interpreter: 'powershell' },
{ ...revisions[0], revision_id: randomUUID(), name: 'Linux Übersicht', interpreter: 'bash' }
];
const writes: string[] = [];
await page.route(origin + '/fixture', (r) =>
r.fulfill({
@@ -434,8 +438,11 @@ test('publishes versions in the library and keeps the earlier script readable',
await page.route(origin + '/api/v1/**', (r) => {
const req = r.request();
const path = '/api/v1/tenants/' + tenantId + '/script-revisions';
expect(new URL(req.url()).pathname).toBe(path);
if (req.method() === 'GET') return r.fulfill({ json: listing(revisions) });
const url = new URL(req.url());
expect(url.pathname).toBe(path);
if (req.method() === 'GET') return r.fulfill({ json: url.searchParams.has('cursor')
? listing(otherScripts)
: { ...listing(revisions), next_cursor: 'second-page' } });
writes.push(path);
expect(req.headers()['x-csrf-token']).toBe(auth.csrf_token);
const body = req.postDataJSON();
@@ -451,6 +458,17 @@ test('publishes versions in the library and keeps the earlier script readable',
return r.fulfill({ json: next });
});
await page.goto(origin + '/fixture');
const library = page.getByRole('region', { name: 'Skriptbibliothek' });
await library.getByLabel('Plattform', { exact: true }).selectOption('windows');
await library.getByRole('searchbox', { name: 'Skriptname' }).fill(' ÜBERSICHT ');
await expect(library.locator('tbody tr')).toHaveCount(1);
await expect(library.locator('tbody tr')).toContainText('Windows Übersicht');
await library.getByLabel('Plattform', { exact: true }).selectOption('linux');
await expect(library.locator('tbody tr')).toContainText('Linux Übersicht');
await library.getByRole('searchbox', { name: 'Skriptname' }).fill('ohne Treffer');
await expect(library.getByText('Keine Skripte passen zu den Filtern.')).toBeVisible();
await library.getByRole('button', { name: 'Filter zurücksetzen' }).click();
await expect(library.locator('tbody tr')).toHaveCount(3);
await page.getByRole('button', { name: script.name, exact: true }).click();
await page.getByRole('button', { name: 'Neue Version', exact: true }).click();
await page.getByLabel('Skriptinhalt').fill('uname -r\n');