diff --git a/config/scripts/mobile-web-app-session-webview-consumers.test.mjs b/config/scripts/mobile-web-app-session-webview-consumers.test.mjs index 2828672be1e..47e132a0737 100644 --- a/config/scripts/mobile-web-app-session-webview-consumers.test.mjs +++ b/config/scripts/mobile-web-app-session-webview-consumers.test.mjs @@ -5,9 +5,14 @@ * where its consumer was, so a page does not go down over one — but nothing it was mounted for * works either, and the closure pays for a module that cannot do its job. * - * C7.6 gives the two editors the plain states they already degrade to (`rulings-ota-c7.md` ruling - * 8). The terminal is the third and is C7.5's, which drops the engine string and mounts xterm in - * the document; it is listed here rather than left unsaid so the list is the work remaining. + * C7.6 gave the two editors the plain states they already degrade to (`rulings-ota-c7.md` ruling + * 8) and left the terminal listed as the work remaining, which was C7.5's. C7.5 has done it: the + * page mounts xterm in the document and drops the engine string, so the list is now empty and + * this closure reaches that package from nowhere at all. + * + * An empty list is also what a scan that read nothing reports, so the control below no longer + * uses the list — it runs the same walk over three native modules that do import the package and + * over the three web siblings that replace them. */ import { readFileSync } from 'node:fs' import { join } from 'node:path' @@ -21,13 +26,21 @@ const describeClosure = mobileWebAppDependenciesPresent() ? describe : describe. const SESSION = 'app/h/[hostId]/session/[worktreeId].tsx' -/** Still on the native component, and whose PR it is. */ -const REMAINING = ['src/terminal/TerminalWebView.tsx'] +/** Nothing: every consumer this closure had now resolves to a web sibling that needs no WebView. */ +const REMAINING = [] -/** The two this PR answered, whose `.web.tsx` the builder resolves instead. */ +/** The three answered, whose `.web.tsx` the builder resolves instead of the native file. */ const ANSWERED = [ 'src/components/MobileRichMarkdownEditor.web.tsx', - 'src/components/MobileHtmlPreview.web.tsx' + 'src/components/MobileHtmlPreview.web.tsx', + 'src/terminal/TerminalWebView.web.tsx' +] + +/** The native files behind those three, which do import the package. The scan's own control. */ +const NATIVE_CONSUMERS = [ + 'src/components/MobileRichMarkdownEditor.tsx', + 'src/components/MobileHtmlPreview.tsx', + 'src/terminal/TerminalWebView.tsx' ] const IMPORTS_WEBVIEW = /(?:from|import)\s*'[^']*react-native-webview'/ @@ -45,9 +58,15 @@ function webViewConsumers(closure) { describeClosure( 'the session closure and react-native-webview', () => { - it('reaches it from the terminal and from nothing else', async () => { + it('reaches it from nothing at all', async () => { const closure = await mobileWebAppRouteClosure(SESSION) expect(webViewConsumers(closure)).toEqual(REMAINING) + // The precondition an empty list needs: the walk read a closure, and read the very modules + // whose native halves are the ones that would have imported the package. + expect(closure.local.length).toBeGreaterThan(500) + for (const file of ANSWERED) { + expect(closure.local, file).toContain(file) + } }) it('resolves both editors to their web siblings, not to the native files', async () => { @@ -58,9 +77,10 @@ describeClosure( } }) - it('finds a consumer when there is one, so the list above is a measurement', async () => { - // The control: the same walk over the module the list names, which does import it. - expect(webViewConsumers({ local: REMAINING })).toEqual(REMAINING) + it('finds a consumer when there is one, so the empty list above is a measurement', () => { + // The control, run over the native files rather than over the list: with the list empty, + // walking it would compare nothing against nothing and pass on a scan that reads no file. + expect(webViewConsumers({ local: NATIVE_CONSUMERS })).toEqual(NATIVE_CONSUMERS) expect(webViewConsumers({ local: ANSWERED })).toEqual([]) }) },