|
| 1 | +// Control UI sidebar footer tests cover cross-route layout parity. |
| 2 | +import { chromium, type Browser, type Page } from "playwright"; |
| 3 | +import { afterAll, beforeAll, describe, expect, it } from "vitest"; |
| 4 | +import { readStyleSheet } from "../../../test/helpers/ui-style-fixtures.js"; |
| 5 | +import { |
| 6 | + canRunPlaywrightChromium, |
| 7 | + resolvePlaywrightChromiumExecutablePath, |
| 8 | +} from "../test-helpers/control-ui-e2e.ts"; |
| 9 | + |
| 10 | +const chromiumExecutablePath = resolvePlaywrightChromiumExecutablePath(chromium.executablePath()); |
| 11 | +const chromiumAvailable = canRunPlaywrightChromium(chromiumExecutablePath); |
| 12 | +const describeBrowserLayout = chromiumAvailable ? describe : describe.skip; |
| 13 | + |
| 14 | +let browser: Browser; |
| 15 | +let page: Page; |
| 16 | + |
| 17 | +function readUiCss(): string { |
| 18 | + return ["base.css", "components.css", "layout.css"] |
| 19 | + .map((file) => readStyleSheet(`ui/src/styles/${file}`)) |
| 20 | + .join("\n"); |
| 21 | +} |
| 22 | + |
| 23 | +beforeAll(async () => { |
| 24 | + if (!chromiumAvailable) { |
| 25 | + return; |
| 26 | + } |
| 27 | + browser = await chromium.launch({ executablePath: chromiumExecutablePath, headless: true }); |
| 28 | + page = await browser.newPage({ viewport: { width: 800, height: 400 } }); |
| 29 | +}); |
| 30 | + |
| 31 | +afterAll(async () => { |
| 32 | + await page?.close().catch(() => {}); |
| 33 | + await browser?.close().catch(() => {}); |
| 34 | +}); |
| 35 | + |
| 36 | +describeBrowserLayout("sidebar footer layout", () => { |
| 37 | + it("keeps the settings footer the same height as the main sidebar footer", async () => { |
| 38 | + await page.setContent(` |
| 39 | + <!doctype html> |
| 40 | + <html data-theme-mode="light"> |
| 41 | + <head> |
| 42 | + <style>${readUiCss()}</style> |
| 43 | + <style> |
| 44 | + .footer-layout-fixture { |
| 45 | + display: grid; |
| 46 | + grid-template-columns: 288px 288px; |
| 47 | + width: 576px; |
| 48 | + height: 180px; |
| 49 | + } |
| 50 | + .footer-layout-fixture > * { |
| 51 | + min-height: 0; |
| 52 | + } |
| 53 | + </style> |
| 54 | + </head> |
| 55 | + <body> |
| 56 | + <main class="shell footer-layout-fixture"> |
| 57 | + <section class="sidebar-shell"> |
| 58 | + <div class="sidebar-shell__content"></div> |
| 59 | + <div class="sidebar-shell__footer"> |
| 60 | + <div class="sidebar-footer-bar"> |
| 61 | + <div class="sidebar-agent-card"> |
| 62 | + <button class="sidebar-agent-card__main" type="button"> |
| 63 | + <span class="sidebar-agent-card__avatar"></span> |
| 64 | + <span class="sidebar-agent-card__name">Mason</span> |
| 65 | + </button> |
| 66 | + </div> |
| 67 | + <div class="sidebar-footer-actions"> |
| 68 | + <button class="sidebar-brand__icon sidebar-footer-bar__custodian" type="button"> |
| 69 | + Inbox |
| 70 | + </button> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </section> |
| 75 | + <aside class="settings-sidebar"> |
| 76 | + <div class="sidebar-shell__content"></div> |
| 77 | + <footer class="settings-sidebar__footer"> |
| 78 | + <openclaw-settings-save-indicator></openclaw-settings-save-indicator> |
| 79 | + <span class="sidebar-footer-build">2026.8.1 · git@5328856</span> |
| 80 | + </footer> |
| 81 | + </aside> |
| 82 | + </main> |
| 83 | + </body> |
| 84 | + </html> |
| 85 | + `); |
| 86 | + |
| 87 | + const heights = await page.evaluate(() => ({ |
| 88 | + main: document.querySelector(".sidebar-shell__footer")?.getBoundingClientRect().height, |
| 89 | + settings: document.querySelector(".settings-sidebar__footer")?.getBoundingClientRect().height, |
| 90 | + })); |
| 91 | + |
| 92 | + expect(heights.main).toBeDefined(); |
| 93 | + expect(heights.settings).toBeDefined(); |
| 94 | + expect(heights.settings).toBeCloseTo(heights.main ?? 0, 2); |
| 95 | + }); |
| 96 | +}); |
0 commit comments