HH/e2e/tests/roles/px-staff.spec.ts
2026-04-19 10:53:12 +03:00

78 lines
2.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { RoleAuthHelper } from '../../helpers/helpers';
test.describe('PX Staff Role', () => {
test.describe.configure({ mode: 'parallel' });
test('login succeeds and goes to dashboard', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
expect(page.url()).not.toContain('login');
expect(page.url()).not.toContain('select-hospital');
});
test('cannot access config dashboard', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
await page.goto('/config/');
const blocked = page.url().includes('command-center') || page.url().includes('analytics') || page.url().toContain('login');
expect(blocked).toBeTruthy();
});
test('can access complaints list', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/complaints/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
test('can access action center', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/actions/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
test('can access surveys templates', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/surveys/templates/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
test('can access surveys analytics', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/surveys/analytics/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
test('can access observations', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/observations/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
test('can access dashboard', async ({ page }) => {
const auth = new RoleAuthHelper(page);
await auth.login('px_staff');
const response = await page.goto('/');
expect(response?.status()).toBeLessThan(400);
expect(page.url()).not.toContain('login');
});
});