Novi Go testovi: - config_test.go: 9 testova (defaults, override, DSN, .env loading) - helpers_test.go: 13 testova (writeJSON, writeError, clientIP) Prosireni E2E testovi za svaku stranicu: - login: 15 testova (forma, auth, redirect, sesije) - dashboard: 18 testova (statistike, navbar, navigacija, odjava) - licenses: 20 testova (tabela, filteri, pretraga, kombinacije) - license-crud: 22 testa (forma, validacija, svi proizvodi/tipovi) - license-detail: 26 testova (info, aktivacije, audit, revoke, release) - audit: 14 testova (tabela, API zapisi, formati) - api-client: 18 testova (activate flow, auth, revoke flow) Azuriran TESTING.md sa kompletnom checklistom Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
119 lines
4.3 KiB
TypeScript
119 lines
4.3 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('Dashboard stranica', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page);
|
|
});
|
|
|
|
test('prikazuje naslov Dashboard', async ({ page }) => {
|
|
await expect(page.locator('h1')).toHaveText('Dashboard');
|
|
});
|
|
|
|
test('prikazuje statistike po proizvodu — 3 kartice', async ({ page }) => {
|
|
await expect(page.locator('.stats-grid')).toBeVisible();
|
|
const statCards = page.locator('.stat-card');
|
|
await expect(statCards).toHaveCount(3);
|
|
});
|
|
|
|
test('svaka kartica prikazuje ime proizvoda', async ({ page }) => {
|
|
const labels = page.locator('.stat-label');
|
|
const texts = await labels.allTextContents();
|
|
expect(texts).toContain('ESIR Fiskalizacija');
|
|
expect(texts).toContain('ARV Evidencija RV');
|
|
expect(texts).toContain('Light-Ticket');
|
|
});
|
|
|
|
test('svaka kartica prikazuje sve metrike', async ({ page }) => {
|
|
const cards = page.locator('.stat-card');
|
|
const count = await cards.count();
|
|
for (let i = 0; i < count; i++) {
|
|
const card = cards.nth(i);
|
|
await expect(card.locator('.stat-row', { hasText: 'Aktivne:' })).toBeVisible();
|
|
await expect(card.locator('.stat-row', { hasText: 'Istekle:' })).toBeVisible();
|
|
await expect(card.locator('.stat-row', { hasText: 'Grace:' })).toBeVisible();
|
|
await expect(card.locator('.stat-row', { hasText: 'Trial:' })).toBeVisible();
|
|
await expect(card.locator('.stat-row', { hasText: 'Aktivacija:' })).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('prikazuje sekciju poslednje aktivnosti', async ({ page }) => {
|
|
await expect(page.locator('h2', { hasText: 'Poslednja aktivnost' })).toBeVisible();
|
|
await expect(page.locator('table').last()).toBeVisible();
|
|
});
|
|
|
|
test('tabela poslednje aktivnosti ima ispravne kolone', async ({ page }) => {
|
|
const lastTable = page.locator('table').last();
|
|
const headers = lastTable.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');
|
|
});
|
|
|
|
test('navbar prikazuje brend', async ({ page }) => {
|
|
await expect(page.locator('.nav-brand')).toHaveText('DAL License Server');
|
|
});
|
|
|
|
test('navbar ima link na dashboard (aktivan)', async ({ page }) => {
|
|
const link = page.locator('a[href="/dashboard"]');
|
|
await expect(link).toBeVisible();
|
|
await expect(link).toHaveClass(/active/);
|
|
});
|
|
|
|
test('navbar ima link na licence', async ({ page }) => {
|
|
await expect(page.locator('a[href="/licenses"]')).toBeVisible();
|
|
});
|
|
|
|
test('navbar ima link na audit log', async ({ page }) => {
|
|
await expect(page.locator('a[href="/audit"]')).toBeVisible();
|
|
});
|
|
|
|
test('navbar ima dugme za odjavu', async ({ page }) => {
|
|
await expect(page.locator('button:has-text("Odjava")')).toBeVisible();
|
|
});
|
|
|
|
test('odjava preusmerava na login', async ({ page }) => {
|
|
await page.click('button:has-text("Odjava")');
|
|
await expect(page).toHaveURL(/\/login/);
|
|
});
|
|
|
|
test('posle odjave ne moze na dashboard', async ({ page }) => {
|
|
await page.click('button:has-text("Odjava")');
|
|
await page.goto('/dashboard');
|
|
await expect(page).toHaveURL(/\/login/);
|
|
});
|
|
|
|
test('root (/) preusmerava na dashboard', async ({ page }) => {
|
|
await page.goto('/');
|
|
await expect(page).toHaveURL(/\/dashboard/);
|
|
});
|
|
|
|
test('navigacija sa dashboarda na licence', async ({ page }) => {
|
|
await page.click('a[href="/licenses"]');
|
|
await expect(page).toHaveURL(/\/licenses/);
|
|
await expect(page.locator('h1')).toHaveText('Licence');
|
|
});
|
|
|
|
test('navigacija sa dashboarda na audit', async ({ page }) => {
|
|
await page.click('a[href="/audit"]');
|
|
await expect(page).toHaveURL(/\/audit/);
|
|
await expect(page.locator('h1')).toHaveText('Audit Log');
|
|
});
|
|
|
|
test('dashboard ima ispravan title', async ({ page }) => {
|
|
await expect(page).toHaveTitle('Dashboard - DAL License Server');
|
|
});
|
|
|
|
test('htmx je ucitan', async ({ page }) => {
|
|
const htmxLoaded = await page.evaluate(() => typeof (window as any).htmx !== 'undefined');
|
|
expect(htmxLoaded).toBe(true);
|
|
});
|
|
});
|