- 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>
133 lines
5.1 KiB
TypeScript
133 lines
5.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('Kreiranje licence', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page);
|
|
});
|
|
|
|
test('forma za novu licencu prikazuje sva polja', async ({ page }) => {
|
|
await page.goto('/licenses/new');
|
|
await expect(page.locator('h1')).toHaveText('Nova licenca');
|
|
await expect(page.locator('select[name="product_id"]')).toBeVisible();
|
|
await expect(page.locator('select[name="license_type"]')).toBeVisible();
|
|
await expect(page.locator('input[name="customer_name"]')).toBeVisible();
|
|
await expect(page.locator('input[name="customer_pib"]')).toBeVisible();
|
|
await expect(page.locator('input[name="customer_email"]')).toBeVisible();
|
|
await expect(page.locator('input[name="limits"]')).toBeVisible();
|
|
await expect(page.locator('input[name="grace_days"]')).toBeVisible();
|
|
await expect(page.locator('textarea[name="notes"]')).toBeVisible();
|
|
});
|
|
|
|
test('dropdown ima sve proizvode', async ({ page }) => {
|
|
await page.goto('/licenses/new');
|
|
const options = page.locator('select[name="product_id"] option');
|
|
const count = await options.count();
|
|
expect(count).toBeGreaterThanOrEqual(3); // ESIR, ARV, LIGHT_TICKET
|
|
});
|
|
|
|
test('dropdown ima sve tipove licenci', async ({ page }) => {
|
|
await page.goto('/licenses/new');
|
|
const options = page.locator('select[name="license_type"] option');
|
|
const texts = await options.allTextContents();
|
|
expect(texts.join(' ')).toContain('Mesecna');
|
|
expect(texts.join(' ')).toContain('Godisnja');
|
|
expect(texts.join(' ')).toContain('Trajna');
|
|
expect(texts.join(' ')).toContain('Trial');
|
|
});
|
|
|
|
test('kreiranje LIGHT_TICKET licence', async ({ page }) => {
|
|
await page.goto('/licenses/new');
|
|
|
|
// Izaberi Light-Ticket proizvod
|
|
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"]', 'E2E Test Firma DOO');
|
|
await page.fill('input[name="customer_pib"]', '999888777');
|
|
await page.fill('input[name="customer_email"]', 'e2e@test.rs');
|
|
await page.fill('input[name="limits"]', '{"max_operators": 5}');
|
|
await page.fill('input[name="grace_days"]', '30');
|
|
await page.fill('textarea[name="notes"]', 'Kreirana iz E2E testa');
|
|
|
|
await page.click('button:has-text("Kreiraj licencu")');
|
|
|
|
// Treba da preusmeriva na detalje licence
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
await expect(page.locator('h1 code')).toBeVisible();
|
|
// Proverava da je LT prefix
|
|
const licenseKey = await page.locator('h1 code').textContent();
|
|
expect(licenseKey).toMatch(/^LT-/);
|
|
});
|
|
|
|
test('kreiranje ARV licence', async ({ page }) => {
|
|
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('ARV')) {
|
|
await productSelect.selectOption({ index: i });
|
|
break;
|
|
}
|
|
}
|
|
|
|
await page.selectOption('select[name="license_type"]', 'ANNUAL');
|
|
await page.fill('input[name="customer_name"]', 'E2E ARV Firma');
|
|
await page.fill('input[name="customer_email"]', 'arv@test.rs');
|
|
|
|
await page.click('button:has-text("Kreiraj licencu")');
|
|
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
const licenseKey = await page.locator('h1 code').textContent();
|
|
expect(licenseKey).toMatch(/^ARV-/);
|
|
});
|
|
|
|
test('kreiranje ESIR licence', async ({ page }) => {
|
|
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('ESIR')) {
|
|
await productSelect.selectOption({ index: i });
|
|
break;
|
|
}
|
|
}
|
|
|
|
await page.selectOption('select[name="license_type"]', 'PERPETUAL');
|
|
await page.fill('input[name="customer_name"]', 'E2E ESIR Prodavnica');
|
|
|
|
await page.click('button:has-text("Kreiraj licencu")');
|
|
|
|
await expect(page).toHaveURL(/\/licenses\/\d+/);
|
|
const licenseKey = await page.locator('h1 code').textContent();
|
|
expect(licenseKey).toMatch(/^ESIR-/);
|
|
});
|
|
|
|
test('otkazi dugme vodi na listu licenci', async ({ page }) => {
|
|
await page.goto('/licenses/new');
|
|
await page.click('a:has-text("Otkazi")');
|
|
await expect(page).toHaveURL(/\/licenses$/);
|
|
});
|
|
});
|