83 lines
3.9 KiB
TypeScript
83 lines
3.9 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { loginAs, navigateTo, expectSidebarLink } from '../helpers/auth';
|
|
import { APP_URL } from '../helpers/api';
|
|
|
|
test.describe('OU Operator — solo grupos y operaciones de equipos', () => {
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, 'operator');
|
|
});
|
|
|
|
// ── Sidebar: solo /groups visible ───────────────────────────────────────────
|
|
test.describe('Sidebar — solo ve /groups', () => {
|
|
test('ve /groups', async ({ page }) => expectSidebarLink(page, '/groups', true));
|
|
test('NO ve /dhcp-servers', async ({ page }) => expectSidebarLink(page, '/dhcp-servers', false));
|
|
test('NO ve /boot-servers', async ({ page }) => expectSidebarLink(page, '/boot-servers', false));
|
|
test('NO ve /calendars', async ({ page }) => expectSidebarLink(page, '/calendars', false));
|
|
test('NO ve /repositories', async ({ page }) => expectSidebarLink(page, '/repositories', false));
|
|
test('NO ve /menus', async ({ page }) => expectSidebarLink(page, '/menus', false));
|
|
});
|
|
|
|
// ── Rutas bloqueadas: redirige a /groups ─────────────────────────────────────
|
|
test.describe('Rutas de admin → redirigen a /groups', () => {
|
|
const blocked = [
|
|
'/users', '/roles', '/env-vars',
|
|
'/commands', '/dhcp-servers', '/boot-servers',
|
|
'/calendars', '/repositories', '/pxe',
|
|
];
|
|
for (const route of blocked) {
|
|
test(`${route} → redirige a /groups`, async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, route);
|
|
expect(finalUrl).toContain('/groups');
|
|
});
|
|
}
|
|
});
|
|
|
|
// ── Rutas permitidas: operaciones de equipos ─────────────────────────────────
|
|
test.describe('Rutas de operación — puede acceder', () => {
|
|
test('accede a /groups', async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, '/groups');
|
|
expect(finalUrl).toContain('/groups');
|
|
});
|
|
|
|
test('accede a /clients/deploy-image', async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, '/clients/deploy-image');
|
|
expect(finalUrl).toContain('/clients/deploy-image');
|
|
});
|
|
|
|
test('accede a /clients/partition-assistant', async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, '/clients/partition-assistant');
|
|
expect(finalUrl).toContain('/clients/partition-assistant');
|
|
});
|
|
|
|
test('accede a /clients/run-script', async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, '/clients/run-script');
|
|
expect(finalUrl).toContain('/clients/run-script');
|
|
});
|
|
|
|
test('accede a /commands-logs (trazas de sus acciones)', async ({ page }) => {
|
|
const finalUrl = await navigateTo(page, '/commands-logs');
|
|
expect(finalUrl).toContain('/commands-logs');
|
|
});
|
|
});
|
|
|
|
// ── GUI en /groups: botones de crear OU/cliente ocultos ─────────────────────
|
|
test.describe('/groups — botones de creación ocultos', () => {
|
|
test('NO ve el botón "Añadir OU"', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/groups`);
|
|
await page.waitForLoadState('networkidle');
|
|
// *ngIf="auth.userCategory !== 'ou-operator' && ..."
|
|
const addOuBtn = page.locator('button.action-button').filter({ hasText: /ou|unidad/i });
|
|
await expect(addOuBtn).not.toBeAttached({ timeout: 5_000 });
|
|
});
|
|
|
|
test('NO ve el botón de menú "Añadir cliente"', async ({ page }) => {
|
|
await page.goto(`${APP_URL}/groups`);
|
|
await page.waitForLoadState('networkidle');
|
|
// Los botones de acción principales no deben aparecer para operator
|
|
const actionBtns = page.locator('button.action-button');
|
|
await expect(actionBtns).not.toBeAttached({ timeout: 5_000 });
|
|
});
|
|
});
|
|
});
|