test(e2e): repair 26 Playwright smoke-test failures
Failures were mostly stale selectors, not product regressions:
- .or() traps matching the topbar "+ New" button → use specific names
(Add Webhook, New Field, New Template)
- broad /create|add|new/ patterns → same fix
- [role="dialog"] overlay matched before content → getByRole('dialog').last()
- locator('input') picked hidden Radix Select inputs → getByPlaceholder /
getByRole('combobox', { name })
- 11-global-search rewritten for the inline topbar search (the cmdk
CommandDialog the old tests targeted was replaced)
- missing .first() causing strict-mode failures on notifications heading,
version history text, nav links
- dashboard landing test: no h1 exists, target KPI text instead
- activity-feed: items aren't anchors; match action badge text
- monitoring data-leak check scoped to <main> (sidebar has Email/Documents)
- admin API without port context returns 400 (not 403) for non-admins —
accept 400 as a valid "blocked" status in the sales-agent test
Also dropped dead imports and unused locals surfaced by lint-staged.
Full suite: 124 passed (11.2m).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { login, navigateTo, PORT_SLUG } from './helpers';
|
||||
import { login, navigateTo } from './helpers';
|
||||
|
||||
test.describe('Document Templates', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
@@ -20,12 +20,12 @@ test.describe('Document Templates', () => {
|
||||
await navigateTo(page, '/admin/templates');
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
const createBtn = page.getByRole('button', { name: /create|add|new/i }).first();
|
||||
const createBtn = page.getByRole('button', { name: 'New Template' }).first();
|
||||
await expect(createBtn).toBeVisible({ timeout: 5_000 });
|
||||
await createBtn.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
const dialog = page.locator('[role="dialog"], [data-state="open"]').first();
|
||||
const dialog = page.getByRole('dialog').last();
|
||||
await expect(dialog).toBeVisible({ timeout: 3_000 });
|
||||
|
||||
// Fill name
|
||||
@@ -43,8 +43,8 @@ test.describe('Document Templates', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// The template editor could be TipTap or a JSON textarea
|
||||
const contentArea = dialog.locator('textarea, [contenteditable="true"], .ProseMirror').first();
|
||||
// The template editor is a JSON textarea with id="template-content"
|
||||
const contentArea = page.locator('#template-content');
|
||||
await expect(contentArea).toBeVisible({ timeout: 5_000 });
|
||||
});
|
||||
|
||||
@@ -53,19 +53,19 @@ test.describe('Document Templates', () => {
|
||||
await navigateTo(page, '/admin/templates');
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
const createBtn = page.getByRole('button', { name: /create|add|new/i }).first();
|
||||
const createBtn = page.getByRole('button', { name: 'New Template' }).first();
|
||||
if (await createBtn.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await createBtn.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
const dialog = page.locator('[role="dialog"], [data-state="open"]').first();
|
||||
const dialog = page.getByRole('dialog').last();
|
||||
|
||||
// Fill name
|
||||
const nameInput = dialog.locator('input').first();
|
||||
await nameInput.fill('Variable Test Template');
|
||||
|
||||
// Type content with variable
|
||||
const contentArea = dialog.locator('textarea, [contenteditable="true"]').first();
|
||||
// Type content with variable (textarea with id="template-content")
|
||||
const contentArea = page.locator('#template-content');
|
||||
if (await contentArea.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
// For textarea: paste TipTap JSON with variables
|
||||
const tiptapJson = JSON.stringify({
|
||||
@@ -135,7 +135,7 @@ test.describe('Document Templates', () => {
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
// Modify and save
|
||||
const dialog = page.locator('[role="dialog"], [data-state="open"]').first();
|
||||
const dialog = page.getByRole('dialog').last();
|
||||
const nameInput = dialog.locator('input').first();
|
||||
const currentName = await nameInput.inputValue();
|
||||
await nameInput.fill(currentName + ' (edited)');
|
||||
@@ -155,7 +155,11 @@ test.describe('Document Templates', () => {
|
||||
|
||||
// Should show version entries
|
||||
const versionList = page.locator('[role="dialog"]').last();
|
||||
const hasVersions = await versionList.getByText(/version|v\d/i).isVisible({ timeout: 3_000 }).catch(() => false);
|
||||
const hasVersions = await versionList
|
||||
.getByText(/version|v\d/i)
|
||||
.first()
|
||||
.isVisible({ timeout: 3_000 })
|
||||
.catch(() => false);
|
||||
expect(hasVersions).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user