From feddf4e6a1c90d4b8020df8426781fbf6ee2f2b8 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 22 Jul 2026 13:57:08 -0700 Subject: [PATCH] test(mobile): structurally guard quick-command action mount --- ...uick-commands-tab-stability-source.test.ts | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/mobile/src/session/quick-commands-tab-stability-source.test.ts b/mobile/src/session/quick-commands-tab-stability-source.test.ts index 61ab0b3d7ea..5172db1e6b6 100644 --- a/mobile/src/session/quick-commands-tab-stability-source.test.ts +++ b/mobile/src/session/quick-commands-tab-stability-source.test.ts @@ -1,11 +1,34 @@ import { readFileSync } from 'node:fs' +import ts from 'typescript' import { describe, expect, it } from 'vitest' -const source = readFileSync( - new URL('../../app/h/[hostId]/session/[worktreeId].tsx', import.meta.url), - 'utf8' +const fileUrl = new URL('../../app/h/[hostId]/session/[worktreeId].tsx', import.meta.url) +const source = readFileSync(fileUrl, 'utf8') +const sourceFile = ts.createSourceFile( + fileUrl.href, + source, + ts.ScriptTarget.Latest, + true, + ts.ScriptKind.TSX ) +function findQuickCommandsTabButtons(): ts.JsxSelfClosingElement[] { + const matches: ts.JsxSelfClosingElement[] = [] + + function visit(node: ts.Node): void { + if ( + ts.isJsxSelfClosingElement(node) && + node.tagName.getText(sourceFile) === 'QuickCommandsTabButton' + ) { + matches.push(node) + } + ts.forEachChild(node, visit) + } + + visit(sourceFile) + return matches +} + function getQuickCommandsTabSource(): string { const start = source.indexOf('accessibilityLabel="New tab"') expect(start).toBeGreaterThanOrEqual(0) @@ -17,9 +40,20 @@ function getQuickCommandsTabSource(): string { describe('quick-commands tab stability', () => { it('keeps the button mounted while preserving the capability gate', () => { const tabSource = getQuickCommandsTabSource() + const buttons = findQuickCommandsTabButtons() - expect(tabSource).toContain(' + ts.isJsxAttribute(attribute) && attribute.name.getText(sourceFile) === 'style' + ) + expect(style?.initializer?.getText(sourceFile)).toBe('{styles.tabBar}') expect(tabSource).toContain('if (quickCommandsSupported === true)') expect(tabSource).toContain('setShowQuickCommands(true)') expect(tabSource).toContain('Desktop update required for quick commands')