- 7 E2E test fajlova (54 testa ukupno): - login.spec.ts: prijava, pogresna lozinka, redirect bez sesije - dashboard.spec.ts: statistike, navbar, odjava, root redirect - licenses.spec.ts: tabela, filteri, pretraga - license-crud.spec.ts: forma, kreiranje LT/ARV/ESIR licence - license-detail.spec.ts: informacije, aktivacije, audit, revoke, force release - audit.spec.ts: audit log stranica, kolone, generisanje zapisa - api-client.spec.ts: activate, deactivate, validate, revoke flow, API key auth - CLAUDE.md: dodato pravilo o rigoroznom testiranju Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import { test, expect, Page } from '@playwright/test';
|
|
|
|
async function login(page: Page) {
|
|
await page.goto('/login');
|
|
await page.fill('input[name="password"]', 'admin123');
|
|
await page.click('button[type="submit"]');
|
|
await expect(page).toHaveURL(/\/dashboard/);
|
|
}
|
|
|
|
test.describe('Audit Log', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page);
|
|
});
|
|
|
|
test('prikazuje audit log stranicu', async ({ page }) => {
|
|
await page.goto('/audit');
|
|
await expect(page.locator('h1')).toHaveText('Audit Log');
|
|
await expect(page.locator('table')).toBeVisible();
|
|
});
|
|
|
|
test('tabela ima ispravne kolone', async ({ page }) => {
|
|
await page.goto('/audit');
|
|
const headers = page.locator('thead th');
|
|
await expect(headers.nth(0)).toHaveText('Vreme');
|
|
await expect(headers.nth(1)).toHaveText('Akcija');
|
|
await expect(headers.nth(2)).toHaveText('Licenca');
|
|
await expect(headers.nth(3)).toHaveText('IP');
|
|
await expect(headers.nth(4)).toHaveText('Detalji');
|
|
});
|
|
|
|
test('kreiranje licence generise audit zapis', async ({ page }) => {
|
|
// Kreiraj licencu
|
|
await page.goto('/licenses/new');
|
|
const productSelect = page.locator('select[name="product_id"]');
|
|
const options = productSelect.locator('option');
|
|
const count = await options.count();
|
|
for (let i = 0; i < count; i++) {
|
|
const text = await options.nth(i).textContent();
|
|
if (text && text.includes('LIGHT_TICKET')) {
|
|
await productSelect.selectOption({ index: i });
|
|
break;
|
|
}
|
|
}
|
|
await page.selectOption('select[name="license_type"]', 'MONTHLY');
|
|
await page.fill('input[name="customer_name"]', 'Audit E2E Test');
|
|
await page.click('button:has-text("Kreiraj licencu")');
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
|
|
// Proveri audit log
|
|
await page.goto('/audit');
|
|
await expect(page.locator('.badge', { hasText: 'CREATE' }).first()).toBeVisible();
|
|
});
|
|
|
|
test('navigacija na audit iz navbara', async ({ page }) => {
|
|
await page.click('a[href="/audit"]');
|
|
await expect(page).toHaveURL(/\/audit/);
|
|
await expect(page.locator('h1')).toHaveText('Audit Log');
|
|
});
|
|
});
|