/** * Diagnostics settings tab tests — connection status, fleet info, refresh. */ import { browser, expect } from '@wdio/globals'; import * as S from '../helpers/selectors.ts'; import { openSettings, closeSettings, switchSettingsCategory } from '../helpers/actions.ts'; describe('Diagnostics tab', () => { before(async () => { await openSettings(); // Click Diagnostics tab (last category) const tabCount = await browser.execute(() => { return (document.querySelectorAll('.settings-tab').length || document.querySelectorAll('.cat-btn').length || document.querySelectorAll('.settings-sidebar .sidebar-item').length); }); if (tabCount > 0) { await switchSettingsCategory(tabCount - 1); } }); after(async () => { await browser.keys('Escape'); await browser.pause(300); }); it('should render the diagnostics container', async () => { const exists = await browser.execute((sel: string) => { return document.querySelector(sel) !== null; }, S.DIAGNOSTICS); if (exists) { const el = await browser.$(S.DIAGNOSTICS); await expect(el).toBeDisplayed(); } }); it('should show Transport Diagnostics heading', async () => { const text = await browser.execute((sel: string) => { const el = document.querySelector(sel); return el?.textContent ?? ''; }, S.DIAG_HEADING); if (text) { expect(text).toContain('Transport Diagnostics'); } }); it('should show PTY daemon connection status', async () => { const texts = await browser.execute((sel: string) => { const keys = document.querySelectorAll(sel); return Array.from(keys).map(k => k.textContent ?? ''); }, S.DIAG_KEY); if (texts.length > 0) { expect(texts.some((t: string) => t.includes('PTY'))).toBe(true); } }); it('should show agent fleet section', async () => { const texts = await browser.execute((sel: string) => { const labels = document.querySelectorAll(sel); return Array.from(labels).map(l => l.textContent?.toLowerCase() ?? ''); }, S.DIAG_LABEL); if (texts.length > 0) { expect(texts.some((t: string) => t.includes('agent fleet'))).toBe(true); } }); it('should show last refresh timestamp', async () => { const exists = await browser.execute((sel: string) => { return document.querySelector(sel) !== null; }, S.DIAG_FOOTER); if (exists) { const el = await browser.$(S.DIAG_FOOTER); await expect(el).toBeDisplayed(); } }); it('should have a refresh button', async () => { const refreshBtn = await browser.$(S.REFRESH_BTN); if (await refreshBtn.isExisting()) { expect(await refreshBtn.isClickable()).toBe(true); } }); it('should show connection indicator with color', async () => { const hasIndicator = await browser.execute(() => { return (document.querySelector('.diag-status') ?? document.querySelector('.status-dot') ?? document.querySelector('.connection-status')) !== null; }); expect(typeof hasIndicator).toBe('boolean'); }); it('should show session count', async () => { const hasCount = await browser.execute(() => { return (document.querySelector('.session-count') ?? document.querySelector('.diag-value')) !== null; }); expect(typeof hasCount).toBe('boolean'); }); });