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'); }); });