|
1 | 1 | /** |
2 | 2 | * @vitest-environment node |
3 | 3 | */ |
4 | | -import { readFileSync } from 'node:fs' |
| 4 | +import { readdirSync, readFileSync } from 'node:fs' |
5 | 5 | import { describe, expect, it } from 'vitest' |
6 | 6 |
|
7 | 7 | /** Anchored to this file, not `process.cwd()`, which only resolves from `apps/sim`. */ |
@@ -149,3 +149,45 @@ describe('desktop title-bar surface audit', () => { |
149 | 149 | expect(resourceHeader).not.toMatch(/py-\[8\.5px\]/) |
150 | 150 | }) |
151 | 151 | }) |
| 152 | + |
| 153 | +/** |
| 154 | + * Every full-viewport page root outside workspace chrome, and why it is safe. |
| 155 | + * |
| 156 | + * A root that fills the viewport and is NOT lane-aware draws its top chrome underneath |
| 157 | + * the macOS traffic lights, because the pre-paint script marks the lane on every desktop |
| 158 | + * route whether or not the page reserves it. That is one bug that has now surfaced four |
| 159 | + * separate times — workspace headers, signup, the CLI handoff, the OAuth error page — |
| 160 | + * each found by a person hitting it rather than by a check. |
| 161 | + * |
| 162 | + * So the check enumerates instead of listing what to look at: any new full-viewport root |
| 163 | + * fails here until it either composes `.desktop-title-bar-page` or is added below with a |
| 164 | + * reason. Reaching for this allowlist should feel like a claim you have to defend. |
| 165 | + */ |
| 166 | +const LANE_EXEMPT: Record<string, string> = { |
| 167 | + 'app/(landing)/components/landing-shell/landing-shell.tsx': |
| 168 | + 'Marketing chrome. The desktop shell boots straight to /login or a workspace and has no path to the landing routes.', |
| 169 | + 'app/(landing)/components/logo-shell/logo-shell.tsx': |
| 170 | + 'Marketing chrome, same reasoning as landing-shell.', |
| 171 | + 'app/playground/page.tsx': 'Dev-only scratch route, not shipped in the desktop shell.', |
| 172 | + 'app/(interfaces)/resume/[workflowId]/[executionId]/loading.tsx': |
| 173 | + 'Embedded interface surface rendered inside a host page, never as the desktop window root.', |
| 174 | +} |
| 175 | + |
| 176 | +describe('desktop traffic-light lane coverage', () => { |
| 177 | + it('leaves no full-viewport root outside workspace chrome unaccounted for', () => { |
| 178 | + const appDir = new URL('../', import.meta.url) |
| 179 | + const files = readdirSync(appDir, { recursive: true, encoding: 'utf8' }) |
| 180 | + .filter((f) => f.endsWith('.tsx') && !f.startsWith('workspace/')) |
| 181 | + .map((f) => `app/${f}`) |
| 182 | + |
| 183 | + const unaccounted = files.filter((file) => { |
| 184 | + const source = stripComments(read(`../${file.slice('app/'.length)}`)) |
| 185 | + const fillsViewport = /\b(min-h-screen|h-screen)\b/.test(source) |
| 186 | + if (!fillsViewport) return false |
| 187 | + const laneAware = source.includes('desktop-title-bar-page') || source.includes('AuthShell') |
| 188 | + return !laneAware && !(file in LANE_EXEMPT) |
| 189 | + }) |
| 190 | + |
| 191 | + expect(unaccounted).toEqual([]) |
| 192 | + }) |
| 193 | +}) |
0 commit comments