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>
156 lines
5.3 KiB
TypeScript
156 lines
5.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { login, navigateTo, PORT_SLUG } from './helpers';
|
|
|
|
test.describe('Notifications', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page, 'super_admin');
|
|
await navigateTo(page, '/');
|
|
await page.waitForTimeout(2_000);
|
|
});
|
|
|
|
// Test 11: Notification bell renders in header
|
|
test('notification bell renders in header with count', async ({ page }) => {
|
|
// 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;
|
|
if (hasBell) {
|
|
bellFound = true;
|
|
await expect(btn).toBeVisible();
|
|
break;
|
|
}
|
|
}
|
|
expect(bellFound).toBeTruthy();
|
|
});
|
|
|
|
// 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();
|
|
|
|
if (await bellBtn.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
|
await bellBtn.click();
|
|
await page.waitForTimeout(1_000);
|
|
|
|
// Should see a popover with "Notifications" heading
|
|
const popover = page.locator('[data-radix-popper-content-wrapper], [role="dialog"]').first();
|
|
await expect(popover).toBeVisible({ timeout: 3_000 });
|
|
|
|
const heading = popover.getByText('Notifications').first();
|
|
await expect(heading).toBeVisible({ timeout: 3_000 });
|
|
}
|
|
});
|
|
|
|
// Test 13: Advancing interest stage creates a notification
|
|
test('interest stage change creates notification', async ({ page }) => {
|
|
// Navigate to interests list
|
|
await navigateTo(page, '/interests');
|
|
await page.waitForTimeout(2_000);
|
|
|
|
// Check if there are any interests to work with
|
|
const interestRow = page.locator('table tbody tr, [data-testid*="interest"]').first();
|
|
if (await interestRow.isVisible({ timeout: 5_000 }).catch(() => false)) {
|
|
// Click into the first interest
|
|
await interestRow.click();
|
|
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();
|
|
|
|
if (await stageSelector.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
|
// Change the stage
|
|
await stageSelector.click();
|
|
await page.waitForTimeout(500);
|
|
const nextStage = page.getByRole('option').nth(1);
|
|
if (await nextStage.isVisible({ timeout: 2_000 }).catch(() => false)) {
|
|
await nextStage.click();
|
|
await page.waitForTimeout(3_000);
|
|
}
|
|
}
|
|
}
|
|
// The notification creation is async via socket — we verify the bell in the next test
|
|
expect(true).toBeTruthy();
|
|
});
|
|
|
|
// 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();
|
|
|
|
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();
|
|
if (await notifItem.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
|
await notifItem.click();
|
|
await page.waitForTimeout(2_000);
|
|
// Should have navigated
|
|
expect(page.url()).toContain(`/${PORT_SLUG}/`);
|
|
}
|
|
}
|
|
});
|
|
|
|
// 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();
|
|
|
|
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 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();
|
|
await firstNotif.click();
|
|
await page.waitForTimeout(2_000);
|
|
|
|
// Go back and check — the unread indicator should be gone or reduced
|
|
await page.goBack();
|
|
await page.waitForTimeout(1_000);
|
|
}
|
|
}
|
|
expect(true).toBeTruthy();
|
|
});
|
|
});
|