- 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>
118 lines
4.4 KiB
TypeScript
118 lines
4.4 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/);
|
|
}
|
|
|
|
async function createLicense(page: Page, customerName: string): Promise<string> {
|
|
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"]', customerName);
|
|
await page.click('button:has-text("Kreiraj licencu")');
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
return page.url();
|
|
}
|
|
|
|
test.describe('Detalji licence', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page);
|
|
});
|
|
|
|
test('prikazuje informacije o licenci', async ({ page }) => {
|
|
const url = await createLicense(page, 'Detail Test Firma');
|
|
|
|
await expect(page.locator('h3', { hasText: 'Informacije' })).toBeVisible();
|
|
await expect(page.locator('.detail-table')).toBeVisible();
|
|
|
|
// Proverava osnovne podatke
|
|
const detailText = await page.locator('.detail-table').textContent();
|
|
expect(detailText).toContain('LIGHT_TICKET');
|
|
expect(detailText).toContain('MONTHLY');
|
|
expect(detailText).toContain('Detail Test Firma');
|
|
});
|
|
|
|
test('prikazuje tabelu aktivacija', async ({ page }) => {
|
|
await createLicense(page, 'Activation Test Firma');
|
|
await expect(page.locator('h2', { hasText: 'Aktivacije' })).toBeVisible();
|
|
// Nova licenca nema aktivacija
|
|
await expect(page.locator('td', { hasText: 'Nema aktivacija' })).toBeVisible();
|
|
});
|
|
|
|
test('prikazuje audit log za licencu', async ({ page }) => {
|
|
await createLicense(page, 'Audit Test Firma');
|
|
await expect(page.locator('h2', { hasText: 'Audit Log' })).toBeVisible();
|
|
// Kreiranje licence generise CREATE audit entry
|
|
await expect(page.locator('.badge', { hasText: 'CREATE' })).toBeVisible();
|
|
});
|
|
|
|
test('prikazuje akcije (revoke, force release)', async ({ page }) => {
|
|
await createLicense(page, 'Actions Test Firma');
|
|
await expect(page.locator('h3', { hasText: 'Akcije' })).toBeVisible();
|
|
await expect(page.locator('button:has-text("Opozovi licencu")')).toBeVisible();
|
|
await expect(page.locator('button:has-text("Force Release")')).toBeVisible();
|
|
});
|
|
|
|
test('revoke licence funkcionise', async ({ page }) => {
|
|
await createLicense(page, 'Revoke Test Firma');
|
|
|
|
// Prihvatamo confirm dialog
|
|
page.on('dialog', dialog => dialog.accept());
|
|
|
|
await page.fill('input[name="reason"]', 'E2E test opozivanje');
|
|
await page.click('button:has-text("Opozovi licencu")');
|
|
|
|
// Posle revoke-a ostajemo na istoj stranici
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
// Status treba biti Opozvana
|
|
await expect(page.locator('.badge.status-revoked')).toBeVisible();
|
|
});
|
|
|
|
test('posle revoke-a dugme za opoziv nestaje', async ({ page }) => {
|
|
await createLicense(page, 'Revoke Hide Test');
|
|
|
|
page.on('dialog', dialog => dialog.accept());
|
|
await page.fill('input[name="reason"]', 'Test');
|
|
await page.click('button:has-text("Opozovi licencu")');
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
|
|
// Dugme za opoziv ne treba da postoji
|
|
await expect(page.locator('button:has-text("Opozovi licencu")')).toHaveCount(0);
|
|
// Ali Force Release treba da postoji
|
|
await expect(page.locator('button:has-text("Force Release")')).toBeVisible();
|
|
});
|
|
|
|
test('force release funkcionise', async ({ page }) => {
|
|
await createLicense(page, 'Release Test Firma');
|
|
|
|
page.on('dialog', dialog => dialog.accept());
|
|
await page.click('button:has-text("Force Release")');
|
|
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
});
|
|
|
|
test('klik na licencu iz liste otvara detalje', async ({ page }) => {
|
|
await createLicense(page, 'Link Test Firma');
|
|
|
|
await page.goto('/licenses');
|
|
// Klik na prvi link sa kodom licence
|
|
const licenseLink = page.locator('a:has(code)').first();
|
|
await licenseLink.click();
|
|
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
await expect(page.locator('h1 code')).toBeVisible();
|
|
});
|
|
});
|