krona-front/e2e/app.spec.ts

73 lines
2.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Krona Business OS — E2E Verification & Visual Matrix', () => {
test('loads Dashboard without console errors or horizontal overflow', async ({ page }) => {
const consoleErrors: string[] = [];
page.on('console', (msg) => {
if (msg.type() === 'error') {
consoleErrors.push(msg.text());
}
});
await page.goto('/');
await page.waitForLoadState('domcontentloaded');
// Verify brand header / title
await expect(page.locator('text=Крона').first()).toBeVisible();
// Check horizontal overflow (scrollWidth <= clientWidth)
const isOverflowing = await page.evaluate(() => {
return document.documentElement.scrollWidth > document.documentElement.clientWidth;
});
expect(isOverflowing).toBe(false);
// Ensure no uncaught browser runtime errors
const fatalErrors = consoleErrors.filter(
(err) => !err.includes('favicon') && !err.includes('status of 404')
);
expect(fatalErrors).toHaveLength(0);
});
test('captures theme and viewport screenshot matrix', async ({ page }, testInfo) => {
const themes = ['soft-light', 'light', 'dark'] as const;
const projectName = testInfo.project.name; // desktop | tablet | mobile
for (const theme of themes) {
await page.goto('/');
await page.waitForLoadState('domcontentloaded');
// Set data-theme attribute directly on documentElement
await page.evaluate((t) => {
document.documentElement.setAttribute('data-theme', t);
localStorage.setItem('krona_theme_mode', t);
}, theme);
await page.waitForTimeout(300);
// Save screenshot
await page.screenshot({
path: `e2e/screenshots/${projectName}_${theme}.png`,
fullPage: false,
});
}
});
test('advances CRM deal stage and verifies kanban status update', async ({ page }) => {
await page.goto('/crm/deals');
await page.waitForLoadState('domcontentloaded');
// Switch to Deals tab if not default
const dealsTab = page.locator('button:has-text("Воронка сделок")');
if (await dealsTab.isVisible()) {
await dealsTab.click({ force: true });
}
// Verify Deal cards are rendered in Kanban
const dealCards = page.locator('[data-testid^="deal-card-"], .group\\/deal, [draggable="true"]');
await expect(dealCards.first()).toBeVisible({ timeout: 15000 });
// Verify kanban stages exist
await expect(page.getByText('Квалификация', { exact: true }).first()).toBeVisible();
await expect(page.getByText('Выиграна', { exact: true }).first()).toBeVisible();
});
});