67 lines
2.7 KiB
TypeScript
67 lines
2.7 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { loginAs, navigateTo, expectSidebarLink } from '../helpers/auth';
|
|
import { APP_URL } from '../helpers/api';
|
|
|
|
test.describe('Super Admin — acceso total', () => {
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, 'superAdmin');
|
|
});
|
|
|
|
// ── Sidebar: todos los elementos visibles ───────────────────────────────────
|
|
test.describe('Sidebar — ve todos los enlaces', () => {
|
|
const links = [
|
|
'/groups', '/dhcp-servers', '/boot-servers',
|
|
'/calendars', '/repositories', '/menus',
|
|
];
|
|
for (const link of links) {
|
|
test(`ve el enlace a ${link}`, async ({ page }) => {
|
|
await expectSidebarLink(page, link, true);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ── Rutas: acceso permitido ─────────────────────────────────────────────────
|
|
test.describe('Rutas — puede acceder a todas', () => {
|
|
const routes = [
|
|
'/users', '/roles', '/env-vars',
|
|
'/commands', '/pxe', '/dhcp-servers', '/boot-servers',
|
|
'/calendars', '/repositories',
|
|
];
|
|
for (const route of routes) {
|
|
test(`accede a ${route} sin ser redirigido`, async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, route);
|
|
expect(finalUrl).toContain(route);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ── GUI: botones de infraestructura visibles ────────────────────────────────
|
|
test('ve el botón "Añadir OU" en /groups', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/groups`);
|
|
await expect(page.locator('button.action-button').first()).toBeVisible();
|
|
});
|
|
|
|
test('ve botones de crear/editar en /dhcp-servers', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/dhcp-servers`);
|
|
await page.waitForLoadState('networkidle');
|
|
// Botón de añadir servidor (solo visible para super-admin)
|
|
const addBtn = page.locator('button').filter({ hasText: /add|añadir|nuevo/i }).first();
|
|
await expect(addBtn).toBeVisible({ timeout: 8_000 });
|
|
});
|
|
|
|
test('ve botones de crear en /commands', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/commands`);
|
|
await page.waitForLoadState('networkidle');
|
|
const addBtn = page.locator('button.action-button').first();
|
|
await expect(addBtn).toBeVisible({ timeout: 8_000 });
|
|
});
|
|
|
|
test('ve botones de crear en /boot-servers', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/boot-servers`);
|
|
await page.waitForLoadState('networkidle');
|
|
const addBtn = page.locator('button').filter({ hasText: /add|añadir|nuevo/i }).first();
|
|
await expect(addBtn).toBeVisible({ timeout: 8_000 });
|
|
});
|
|
});
|