Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(playwright): expand desktop layout tests for comprehensive page coverage

LearningCircuit221a2a85a5c2
diff --git a/tests/ui_tests/playwright/tests/desktop-layout.spec.js b/tests/ui_tests/playwright/tests/desktop-layout.spec.js
index 0b0279d7a6..b08ba091b0 100644
--- a/tests/ui_tests/playwright/tests/desktop-layout.spec.js
+++ b/tests/ui_tests/playwright/tests/desktop-layout.spec.js
@@ -1,9 +1,17 @@
/**
* Desktop Layout Tests
*
- * Tests to verify the desktop sidebar layout works correctly
+ * Comprehensive tests to verify the desktop sidebar layout works correctly
* and doesn't overlap with the main content at various viewport sizes.
*
+ * Coverage:
+ * - Main pages with sidebar (Research, History, Settings, News, Library, Metrics)
+ * - Metrics sub-pages (Costs, Star Reviews, Context Overflow, Links)
+ * - News sub-pages (Subscriptions, New Subscription)
+ * - Library sub-pages (Collections, Create Collection, Download Manager, Embedding Settings)
+ * - Auth pages (Login, Register - no sidebar, Change Password - with sidebar)
+ * - Benchmark page
+ *
* Breakpoints tested:
* - 768px-991px: Collapsed sidebar (60px)
* - 992px-1199px: Full sidebar (240px)
@@ -14,304 +22,471 @@
import { test, expect } from '@playwright/test';
-// Only run on desktop browsers
-test.describe('Desktop Sidebar Layout', () => {
- test.beforeEach(async ({ page, isMobile }) => {
- // Skip all tests in this file for mobile devices
- if (isMobile) {
- test.skip();
- return;
+// ============================================
+// HELPER FUNCTIONS
+// ============================================
+
+/**
+ * Verify sidebar doesn't overlap main content
+ */
+async function verifySidebarNoOverlap(page, expectedSidebarWidth = null) {
+ const sidebar = page.locator('.ldr-sidebar');
+ const mainContent = page.locator('.ldr-main-content');
+
+ const sidebarBox = await sidebar.boundingBox();
+ const mainContentBox = await mainContent.boundingBox();
+
+ expect(sidebarBox).not.toBeNull();
+ expect(mainContentBox).not.toBeNull();
+
+ if (sidebarBox && mainContentBox) {
+ // Verify sidebar width if expected
+ if (expectedSidebarWidth) {
+ expect(sidebarBox.width).toBeGreaterThanOrEqual(expectedSidebarWidth - 5);
+ expect(sidebarBox.width).toBeLessThanOrEqual(expectedSidebarWidth + 5);
}
- });
+ // Main content should start after sidebar ends (no overlap)
+ const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
+ expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
+ }
+}
+
+/**
+ * Standard page setup for desktop tests
+ */
+async function setupDesktopPage(page, path, width = 1200, height = 800) {
+ await page.setViewportSize({ width, height });
+ await page.goto(path);
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+}
+
+/**
+ * Check if page has sidebar (some pages like auth don't have sidebar)
+ */
+async function hasSidebar(page) {
+ const sidebar = page.locator('.ldr-sidebar');
+ const count = await sidebar.count();
+ if (count === 0) return false;
+ const isVisible = await sidebar.first().isVisible().catch(() => false);
+ return isVisible;
+}
+
+// ============================================
+// CORE SIDEBAR LAYOUT TESTS (Multiple Viewports)
+// ============================================
+
+test.describe('Desktop Sidebar Layout - Viewport Tests', () => {
test('Sidebar does not overlap main content at 1200px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+ if (isMobile) { test.skip(); return; }
- await page.setViewportSize({ width: 1200, height: 800 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+ await setupDesktopPage(page, '/settings/', 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
- // Get sidebar and main content bounding boxes
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ test('Sidebar does not overlap main content at 1400px width', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+ await setupDesktopPage(page, '/settings/', 1400, 900);
+ await verifySidebarNoOverlap(page, 240);
+ });
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ test('Sidebar does not overlap main content at 1600px width', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- // Main content should start after sidebar ends (no overlap)
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1); // Allow 1px tolerance
- }
+ await setupDesktopPage(page, '/settings/', 1600, 900);
+ await verifySidebarNoOverlap(page, 240);
});
- test('Sidebar does not overlap main content at 1400px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+ test('Sidebar does not overlap main content at 1920px width', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await page.setViewportSize({ width: 1400, height: 900 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+ await setupDesktopPage(page, '/settings/', 1920, 1080);
+ await verifySidebarNoOverlap(page, 240);
+ });
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ test('Collapsed sidebar (60px) at 900px width', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+ await setupDesktopPage(page, '/settings/', 900, 700);
+ await verifySidebarNoOverlap(page, 60);
+ });
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ test('Full sidebar (240px) at 1000px width', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
- }
+ await setupDesktopPage(page, '/settings/', 1000, 700);
+ await verifySidebarNoOverlap(page, 240);
});
+});
- test('Sidebar does not overlap main content at 1600px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+// ============================================
+// MAIN PAGES - SIDEBAR NO OVERLAP TESTS
+// ============================================
- await page.setViewportSize({ width: 1600, height: 900 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+test.describe('Main Pages - Sidebar No Overlap', () => {
+ const mainPages = [
+ { path: '/', name: 'Research' },
+ { path: '/history/', name: 'History' },
+ { path: '/settings/', name: 'Settings' },
+ { path: '/news/', name: 'News' },
+ { path: '/library/', name: 'Library' },
+ { path: '/metrics/', name: 'Metrics' },
+ ];
+
+ for (const { path, name } of mainPages) {
+ test(`${name} page - no sidebar overlap at 1200px`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
+
+ await setupDesktopPage(page, path, 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
+ }
+});
+
+// ============================================
+// METRICS SUB-PAGES
+// ============================================
+
+test.describe('Metrics Sub-Pages - Sidebar No Overlap', () => {
+ const metricsPages = [
+ { path: '/metrics/', name: 'Metrics Dashboard' },
+ { path: '/metrics/costs', name: 'Metrics Costs' },
+ { path: '/metrics/star-reviews', name: 'Metrics Star Reviews' },
+ { path: '/metrics/context-overflow', name: 'Metrics Context Overflow' },
+ { path: '/metrics/links', name: 'Metrics Links' },
+ ];
+
+ for (const { path, name } of metricsPages) {
+ test(`${name} - no sidebar overlap`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
+
+ await setupDesktopPage(page, path, 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
+ }
+});
+
+// ============================================
+// NEWS SUB-PAGES
+// ============================================
+
+test.describe('News Sub-Pages - Sidebar No Overlap', () => {
+ const newsPages = [
+ { path: '/news/', name: 'News Main' },
+ { path: '/news/subscriptions', name: 'News Subscriptions List' },
+ { path: '/news/subscriptions/new', name: 'News New Subscription' },
+ ];
+
+ for (const { path, name } of newsPages) {
+ test(`${name} - no sidebar overlap`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ await setupDesktopPage(page, path, 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
+ }
+});
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+// ============================================
+// LIBRARY SUB-PAGES
+// ============================================
+
+test.describe('Library Sub-Pages - Sidebar No Overlap', () => {
+ const libraryPages = [
+ { path: '/library/', name: 'Library Main' },
+ { path: '/library/collections', name: 'Library Collections' },
+ { path: '/library/collections/create', name: 'Library Create Collection' },
+ { path: '/library/download-manager', name: 'Library Download Manager' },
+ { path: '/library/embedding-settings', name: 'Library Embedding Settings' },
+ ];
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ for (const { path, name } of libraryPages) {
+ test(`${name} - no sidebar overlap`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
+ await setupDesktopPage(page, path, 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
+ }
+});
+
+// ============================================
+// AUTH PAGES
+// Note: When authenticated (via auth file), login/register pages
+// may redirect or show different content
+// ============================================
+
+test.describe('Auth Pages - Desktop Layout', () => {
+ test('Login page - proper desktop layout', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
+
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/auth/login');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ // When authenticated, may redirect to main page or show sidebar
+ // Just verify page loads and check sidebar if present
+ if (await hasSidebar(page)) {
+ await verifySidebarNoOverlap(page, 240);
+ } else {
+ // If not authenticated (no sidebar), verify form is visible
+ const form = page.locator('form');
+ if (await form.count() > 0) {
+ await expect(form.first()).toBeVisible();
+ }
}
});
- test('Sidebar does not overlap main content at 1920px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+ test('Register page - proper desktop layout', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await page.setViewportSize({ width: 1920, height: 1080 });
- await page.goto('/settings/');
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/auth/register');
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(500);
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ // When authenticated, may redirect or show different content
+ if (await hasSidebar(page)) {
+ await verifySidebarNoOverlap(page, 240);
+ } else {
+ const form = page.locator('form');
+ if (await form.count() > 0) {
+ await expect(form.first()).toBeVisible();
+ }
+ }
+ });
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+ test('Change Password page - no sidebar overlap', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ await setupDesktopPage(page, '/auth/change-password', 1200, 800);
- if (sidebarBox && mainContentBox) {
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
+ // Change password page should have sidebar (user is authenticated)
+ if (await hasSidebar(page)) {
+ await verifySidebarNoOverlap(page, 240);
+ } else {
+ // If no sidebar, just verify page loads
+ const body = page.locator('body');
+ await expect(body).toBeVisible();
}
});
+});
- test('Collapsed sidebar (60px) at 900px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+// ============================================
+// BENCHMARK PAGE
+// ============================================
- await page.setViewportSize({ width: 900, height: 700 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+test.describe('Benchmark Page - Sidebar No Overlap', () => {
+ test('Benchmark page - no sidebar overlap', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ await setupDesktopPage(page, '/benchmark/', 1200, 800);
+ await verifySidebarNoOverlap(page, 240);
+ });
+});
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - MAIN PAGES
+// ============================================
+
+test.describe('Desktop Screenshots - Main Pages', () => {
+ const mainPagesForScreenshots = [
+ { path: '/', name: 'research' },
+ { path: '/history/', name: 'history' },
+ { path: '/settings/', name: 'settings' },
+ { path: '/news/', name: 'news' },
+ { path: '/library/', name: 'library' },
+ { path: '/metrics/', name: 'metrics' },
+ ];
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ for (const { path, name } of mainPagesForScreenshots) {
+ test(`${name} page at 1200px`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- // At 900px, sidebar should be collapsed to 60px
- expect(sidebarBox.width).toBeLessThanOrEqual(65); // Allow small tolerance
+ await setupDesktopPage(page, path, 1200, 800);
+ await expect(page).toHaveScreenshot(`desktop-${name}-1200px.png`, {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+});
- // Main content should start after sidebar
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
- }
- });
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - METRICS SUB-PAGES
+// ============================================
- test('Full sidebar (240px) at 1000px width', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+test.describe('Desktop Screenshots - Metrics Sub-Pages', () => {
+ const metricsPagesForScreenshots = [
+ { path: '/metrics/costs', name: 'metrics-costs' },
+ { path: '/metrics/star-reviews', name: 'metrics-star-reviews' },
+ { path: '/metrics/context-overflow', name: 'metrics-context-overflow' },
+ { path: '/metrics/links', name: 'metrics-links' },
+ ];
- await page.setViewportSize({ width: 1000, height: 700 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+ for (const { path, name } of metricsPagesForScreenshots) {
+ test(`${name} at 1200px`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
+
+ await setupDesktopPage(page, path, 1200, 800);
+ await expect(page).toHaveScreenshot(`desktop-${name}-1200px.png`, {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+});
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - NEWS SUB-PAGES
+// ============================================
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+test.describe('Desktop Screenshots - News Sub-Pages', () => {
+ const newsPagesForScreenshots = [
+ { path: '/news/subscriptions', name: 'news-subscriptions' },
+ { path: '/news/subscriptions/new', name: 'news-new-subscription' },
+ ];
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ for (const { path, name } of newsPagesForScreenshots) {
+ test(`${name} at 1200px`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- // At 1000px (above 991px breakpoint), sidebar should be full 240px
- expect(sidebarBox.width).toBeGreaterThanOrEqual(235); // Allow small tolerance
- expect(sidebarBox.width).toBeLessThanOrEqual(245);
+ await setupDesktopPage(page, path, 1200, 800);
+ await expect(page).toHaveScreenshot(`desktop-${name}-1200px.png`, {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+});
- // Main content should start after sidebar
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
- }
- });
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - LIBRARY SUB-PAGES
+// ============================================
+
+test.describe('Desktop Screenshots - Library Sub-Pages', () => {
+ const libraryPagesForScreenshots = [
+ { path: '/library/collections', name: 'library-collections' },
+ { path: '/library/collections/create', name: 'library-create-collection' },
+ { path: '/library/download-manager', name: 'library-download-manager' },
+ { path: '/library/embedding-settings', name: 'library-embedding-settings' },
+ ];
+
+ for (const { path, name } of libraryPagesForScreenshots) {
+ test(`${name} at 1200px`, async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
+
+ await setupDesktopPage(page, path, 1200, 800);
+ await expect(page).toHaveScreenshot(`desktop-${name}-1200px.png`, {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
});
-// Visual regression tests for desktop layouts
-test.describe('Desktop Layout Screenshots', () => {
- test('Settings page at 1200px - sidebar visible', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - AUTH PAGES
+// ============================================
+
+test.describe('Desktop Screenshots - Auth Pages', () => {
+ test('Login page at 1200px', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
await page.setViewportSize({ width: 1200, height: 800 });
- await page.goto('/settings/');
+ await page.goto('/auth/login');
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(500);
- await expect(page).toHaveScreenshot('desktop-settings-1200px.png', {
+ await expect(page).toHaveScreenshot('desktop-auth-login-1200px.png', {
maxDiffPixelRatio: 0.02,
});
});
- test('Settings page at 1600px - large desktop', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+ test('Register page at 1200px', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await page.setViewportSize({ width: 1600, height: 900 });
- await page.goto('/settings/');
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/auth/register');
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(500);
- await expect(page).toHaveScreenshot('desktop-settings-1600px.png', {
+ await expect(page).toHaveScreenshot('desktop-auth-register-1200px.png', {
maxDiffPixelRatio: 0.02,
});
});
- test('Settings page at 900px - collapsed sidebar', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
-
- await page.setViewportSize({ width: 900, height: 700 });
- await page.goto('/settings/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+ test('Change Password page at 1200px', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await expect(page).toHaveScreenshot('desktop-settings-900px-collapsed.png', {
+ await setupDesktopPage(page, '/auth/change-password', 1200, 800);
+ await expect(page).toHaveScreenshot('desktop-auth-change-password-1200px.png', {
maxDiffPixelRatio: 0.02,
});
});
+});
- test('Research page at 1200px', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+// ============================================
+// VISUAL REGRESSION SCREENSHOTS - BENCHMARK
+// ============================================
- await page.setViewportSize({ width: 1200, height: 800 });
- await page.goto('/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+test.describe('Desktop Screenshots - Benchmark', () => {
+ test('Benchmark page at 1200px', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await expect(page).toHaveScreenshot('desktop-research-1200px.png', {
+ await setupDesktopPage(page, '/benchmark/', 1200, 800);
+ await expect(page).toHaveScreenshot('desktop-benchmark-1200px.png', {
maxDiffPixelRatio: 0.02,
});
});
+});
- test('Metrics page at 1200px', async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+// ============================================
+// RESPONSIVE BREAKPOINT SCREENSHOTS
+// ============================================
- await page.setViewportSize({ width: 1200, height: 800 });
- await page.goto('/metrics/');
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+test.describe('Desktop Screenshots - Responsive Breakpoints', () => {
+ test('Settings page at 900px - collapsed sidebar', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- await expect(page).toHaveScreenshot('desktop-metrics-1200px.png', {
+ await setupDesktopPage(page, '/settings/', 900, 700);
+ await expect(page).toHaveScreenshot('desktop-settings-900px-collapsed.png', {
maxDiffPixelRatio: 0.02,
});
});
-});
-// Test all main pages don't have sidebar overlap
-test.describe('All Pages - Sidebar No Overlap', () => {
- const pages = [
- { path: '/', name: 'Research' },
- { path: '/history/', name: 'History' },
- { path: '/settings/', name: 'Settings' },
- { path: '/news/', name: 'News' },
- { path: '/library/', name: 'Library' },
- { path: '/metrics/', name: 'Metrics' },
- ];
+ test('Settings page at 1600px - large desktop', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- for (const { path, name } of pages) {
- test(`${name} page - no sidebar overlap at 1200px`, async ({ page, isMobile }) => {
- if (isMobile) {
- test.skip();
- return;
- }
+ await setupDesktopPage(page, '/settings/', 1600, 900);
+ await expect(page).toHaveScreenshot('desktop-settings-1600px.png', {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
- await page.setViewportSize({ width: 1200, height: 800 });
- await page.goto(path);
- await page.waitForLoadState('domcontentloaded');
- await page.waitForTimeout(500);
+ test('Research page at 900px - collapsed sidebar', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebar = page.locator('.ldr-sidebar');
- const mainContent = page.locator('.ldr-main-content');
+ await setupDesktopPage(page, '/', 900, 700);
+ await expect(page).toHaveScreenshot('desktop-research-900px-collapsed.png', {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+
+ test('Research page at 1600px - large desktop', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- const sidebarBox = await sidebar.boundingBox();
- const mainContentBox = await mainContent.boundingBox();
+ await setupDesktopPage(page, '/', 1600, 900);
+ await expect(page).toHaveScreenshot('desktop-research-1600px.png', {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
- // Sidebar should be visible on desktop
- expect(sidebarBox).not.toBeNull();
- expect(mainContentBox).not.toBeNull();
+ test('Metrics page at 1600px - large desktop', async ({ page, isMobile }) => {
+ if (isMobile) { test.skip(); return; }
- if (sidebarBox && mainContentBox) {
- const sidebarRightEdge = sidebarBox.x + sidebarBox.width;
- expect(mainContentBox.x).toBeGreaterThanOrEqual(sidebarRightEdge - 1);
- }
+ await setupDesktopPage(page, '/metrics/', 1600, 900);
+ await expect(page).toHaveScreenshot('desktop-metrics-1600px.png', {
+ maxDiffPixelRatio: 0.02,
});
- }
+ });
});