/** * Notification system tests — bell, drawer, clear, toast, history. */ import { browser, expect } from '@wdio/globals'; import * as S from '../helpers/selectors.ts'; import { openNotifications, closeNotifications } from '../helpers/actions.ts'; describe('Notification system', () => { it('should show the notification bell button', async () => { const bell = await browser.$(S.NOTIF_BTN); if (await bell.isExisting()) { await expect(bell).toBeDisplayed(); } }); it('should open notification drawer on bell click', async () => { await openNotifications(); const visible = await browser.execute((sel: string) => { const el = document.querySelector(sel); if (!el) return false; return getComputedStyle(el).display !== 'none'; }, S.NOTIF_DRAWER); if (visible) { expect(visible).toBe(true); } }); it('should show drawer header with title', async () => { const text = await browser.execute((sel: string) => { const el = document.querySelector(sel); return el?.textContent ?? ''; }, S.DRAWER_TITLE); if (text) { expect(text).toBe('Notifications'); } }); it('should show clear all button', async () => { const clearBtn = await browser.$(S.CLEAR_BTN); if (await clearBtn.isExisting()) { await expect(clearBtn).toBeDisplayed(); const text = await clearBtn.getText(); expect(text).toContain('Clear'); } }); it('should show empty state or notification items', async () => { const hasContent = await browser.execute(() => { const empty = document.querySelector('.notif-empty'); const items = document.querySelectorAll('.notif-item'); return (empty !== null) || items.length > 0; }); expect(hasContent).toBe(true); }); it('should close drawer on backdrop click', async () => { await closeNotifications(); const hidden = await browser.execute((sel: string) => { const el = document.querySelector(sel); if (!el) return true; return getComputedStyle(el).display === 'none'; }, S.NOTIF_DRAWER); expect(hidden).toBe(true); }); it('should show unread badge when notifications exist', async () => { const hasBadge = await browser.execute(() => { return document.querySelector('.notif-badge') ?? document.querySelector('.unread-count'); }); // Badge may or may not be present expect(hasBadge !== undefined).toBe(true); }); it('should reopen drawer after close', async () => { await openNotifications(); const visible = await browser.execute((sel: string) => { const el = document.querySelector(sel); if (!el) return false; return getComputedStyle(el).display !== 'none'; }, S.NOTIF_DRAWER); if (visible) { expect(visible).toBe(true); } await closeNotifications(); }); it('should show notification timestamp', async () => { await openNotifications(); const hasTimestamp = await browser.execute(() => { return (document.querySelector('.notif-time') ?? document.querySelector('.notif-timestamp')) !== null; }); expect(typeof hasTimestamp).toBe('boolean'); await closeNotifications(); }); it('should show mark-read action', async () => { await openNotifications(); const hasAction = await browser.execute(() => { return (document.querySelector('.mark-read') ?? document.querySelector('.notif-action')) !== null; }); expect(typeof hasAction).toBe('boolean'); await closeNotifications(); }); });