105 lines
3.4 KiB
TypeScript
Executable file
105 lines
3.4 KiB
TypeScript
Executable file
/**
|
|
* Attributes E2E Tests
|
|
*
|
|
* Tests the attribute definitions page in platform-admin.
|
|
* Verifies attribute listing, filtering, and CRUD operations.
|
|
*/
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Attributes Page', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// Mock API to return sample attributes
|
|
await page.route('**/api/attributes**', (route) => {
|
|
if (route.request().method() === 'GET') {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
attributes: [
|
|
{
|
|
id: 'attr-001',
|
|
code: 'eye_color',
|
|
name: 'Eye Color',
|
|
dataType: 'enum',
|
|
entityType: 'User',
|
|
metaCategory: 'Appearance',
|
|
priority: 'essential',
|
|
grouping: 'Physical',
|
|
searchable: true,
|
|
enumValues: ['blue', 'green', 'brown', 'hazel'],
|
|
createdAt: '2024-01-01T00:00:00Z',
|
|
},
|
|
{
|
|
id: 'attr-002',
|
|
code: 'height_cm',
|
|
name: 'Height',
|
|
dataType: 'number',
|
|
entityType: 'User',
|
|
metaCategory: 'Appearance',
|
|
priority: 'recommended',
|
|
grouping: 'Physical',
|
|
searchable: true,
|
|
createdAt: '2024-01-01T00:00:00Z',
|
|
},
|
|
],
|
|
total: 2,
|
|
}),
|
|
});
|
|
} else {
|
|
route.continue();
|
|
}
|
|
});
|
|
|
|
// Navigate to attributes page
|
|
await page.goto('/attributes');
|
|
await page.waitForLoadState('networkidle');
|
|
});
|
|
|
|
test('should display attributes page header', async ({ page }) => {
|
|
const mainContent = page.locator('main');
|
|
await expect(mainContent.locator('h1').first()).toContainText(/attribute/i);
|
|
});
|
|
|
|
test('should display stats cards', async ({ page }) => {
|
|
await page.waitForTimeout(500);
|
|
|
|
// Check for stat labels
|
|
await expect(page.locator('text=Total').first()).toBeVisible({ timeout: 10000 });
|
|
await expect(page.locator('text=Searchable').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should display filter controls', async ({ page }) => {
|
|
// Look for filter dropdowns/selects
|
|
const filters = page.locator('select');
|
|
await expect(filters.first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should display attributes table', async ({ page }) => {
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for table headers or attribute codes
|
|
await expect(page.locator('text=eye_color').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should show data type badges', async ({ page }) => {
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for data type indicators
|
|
await expect(page.locator('text=/enum|number|string/i').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should show edit button for attributes', async ({ page }) => {
|
|
await page.waitForTimeout(500);
|
|
|
|
// Find edit button
|
|
const editBtn = page.locator('button:has-text("Edit")').first();
|
|
await expect(editBtn).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should show create new attribute button', async ({ page }) => {
|
|
// Find create/add button
|
|
const createBtn = page.locator('button:has-text(/new|add|create/i)').first();
|
|
await expect(createBtn).toBeVisible({ timeout: 10000 });
|
|
});
|
|
});
|