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:
@@ -10,17 +10,13 @@ test.describe('Notifications', () => {
|
||||
|
||||
// Test 11: Notification bell renders in header
|
||||
test('notification bell renders in header with count', async ({ page }) => {
|
||||
// The NotificationBell component should render a bell icon button
|
||||
const bellButton = page.locator('header button').filter({ has: page.locator('svg') });
|
||||
const bellWithPopover = page.locator('[data-testid="notification-bell"], header button:has(svg.lucide-bell)').first();
|
||||
|
||||
// Look for a button in the header that contains a Bell SVG
|
||||
const headerButtons = page.locator('header button');
|
||||
let bellFound = false;
|
||||
const count = await headerButtons.count();
|
||||
for (let i = 0; i < count; i++) {
|
||||
const btn = headerButtons.nth(i);
|
||||
const hasBell = await btn.locator('.lucide-bell, [data-lucide="bell"]').count() > 0;
|
||||
const hasBell = (await btn.locator('.lucide-bell, [data-lucide="bell"]').count()) > 0;
|
||||
if (hasBell) {
|
||||
bellFound = true;
|
||||
await expect(btn).toBeVisible();
|
||||
@@ -33,9 +29,12 @@ test.describe('Notifications', () => {
|
||||
// Test 12: Clicking bell opens dropdown with notifications
|
||||
test('clicking bell opens notification dropdown', async ({ page }) => {
|
||||
// Find and click the bell button
|
||||
const bellBtn = page.locator('header button').filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
}).first();
|
||||
const bellBtn = page
|
||||
.locator('header button')
|
||||
.filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
})
|
||||
.first();
|
||||
|
||||
if (await bellBtn.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await bellBtn.click();
|
||||
@@ -45,7 +44,7 @@ test.describe('Notifications', () => {
|
||||
const popover = page.locator('[data-radix-popper-content-wrapper], [role="dialog"]').first();
|
||||
await expect(popover).toBeVisible({ timeout: 3_000 });
|
||||
|
||||
const heading = popover.getByText('Notifications');
|
||||
const heading = popover.getByText('Notifications').first();
|
||||
await expect(heading).toBeVisible({ timeout: 3_000 });
|
||||
}
|
||||
});
|
||||
@@ -64,9 +63,12 @@ test.describe('Notifications', () => {
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
// Look for a stage change button/dropdown
|
||||
const stageSelector = page.locator('select, [role="combobox"]').filter({
|
||||
has: page.getByText(/open|details|communication|visited/i),
|
||||
}).first();
|
||||
const stageSelector = page
|
||||
.locator('select, [role="combobox"]')
|
||||
.filter({
|
||||
has: page.getByText(/open|details|communication|visited/i),
|
||||
})
|
||||
.first();
|
||||
|
||||
if (await stageSelector.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
// Change the stage
|
||||
@@ -86,16 +88,23 @@ test.describe('Notifications', () => {
|
||||
// Test 14: Click notification navigates to entity
|
||||
test('clicking notification links to entity', async ({ page }) => {
|
||||
// Open notification dropdown
|
||||
const bellBtn = page.locator('header button').filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
}).first();
|
||||
const bellBtn = page
|
||||
.locator('header button')
|
||||
.filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
})
|
||||
.first();
|
||||
|
||||
if (await bellBtn.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await bellBtn.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
// Find the first notification item with a link
|
||||
const notifItem = page.locator('[data-radix-popper-content-wrapper] a, [data-radix-popper-content-wrapper] [role="button"]').first();
|
||||
const notifItem = page
|
||||
.locator(
|
||||
'[data-radix-popper-content-wrapper] a, [data-radix-popper-content-wrapper] [role="button"]',
|
||||
)
|
||||
.first();
|
||||
if (await notifItem.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await notifItem.click();
|
||||
await page.waitForTimeout(2_000);
|
||||
@@ -107,21 +116,32 @@ test.describe('Notifications', () => {
|
||||
|
||||
// Test 15: Notification marks as read after clicking
|
||||
test('notification marks as read after clicking', async ({ page }) => {
|
||||
const bellBtn = page.locator('header button').filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
}).first();
|
||||
const bellBtn = page
|
||||
.locator('header button')
|
||||
.filter({
|
||||
has: page.locator('.lucide-bell'),
|
||||
})
|
||||
.first();
|
||||
|
||||
if (await bellBtn.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await bellBtn.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
// Check for unread indicators (blue dots, bold text, etc.)
|
||||
const unreadIndicator = page.locator('[data-radix-popper-content-wrapper] .bg-blue-500, [data-radix-popper-content-wrapper] [class*="unread"]').first();
|
||||
const unreadIndicator = page
|
||||
.locator(
|
||||
'[data-radix-popper-content-wrapper] .bg-blue-500, [data-radix-popper-content-wrapper] [class*="unread"]',
|
||||
)
|
||||
.first();
|
||||
const hadUnread = await unreadIndicator.isVisible({ timeout: 2_000 }).catch(() => false);
|
||||
|
||||
if (hadUnread) {
|
||||
// Click the first notification
|
||||
const firstNotif = page.locator('[data-radix-popper-content-wrapper] [role="button"], [data-radix-popper-content-wrapper] a').first();
|
||||
const firstNotif = page
|
||||
.locator(
|
||||
'[data-radix-popper-content-wrapper] [role="button"], [data-radix-popper-content-wrapper] a',
|
||||
)
|
||||
.first();
|
||||
await firstNotif.click();
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user