Files
pn-new-crm/tests/e2e/smoke/12-notifications.spec.ts
Matt 221ae5784e chore(autonomous-session): consolidate uncommitted work from prior session
Bundles the prior autonomous-session output that was sitting unstaged:

- Em-dash sweep across src/ + tests/ (en-dash/em-dash to hyphen, ~2280 instances)
- country-flag-icons rollout (CountryFlag component, replaces emoji glyphs that
  never rendered on Windows; lazy-loads the 3x2 SVG index as a single chunk
  after the per-subpath dynamic-import approach silently failed in webpack)
- Admin IA Phase 1+2: 7-domain regroup, 41 to 38 pages, /admin/berths index,
  redirects (ocr to ai, reports to dashboard, invitations to users),
  docs/admin-ia-proposal.md
- Per-template email tester (registry + endpoint + UI on Email admin page)
- Cancel-document mode picker (delete-from-Documenso vs keep-for-audit)
- Dashboard PDF report: 25 widgets, SVG charts, date-range picker, 11 resolvers
- Customize-widgets per-region sortables at xl+ (charts/rails/feed); single
  flat sortable below xl when the layout stacks; per-viewport saved orders
- Audit doc updates capturing each shipped item
- Lint fixes: react-compiler immutability in DonutChart (reduce instead of
  let-reassign), set-state-in-effect disables in CountryFlag and
  UploadForSigning preview-bytes effect, unused 'confirm' destructures in
  interest contract + reservation tabs, unescaped apostrophe in test-template
  card copy
2026-05-23 00:52:59 +02:00

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();
});
});