From 4759c55fb8c10946264b59e958b045deb75f3fa5 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sun, 8 Nov 2026 00:31:10 -0800 Subject: [PATCH] Fix spurious unit test failures --- tests/assistant-settings-visibility.test.cjs | 1 - tests/ios-privacy-page.test.cjs | 57 -------------------- tests/onboarding-devices.test.cjs | 6 +-- tests/onboarding-layout.test.cjs | 2 +- 4 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 tests/ios-privacy-page.test.cjs diff --git a/tests/assistant-settings-visibility.test.cjs b/tests/assistant-settings-visibility.test.cjs index 900f2f9f..e7a8846c 100644 --- a/tests/assistant-settings-visibility.test.cjs +++ b/tests/assistant-settings-visibility.test.cjs @@ -60,7 +60,6 @@ function settingsEnv(initialUrl = '', initialModel = 'openai-compatible') { deleteAsrModel() {}, startAsrModelDownload() {}, onAsrModelStateChanged: () => () => {}, }, '../../apps/files/text-viewer': { TextViewerLayer: class {} }, - '../../analytics/privacy-disclosure': { IOS_PRIVACY_NOTICE: '' }, '../menu': { drawRightValueMenuItem() {}, openModalMenu() {}, submenuItem: label => ({ label, onSelect() {} }), diff --git a/tests/ios-privacy-page.test.cjs b/tests/ios-privacy-page.test.cjs deleted file mode 100644 index 98394fcf..00000000 --- a/tests/ios-privacy-page.test.cjs +++ /dev/null @@ -1,57 +0,0 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const { loader } = require('./helpers/load-typescript.cjs'); - -function harness(width, height) { - const font = { lineHeight: 20, measureText: text => text.length * 10, getGlyph: () => ({ dwidthX: 10 }) }; - const load = loader({}, { './onboarding-fonts': { onboardingFont: () => font } }); - const { IosPrivacyPage } = load('app/apps/onboarding/ios-privacy-page.ts'); - const { IOS_PRIVACY_NOTICE } = load('app/analytics/privacy-disclosure.ts'); - const page = new IosPrivacyPage(); - let next = 0; - return { - page, notice: IOS_PRIVACY_NOTICE, get next() { return next; }, - input(type) { page.handleInput({ type }, { next: () => next++ }); }, - paint() { - const rows = []; - page.paint({ width, height, drawText(font, x, y, text) { - assert.ok(x + font.measureText(text) <= width, `horizontal overflow: ${text}`); - assert.ok(y >= 0 && y + font.lineHeight <= height, `vertical overflow: ${text}`); - rows.push({ y, text }); - } }); - return rows; - }, - }; -} - -for (const [width, height] of [[576, 188], [576, 260], [640, 432]]) { - test(`entire iOS notice is readable before continuing at ${width}x${height}`, () => { - const h = harness(width, height); - const shown = []; - for (let i = 0; !h.next && i < 30; i++) { - const rows = h.paint(); - const footer = rows.at(-1); - for (const row of rows.slice(1, -1)) { - assert.ok(row.y + 20 <= footer.y, 'body must not overlap navigation'); - shown.push(row.text); - } - h.input('click'); - } - assert.equal(h.next, 1); - // Line breaking may also split after punctuation (e.g. device/app). - assert.equal(shown.join('').replace(/\s+/g, ''), h.notice.replace(/\s+/g, '')); - }); -} - -test('scrolling stays inside the notice; revisiting starts at the beginning', () => { - const h = harness(576, 188); - const first = h.paint().map(row => row.text); - h.input('scroll-up'); - assert.deepEqual(h.paint().map(row => row.text), first); - h.input('scroll-down'); - assert.notDeepEqual(h.paint().map(row => row.text), first); - for (let i = 0; i < 30; i++) h.input('scroll-down'); - assert.equal(h.next, 0, 'scrolling must not accept the notice'); - h.page.enter(); - assert.deepEqual(h.paint().map(row => row.text), first); -}); diff --git a/tests/onboarding-devices.test.cjs b/tests/onboarding-devices.test.cjs index cb973b44..dff51d16 100644 --- a/tests/onboarding-devices.test.cjs +++ b/tests/onboarding-devices.test.cjs @@ -33,7 +33,7 @@ function fixture({ glasses = 'g2', ios = false, completed = false, ring = false, const modules = { '@nativescript/core': core, './onboarding-state': onboardingState, '../ui/dashboard-settings': settings, './onboarding-navigation': { finishOnboardingNavigation: () => state.navigations.push('finish') }, - '../analytics/privacy-disclosure': { IOS_PRIVACY_NOTICE: 'privacy' }, + '../g1/even-firmware': { EVEN_G1_RESTORE: { version: '1.6.6' } }, '../native/even-app-conflict': { openEvenAppSettings() {} }, '../native/ble-permissions': { ensureBlePermissions: async () => {} }, '../g2/device-addresses': { @@ -143,8 +143,8 @@ test('the disclaimer and firmware steps name only the chosen glasses', () => { assert.doesNotMatch(io.disclaimer.body, /Even/); assert.match(g2.firmware.body, /reconnecting the official Even Realities app/); - assert.doesNotMatch(g2.firmware.body, /computer|G1/); - assert.match(g1.firmware.body, /takes a computer/); + assert.doesNotMatch(g2.firmware.body, /from Faceclaw|1\.6\.6|G1/); + assert.match(g1.firmware.body, /return to the official firmware later from Faceclaw, as version 1\.6\.6\./); assert.doesNotMatch(g1.firmware.body, /reconnecting|G2/); assert.equal(g2.firmware.primaryLabel, 'Flash Firmware'); assert.equal(g1.firmware.primaryLabel, 'Flash Firmware'); diff --git a/tests/onboarding-layout.test.cjs b/tests/onboarding-layout.test.cjs index 55e0e070..fc2122f8 100644 --- a/tests/onboarding-layout.test.cjs +++ b/tests/onboarding-layout.test.cjs @@ -231,7 +231,7 @@ test('the flow switches immersive mode per page and skips pages that do not appl const load = loader({}, { '../../graphics/image': { GrayImage: class {} }, '../../ui/shell/in-process-window': {}, '../../ui/shell/shell': { shell }, '../../ui/sound-effects': {}, - './data-collection-page': {}, './depth-page': {}, './display-mode-page': {}, './ios-privacy-page': {}, './layout-page': {}, + './data-collection-page': {}, './depth-page': {}, './display-mode-page': {}, './layout-page': {}, './onboarding-progress': {}, './text-size-page': {}, './welcome-page': {}, }); const { OnboardingLayer } = load('app/apps/onboarding/onboarding-app.ts');