feat(admin): E2E CRUD/i18n polish, IFT smoke workflow, fix edit payload wiping id. Refs EventHub/EventHubFrontAdmin#33 #37 #38 #39
This commit is contained in:
@@ -23,3 +23,20 @@ Helper: `src/lib/testid.ts`.
|
||||
- kebab-case; dynamic id = API entity id (or banned word)
|
||||
- Prefer a11y for login fields
|
||||
- Do not decorate decorative wrappers
|
||||
|
||||
## Запуск
|
||||
|
||||
| Команда | Назначение |
|
||||
|---------|------------|
|
||||
| `npm run test:e2e` | mock-suite (CI / PR), API через Playwright route |
|
||||
| `npm run test:e2e:ift` | IFT smoke (живой API), см. ниже |
|
||||
|
||||
### IFT secrets (Gitea → Settings → Secrets)
|
||||
|
||||
| Secret | Обязателен | Назначение |
|
||||
|--------|------------|------------|
|
||||
| `E2E_ADMIN_EMAIL` | да | логин smoke-админа на IFT |
|
||||
| `E2E_ADMIN_PASSWORD` | да | пароль |
|
||||
| `E2E_IFT_BASE_URL` | нет | default `https://admin-ui.ift.eventhub.local` |
|
||||
|
||||
Workflow `e2e-ift.yml` стартует после успешного `Deploy IFT (admin)`.
|
||||
|
||||
@@ -85,8 +85,9 @@ export function createContentSeed() {
|
||||
{
|
||||
id: 'sub-e2e-1',
|
||||
user_id: 'user-e2e-1',
|
||||
plan: 'pro',
|
||||
plan: 'monthly',
|
||||
status: 'active',
|
||||
trial_used: false,
|
||||
started_at: now,
|
||||
expires_at: '2027-01-01T00:00:00Z',
|
||||
auto_renew: true,
|
||||
@@ -96,8 +97,8 @@ export function createContentSeed() {
|
||||
];
|
||||
|
||||
const bannedWords = [
|
||||
{ word: 'spamword', added_by: 'admin-e2e-1', created_at: now },
|
||||
{ word: 'badword', added_by: 'admin-e2e-1', created_at: now },
|
||||
{ word: 'spamword', added_by: 'admin-e2e-1', added_at: now },
|
||||
{ word: 'badword', added_by: 'admin-e2e-1', added_at: now },
|
||||
];
|
||||
|
||||
const admins = [
|
||||
|
||||
@@ -70,7 +70,9 @@ export async function tryHandleContentApi(
|
||||
return true;
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
content.users[idx] = { ...content.users[idx], ...(postData() as object) };
|
||||
const patch = (postData() || {}) as Record<string, unknown>;
|
||||
delete patch.id;
|
||||
content.users[idx] = { ...content.users[idx], ...patch, id };
|
||||
await json(route, 200, content.users[idx]);
|
||||
return true;
|
||||
}
|
||||
@@ -114,7 +116,9 @@ export async function tryHandleContentApi(
|
||||
return true;
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
content.calendars[idx] = { ...content.calendars[idx], ...(postData() as object) };
|
||||
const patch = (postData() || {}) as Record<string, unknown>;
|
||||
delete patch.id;
|
||||
content.calendars[idx] = { ...content.calendars[idx], ...patch, id };
|
||||
await json(route, 200, content.calendars[idx]);
|
||||
return true;
|
||||
}
|
||||
@@ -155,7 +159,9 @@ export async function tryHandleContentApi(
|
||||
return true;
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
content.events[idx] = { ...content.events[idx], ...(postData() as object) };
|
||||
const patch = (postData() || {}) as Record<string, unknown>;
|
||||
delete patch.id;
|
||||
content.events[idx] = { ...content.events[idx], ...patch, id };
|
||||
await json(route, 200, content.events[idx]);
|
||||
return true;
|
||||
}
|
||||
@@ -197,7 +203,9 @@ export async function tryHandleContentApi(
|
||||
return true;
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
content.subscriptions[idx] = { ...content.subscriptions[idx], ...(postData() as object) };
|
||||
const patch = (postData() || {}) as Record<string, unknown>;
|
||||
delete patch.id;
|
||||
content.subscriptions[idx] = { ...content.subscriptions[idx], ...patch, id };
|
||||
await json(route, 200, content.subscriptions[idx]);
|
||||
return true;
|
||||
}
|
||||
@@ -221,7 +229,7 @@ export async function tryHandleContentApi(
|
||||
if (method === 'POST' && path.endsWith('/v1/admin/banned-words')) {
|
||||
const payload = postData() as { word?: string };
|
||||
const word = (payload.word || '').trim();
|
||||
if (word) content.bannedWords.push({ word, added_by: 'admin-e2e-1', created_at: '2026-07-14T12:00:00Z' });
|
||||
if (word) content.bannedWords.push({ word, added_by: 'admin-e2e-1', added_at: '2026-07-14T12:00:00Z' });
|
||||
await json(route, 200, { ok: true });
|
||||
return true;
|
||||
}
|
||||
@@ -293,19 +301,30 @@ export async function tryHandleContentApi(
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- monitoring enrichment ----
|
||||
// ---- monitoring ----
|
||||
if (method === 'GET' && path.includes('/v1/admin/nodes/metrics')) {
|
||||
await json(route, 200, {
|
||||
nodes: [
|
||||
{
|
||||
node: 'node-a',
|
||||
cpu: 12,
|
||||
memory_used_mb: 512,
|
||||
memory_total_mb: 2048,
|
||||
ts: '2026-07-14T12:00:00Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
await json(route, 200, [
|
||||
{
|
||||
active_sessions: 3,
|
||||
io_in: 10,
|
||||
io_out: 20,
|
||||
memory_atom: 1,
|
||||
memory_binary: 2,
|
||||
memory_ets: 3,
|
||||
memory_processes: 4,
|
||||
memory_total: 2048,
|
||||
mnesia_commits: 1,
|
||||
mnesia_failures: 0,
|
||||
node: 'node-a',
|
||||
process_count: 100,
|
||||
run_queue: 0,
|
||||
table_sizes: { users: 10 },
|
||||
timestamp: '2026-07-14T12:00:00Z',
|
||||
ws_connections: 5,
|
||||
cpu_utilization: 12,
|
||||
memory_available: 1024,
|
||||
},
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,101 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { seedAuthenticatedSession } from '../helpers/session';
|
||||
|
||||
async function openRowAction(page: Page, id: string, label: RegExp) {
|
||||
await page.getByTestId(`row-actions-${id}`).click();
|
||||
await page.getByRole('menuitem', { name: label }).click();
|
||||
}
|
||||
|
||||
/** Radix Select in edit dialogs — ensure option chosen so Save enables. */
|
||||
async function pickDialogOption(page: Page, dialogTestId: string, comboboxIndex: number, option: string) {
|
||||
const dialog = page.getByTestId(dialogTestId);
|
||||
await dialog.getByRole('combobox').nth(comboboxIndex).click();
|
||||
await page.getByRole('option', { name: option, exact: true }).click();
|
||||
}
|
||||
|
||||
test.describe('content explore (mock)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await seedAuthenticatedSession(page);
|
||||
});
|
||||
|
||||
test('users: список, поиск, detail', async ({ page }) => {
|
||||
test('users: список, поиск, detail, edit, delete', async ({ page }) => {
|
||||
await page.goto('/users');
|
||||
await expect(page.getByTestId('page-users')).toBeVisible();
|
||||
await page.getByTestId('view-rows').click();
|
||||
await expect(page.getByTestId('row-user-e2e-1')).toBeVisible();
|
||||
await page.getByTestId('filter-users-search-input').fill('Alice');
|
||||
await page.getByTestId('filter-users-search').locator('button[type="submit"]').click();
|
||||
await expect(page.getByTestId('row-user-e2e-1')).toBeVisible();
|
||||
|
||||
await openRowAction(page, 'user-e2e-1', /редакт|edit/i);
|
||||
await expect(page.getByTestId('dialog-edit-user')).toBeVisible();
|
||||
await page.getByLabel(/ник|nickname/i).fill('Alice E2E');
|
||||
await pickDialogOption(page, 'dialog-edit-user', 0, 'user');
|
||||
await pickDialogOption(page, 'dialog-edit-user', 1, 'active');
|
||||
await expect(page.getByTestId('btn-save')).toBeEnabled();
|
||||
await page.getByTestId('btn-save').click();
|
||||
await expect(page.getByTestId('dialog-edit-user')).toHaveCount(0);
|
||||
|
||||
await page.goto('/users/user-e2e-1');
|
||||
await expect(page.getByTestId('page-user-detail')).toBeVisible();
|
||||
|
||||
await page.goto('/users');
|
||||
await page.getByTestId('view-rows').click();
|
||||
await openRowAction(page, 'user-e2e-2', /удал|delete/i);
|
||||
await expect(page.getByTestId('dialog-delete-user')).toBeVisible();
|
||||
await page.getByTestId('btn-delete-confirm').click();
|
||||
await expect(page.getByTestId('row-user-e2e-2')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('calendars: список и detail', async ({ page }) => {
|
||||
test('calendars: edit и detail', async ({ page }) => {
|
||||
await page.goto('/calendars');
|
||||
await expect(page.getByTestId('page-calendars')).toBeVisible();
|
||||
await page.getByTestId('view-rows').click();
|
||||
await expect(page.getByTestId('row-cal-e2e-1')).toBeVisible();
|
||||
await openRowAction(page, 'cal-e2e-1', /редакт|edit/i);
|
||||
await expect(page.getByTestId('dialog-edit-calendar')).toBeVisible();
|
||||
await page.getByTestId('dialog-edit-calendar').locator('input').first().fill('E2E Calendar');
|
||||
await pickDialogOption(page, 'dialog-edit-calendar', 0, 'personal');
|
||||
await pickDialogOption(page, 'dialog-edit-calendar', 1, 'active');
|
||||
await expect(page.getByTestId('btn-save')).toBeEnabled();
|
||||
await page.getByTestId('btn-save').click();
|
||||
await expect(page.getByTestId('dialog-edit-calendar')).toHaveCount(0);
|
||||
await page.goto('/calendars/cal-e2e-1');
|
||||
await expect(page.getByTestId('page-calendar-detail')).toBeVisible();
|
||||
});
|
||||
|
||||
test('events: список и detail', async ({ page }) => {
|
||||
test('events: edit и detail', async ({ page }) => {
|
||||
await page.goto('/events');
|
||||
await expect(page.getByTestId('page-events')).toBeVisible();
|
||||
await page.getByTestId('view-rows').click();
|
||||
await expect(page.getByTestId('row-evt-e2e-1')).toBeVisible();
|
||||
await openRowAction(page, 'evt-e2e-1', /редакт|edit/i);
|
||||
await expect(page.getByTestId('dialog-edit-event')).toBeVisible();
|
||||
await page.getByTestId('dialog-edit-event').locator('input').first().fill('E2E Workout');
|
||||
await pickDialogOption(page, 'dialog-edit-event', 0, 'single');
|
||||
await pickDialogOption(page, 'dialog-edit-event', 1, 'active');
|
||||
await expect(page.getByTestId('btn-save')).toBeEnabled();
|
||||
// Tall dialog: footer can sit outside viewport; submit via form API.
|
||||
await page.getByTestId('dialog-edit-event').locator('form').evaluate((form) => {
|
||||
(form as HTMLFormElement).requestSubmit();
|
||||
});
|
||||
await expect(page.getByTestId('dialog-edit-event')).toHaveCount(0);
|
||||
await page.goto('/events/evt-e2e-1');
|
||||
await expect(page.getByTestId('page-event-detail')).toBeVisible();
|
||||
});
|
||||
|
||||
test('subscriptions: список', async ({ page }) => {
|
||||
test('subscriptions: edit и delete', async ({ page }) => {
|
||||
await page.goto('/subscriptions');
|
||||
await expect(page.getByTestId('page-subscriptions')).toBeVisible();
|
||||
await page.getByTestId('view-rows').click();
|
||||
await expect(page.getByTestId('row-sub-e2e-1')).toBeVisible();
|
||||
await openRowAction(page, 'sub-e2e-1', /редакт|edit/i);
|
||||
await expect(page.getByTestId('dialog-edit-subscription')).toBeVisible();
|
||||
await pickDialogOption(page, 'dialog-edit-subscription', 0, 'monthly');
|
||||
await pickDialogOption(page, 'dialog-edit-subscription', 1, 'active');
|
||||
await page.getByTestId('btn-save').click();
|
||||
await expect(page.getByTestId('dialog-edit-subscription')).toHaveCount(0);
|
||||
await openRowAction(page, 'sub-e2e-1', /удал|delete/i);
|
||||
await expect(page.getByTestId('dialog-delete-subscription')).toBeVisible();
|
||||
await page.getByTestId('btn-delete-confirm').click();
|
||||
await expect(page.getByTestId('row-sub-e2e-1')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('banned-words: список и add', async ({ page }) => {
|
||||
|
||||
@@ -75,10 +75,16 @@ test.describe('reviews explore (mock)', () => {
|
||||
await seedAuthenticatedSession(page);
|
||||
});
|
||||
|
||||
test('страница reviews рендерится, bulk отключён без выбора', async ({ page }) => {
|
||||
test('страница reviews и bulk hide', async ({ page }) => {
|
||||
await page.goto('/reviews');
|
||||
await expect(page.getByTestId('page-reviews')).toBeVisible();
|
||||
await page.getByTestId('view-table').click();
|
||||
await expect(page.getByText('Great event')).toBeVisible();
|
||||
await expect(page.getByTestId('btn-reviews-bulk-hidden')).toBeDisabled();
|
||||
await page.getByTestId('review-check-rev-vis-1').check();
|
||||
await page.getByTestId('btn-reviews-bulk-hidden').click();
|
||||
await expect(page.getByTestId('dialog-reviews-bulk-status')).toBeVisible();
|
||||
await page.getByTestId('input-bulk-reason').fill('e2e hide');
|
||||
await page.getByTestId('btn-save').click();
|
||||
await expect(page.getByTestId('dialog-reviews-bulk-status')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,11 +24,12 @@ test.describe('system / overview (mock)', () => {
|
||||
await expect(page.getByTestId('row-audit-e2e-1')).toBeVisible();
|
||||
});
|
||||
|
||||
test('monitoring: страница и range', async ({ page }) => {
|
||||
test('monitoring: страница, range и node', async ({ page }) => {
|
||||
await page.goto('/monitoring');
|
||||
await expect(page.getByTestId('page-monitoring')).toBeVisible();
|
||||
await page.getByTestId('filter-monitoring-range-30').click();
|
||||
await expect(page.getByTestId('filter-monitoring-range-30')).toBeVisible();
|
||||
await page.getByTestId('filter-monitoring-node-node-a').click();
|
||||
await expect(page).toHaveURL(/node=node-a/);
|
||||
});
|
||||
|
||||
test('profile: view и edit', async ({ page }) => {
|
||||
@@ -47,13 +48,15 @@ test.describe('system / overview (mock)', () => {
|
||||
});
|
||||
|
||||
test.describe('i18n (mock)', () => {
|
||||
test('переключение языка через меню', async ({ page }) => {
|
||||
test('переключение языка через меню меняет UI', async ({ page }) => {
|
||||
await seedAuthenticatedSession(page);
|
||||
await page.goto('/dashboard');
|
||||
await page.getByTestId('menu-user').click();
|
||||
await expect(page.getByTestId('menu-profile')).toHaveText(/Мой профиль/i);
|
||||
await page.getByTestId('lang-en').click();
|
||||
// profile language mutation returns user with language=en; menu stays open or reopens
|
||||
await page.getByTestId('menu-user').click().catch(() => undefined);
|
||||
await expect(page.getByTestId('lang-en')).toBeVisible();
|
||||
// Dropdown may close; reopen after store + i18n sync from PUT /me
|
||||
await expect(page.getByText(/Профиль обновлён|Profile updated/i)).toBeVisible({ timeout: 15_000 });
|
||||
await page.getByTestId('menu-user').click();
|
||||
await expect(page.getByTestId('menu-profile')).toHaveText(/My profile/i);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user