Files
postgres/tests/e2e/AdminDashboard.e2e.ts
2026-01-08 04:10:37 +00:00

139 lines
4.9 KiB
TypeScript

import { expect, test } from '@playwright/test';
test.describe('Admin Dashboard', () => {
test.describe('Navigation', () => {
test('should redirect to login when not authenticated', async ({ page }) => {
await page.goto('/admin/dashboard');
// Should redirect to login page or show 401
await expect(page).toHaveURL(/\/admin\/login/);
});
test('should display login page with form', async ({ page }) => {
await page.goto('/admin/login');
await expect(page.getByLabel(/username/i)).toBeVisible();
await expect(page.getByLabel(/password/i)).toBeVisible();
await expect(page.getByRole('button', { name: /login/i })).toBeVisible();
});
});
test.describe('Table Manager UI', () => {
test.skip('should display Table Manager tab after login', async ({ page }) => {
// This test would require actual authentication
// Skipping for now as it needs a real admin user
await page.goto('/admin/login');
// Login flow would go here
// await page.fill('input[name="username"]', 'admin');
// await page.fill('input[name="password"]', 'admin123');
// await page.click('button[type="submit"]');
// Then verify Table Manager tab exists
// await expect(page.getByText('Table Manager')).toBeVisible();
});
test.skip('should open create table dialog', async ({ page }) => {
// This test would require authentication
// Skipping for now
// await page.goto('/admin/dashboard');
// await page.getByText('Table Manager').click();
// await page.getByRole('button', { name: /create table/i }).click();
// await expect(page.getByText('Create New Table')).toBeVisible();
// await expect(page.getByLabel(/table name/i)).toBeVisible();
});
});
test.describe('Column Manager UI', () => {
test.skip('should display Column Manager tab after login', async ({ page }) => {
// This test would require actual authentication
// Skipping for now
// await page.goto('/admin/dashboard');
// await expect(page.getByText('Column Manager')).toBeVisible();
});
test.skip('should show table selector in Column Manager', async ({ page }) => {
// This test would require authentication
// Skipping for now
// await page.goto('/admin/dashboard');
// await page.getByText('Column Manager').click();
// await expect(page.getByText(/select a table/i)).toBeVisible();
});
});
test.describe('Admin Panel Security', () => {
test('should not allow access to admin API without auth', async ({ page }) => {
const response = await page.request.get('/api/admin/tables');
expect(response.status()).toBe(401);
});
test('should not allow table management without auth', async ({ page }) => {
const response = await page.request.post('/api/admin/table-manage', {
data: {
tableName: 'test',
columns: [{ name: 'id', type: 'INTEGER' }],
},
});
expect(response.status()).toBe(401);
});
test('should not allow column management without auth', async ({ page }) => {
const response = await page.request.post('/api/admin/column-manage', {
data: {
tableName: 'test',
columnName: 'col',
dataType: 'INTEGER',
},
});
expect(response.status()).toBe(401);
});
test('should not allow constraint management without auth', async ({ page }) => {
const response = await page.request.get('/api/admin/constraints?tableName=test');
expect(response.status()).toBe(401);
});
});
test.describe('Constraints Manager UI', () => {
test.skip('should display Constraints tab after login', async ({ page }) => {
// This test would require actual authentication
// Skipping for now as it needs a real admin user
// await page.goto('/admin/dashboard');
// await expect(page.getByText('Constraints')).toBeVisible();
});
test.skip('should show table selector in Constraints Manager', async ({ page }) => {
// This test would require authentication
// Skipping for now
// await page.goto('/admin/dashboard');
// await page.getByText('Constraints').click();
// await expect(page.getByText(/select a table/i)).toBeVisible();
});
test.skip('should open add constraint dialog', async ({ page }) => {
// This test would require authentication
// Skipping for now
// await page.goto('/admin/dashboard');
// await page.getByText('Constraints').click();
// Select a table first
// await page.getByRole('button', { name: /add constraint/i }).click();
// await expect(page.getByText('Add Constraint')).toBeVisible();
// await expect(page.getByLabel(/constraint name/i)).toBeVisible();
});
});
});