diff --git a/openpilot/starpilot/galaxy/tests/browser/settings-state.cjs b/openpilot/starpilot/galaxy/tests/browser/settings-state.cjs index 203c09e9e1..494effe1cb 100644 --- a/openpilot/starpilot/galaxy/tests/browser/settings-state.cjs +++ b/openpilot/starpilot/galaxy/tests/browser/settings-state.cjs @@ -152,12 +152,12 @@ const { execFileSync } = require('node:child_process') ['onroad-layout', 'OnroadLayoutPage', prepareLayout], ['onroad-layout', 'OnroadLayoutPage', prepareLayout, { projection: true }], ['models', 'ModelsPage', prepareModels], - ['model-laboratory', 'LaboratoryPage', vm => Object.assign(vm, { loading: false, - configuration: { enabled: false, lateralModel: 'one', longitudinalModel: 'two' }, status: { + ['models', 'ModelsPage', vm => { prepareModels(vm); Object.assign(vm, { pairView: 'pair', + labConfig: { enabled: false, lateralModel: 'one', longitudinalModel: 'two' }, lab: { configuration: { enabled: false, lateralModel: 'one', longitudinalModel: 'two' }, - isOnroad: false, runtimeSupported: true, chestnutReady: true, runtime: {}, download: { downloading: false }, + isOnroad: false, runtimeSupported: true, chestnutReady: true, runtime: {}, download: { downloading: false }, summary: { published: 2 }, models: ['one', 'two'].map(value => ({ value, label: value, small: true, modelLabEligible: true, modelLabArtifactAvailable: true, modelLabArtifactInstalled: true })), - capabilities: { configure: true, download: true, delete: true, cancel: true, refresh: true } } })], + capabilities: { configure: true, download: true, delete: true, cancel: true, refresh: true } } }) }], ['sentry-notifications', 'SentryNotifications', vm => { vm.notifications = { subscriptionCount: 0, subscriptions: [], channels: Object.fromEntries(vm.channels.map(name => [name, { enabled: true, configured: true, pending: 0, lastState: 'idle', lastError: '' }])) } }], ['drive-state', 'DriveStatePanel', vm => { vm.state = { mode: 'auto', available: true, effective: 'offroad', overrideAllowed: true } }], @@ -213,13 +213,12 @@ const { execFileSync } = require('node:child_process') return cases.map(([, name]) => name) }, layout) for (const success of [false, true]) { - await page.getByRole('combobox', { name: /^Active Small/ }).click() - await page.getByRole('option', { name: 'two', exact: true }).click() + await page.getByRole('button', { name: 'Set Active Small' }).click() await page.waitForFunction(() => !!vm.busy) - assert.equal(await page.getByRole('combobox', { name: /^Active Small/, includeHidden: true }).textContent(), 'two') + assert.equal(await page.locator('.gx-model-summary-item__value').first().textContent(), 'two') await page.evaluate(success => finishModel(success), success) await page.waitForFunction(() => !vm.busy) - assert.equal(await page.getByRole('combobox', { name: /^Active Small/ }).textContent(), success ? 'two' : 'one') + assert.equal(await page.locator('.gx-model-summary-item__value').first().textContent(), success ? 'two' : 'one') } assert.deepEqual(errors, []) console.log(`Settings state: ${pages.length} settings pages and ${audited.length} specialized pages; delayed preview/save/readback, Default/download buttons, stable control nodes/opacity and failed-save recovery passed.`) diff --git a/openpilot/starpilot/galaxy/tests/browser/tab-motion.cjs b/openpilot/starpilot/galaxy/tests/browser/tab-motion.cjs index 78a4e3d87c..02de6a4581 100644 --- a/openpilot/starpilot/galaxy/tests/browser/tab-motion.cjs +++ b/openpilot/starpilot/galaxy/tests/browser/tab-motion.cjs @@ -48,22 +48,27 @@ const assert = require('node:assert/strict') assert.equal(await page.locator('.gx-route:not([inert])').count(), 1) assert.equal(await nav.getByRole('button', { name: 'Home', exact: true }).getAttribute('aria-current'), 'page') + // The old Model Laboratory link opens the merged Models page at its Laboratory pair section. await page.goto(base + '#/model_laboratory') - const heading = page.getByText('Available models', { exact: true }) - await heading.waitFor() + const laboratory = page.locator('#gx-model-laboratory') + await laboratory.waitFor() + await page.waitForFunction(() => { + const box = document.querySelector('#gx-model-laboratory').getBoundingClientRect() + return box.top >= 0 && box.top < innerHeight + }) + assert.equal(await page.locator('.gx-route:not([inert]) h2').first().textContent(), 'Models') for (const width of [320, 360, 390, 600, 1280]) { await page.setViewportSize({ width, height: 900 }) const layout = await page.evaluate(() => { - const title = [...document.querySelectorAll('.gx-section__title')].find(element => element.textContent === 'Available models') - const summary = title.closest('.gx-card').querySelector('.gx-summary') - const cells = [...summary.children].map(element => element.getBoundingClientRect()) - return { headerHeight: title.parentElement.getBoundingClientRect().height, - summaryHeight: summary.getBoundingClientRect().height, - equalRows: cells.every(cell => Math.abs(cell.top - cells[0].top) < 1), + const header = document.querySelector('.gx-page-header') + const modeBar = document.querySelector('.gx-model-mode') + const list = document.querySelector('.gx-model-list') + return { headerHeight: header.getBoundingClientRect().height, + modeBarHeight: modeBar.getBoundingClientRect().height, + hasRows: list && list.children.length > 0, overflow: document.documentElement.scrollWidth > innerWidth } }) - assert.ok(layout.headerHeight < 80 && layout.summaryHeight < 100, 'model summary stays compact') - assert.equal(layout.equalRows, true, 'all three counts share one row') + assert.ok(layout.headerHeight < 120 && layout.modeBarHeight < 80 && layout.hasRows, 'model headers and row list stay compact') assert.equal(layout.overflow, false) } await page.setViewportSize({ width: 390, height: 900 }) diff --git a/openpilot/starpilot/galaxy/tests/test_model_laboratory.mjs b/openpilot/starpilot/galaxy/tests/test_model_laboratory.mjs index c95e296231..2f688c9401 100644 --- a/openpilot/starpilot/galaxy/tests/test_model_laboratory.mjs +++ b/openpilot/starpilot/galaxy/tests/test_model_laboratory.mjs @@ -1,5 +1,5 @@ import assert from "node:assert/strict" -import { LaboratoryFeed, LaboratoryPage, laboratoryModels, laboratoryReady, laboratorySelectionError, laboratoryActionAllowed, laboratoryDraft, laboratoryStatusLabel } from "../web/js/model-laboratory.js" +import { LaboratoryFeed, ModelsPage, laboratoryModels, laboratoryReady, laboratorySelectionError, laboratoryActionAllowed, laboratoryDraft, laboratoryStatusLabel } from "../web/js/models.js" const model = (value, version = 'v9') => ({ value, label: `Model ${value}`, version, small: true, modelLabEligible: true, modelLabArtifactAvailable: true, modelLabArtifactInstalled: true }) const payload = () => ({ schemaVersion: 1, isOnroad: false, chestnutReady: true, runtimeSupported: true, @@ -72,24 +72,30 @@ assert.equal(download.requests[1].url,'./api/models/laboratory/download');assert await download.reply(1,{message:'Starting download'});await download.reply(2,{...p,download:{downloading:true,jobId:'job',progress:'40%'}});await downloading const canceling=download.feed.action('cancel');assert.equal(download.requests[3].url,'./api/models/cancel');assert.deepEqual(JSON.parse(download.requests[3].options.body),{jobId:'job'}) await download.reply(3,{message:'Cancelling'});await download.reply(4,p);await canceling;download.feed.stop() -assert.deepEqual([...LaboratoryPage.template.matchAll(/class="gx-section__title">([^<]+)<\/span>/g)].map(match => match[1]), - ['Compose a pair', 'Available models']) -for (const label of ['Lateral model', 'Longitudinal model', 'Enable model pair', 'Check model catalog']) { - const position = LaboratoryPage.template.indexOf(label) - assert.ok(position >= 0 && position < LaboratoryPage.template.indexOf('v-for="m in availableModels"'), - `${label} must appear before the model catalog`) -} -assert.doesNotMatch(LaboratoryPage.template,/runtimeState|modelLabel\(status\?\.runtime/ ) -assert.match(LaboratoryPage.template,/status\?\.runtime.error/) -assert.equal(LaboratoryPage.methods.modelLabel.call({status:p},'a'),'Model a') -assert.equal(LaboratoryPage.methods.modelLabel.call({status:p},'unknown'),'unknown') -assert.equal(LaboratoryPage.methods.modelLabel.call({status:null},''),'Not selected') -assert.match(LaboratoryPage.template,/GalaxySelect/) -assert.match(LaboratoryPage.template,/Catalog models/) -assert.match(LaboratoryPage.template,/modelLabReason/) +// Model Laboratory lives on the Models page: Single model / Model pair mode switcher and eGPU variants on the model rows +const template = ModelsPage.template +const labCard = template.indexOf('id="gx-model-laboratory"') +assert.ok(template.indexOf('Single model') < labCard && labCard < template.indexOf('gx-model-list')) +assert.match(template,/aria-label="Lateral model"/) +assert.match(template,/aria-label="Longitudinal model"/) +assert.ok(template.includes(`@click="setDriveMode('pair')"> Model pair`)) +assert.match(template,/Verified downloads/) +assert.match(template,/eGPU variant/) +assert.match(template,/Pairable/) +assert.doesNotMatch(template,/Available models|Compose a pair|Catalog models/) assert.equal(laboratoryStatusLabel({modelLabStatus:"runtime-unavailable"}), "Downloaded") assert.equal(laboratoryStatusLabel({modelLabStatus:"unsupported"}), "Not supported") +assert.doesNotMatch(template,/20 Hz/) +const save=fixture();save.feed.start();await save.reply(0,p) +const saving=save.feed.action('save',null,{enabled:true,lateralModel:'b',longitudinalModel:'a'}) +assert.equal(save.requests[1].url,'./api/models/laboratory') +assert.deepEqual(JSON.parse(save.requests[1].options.body),{enabled:false,lateralModel:'b',longitudinalModel:'a'}) +await save.reply(1,{...p,message:'saved'});await save.reply(2,p);await saving;save.feed.stop() const performanceNotice = 'Two Big models cannot run together at the required speed. Choose a Small model for one role. Other combinations can also cause model lag warnings.' -assert.ok(LaboratoryPage.template.includes(performanceNotice)) -assert.doesNotMatch(LaboratoryPage.template.replace(performanceNotice,''),/20 Hz/) +assert.ok(template.includes(performanceNotice)) +assert.match(template,/lab\.runtime\.error/) console.log('Model Laboratory contracts passed') +assert.match(template,/steers · \{\{ labModelLabel\(labConfig\.longitudinalModel\) \}\} paces/) +assert.match(template,/The pair takes effect the next time the driving model starts/) +assert.match(template,/labRow\(m\)\?\.small \|\| labRow\(m\)\?\.modelLabEligible/) +assert.match(template,/Pair lateral judgment from one model with longitudinal judgment from another\./) diff --git a/openpilot/starpilot/galaxy/tests/test_models.mjs b/openpilot/starpilot/galaxy/tests/test_models.mjs index 171f63a5da..ffcc3a78d1 100644 --- a/openpilot/starpilot/galaxy/tests/test_models.mjs +++ b/openpilot/starpilot/galaxy/tests/test_models.mjs @@ -80,7 +80,7 @@ const listeners = new Map() globalThis.document = { hidden: false, addEventListener: (name, fn) => listeners.set(name, fn), removeEventListener: (name, fn) => { if (listeners.get(name) === fn) listeners.delete(name) } } -const page = { mode: "local", finishDialog() {}, manager: { start() {}, stop() {} }, feed: { starts: 0, stops: 0, start() { this.starts++ }, stop() { this.stops++ } } } +const page = { mode: "local", finishDialog() {}, manager: { start() {}, stop() {} }, laboratory: { starts: 0, stops: 0, start() { this.starts++ }, stop() { this.stops++ } }, feed: { starts: 0, stops: 0, start() { this.starts++ }, stop() { this.stops++ } } } ModelsPage.mounted.call(page) assert.equal(page.feed.starts, 1) document.hidden = true @@ -91,6 +91,7 @@ listeners.get("visibilitychange")() assert.equal(page.feed.starts, 2) ModelsPage.beforeUnmount.call(page) assert.equal(page.feed.stops, 2) +assert.deepEqual([page.laboratory.starts, page.laboratory.stops], [2, 2]) assert.equal(listeners.size, 0) globalThis.document = priorDocument @@ -244,7 +245,8 @@ console.log('Randomizer and exclusion interactions passed') assert.match(ModelsPage.template, /Selections apply next onroad cycle/) assert.doesNotMatch(ModelsPage.template, /Onroad: switching/) -assert.equal((ModelsPage.template.match(/class="gx-model-control"/g) || []).length, 2) +// Active Small, Active Big summary items, and the Laboratory pair's lateral and longitudinal pickers +assert.equal((ModelsPage.template.match(/class="gx-model-control[\s"]/g) || []).length, 4) // the library tab is only a view: every model is one tap away, and a sleeping GPU never hides anything assert.equal(ModelsPage.data().tab, 'both') assert.equal(ModelsPage.computed.libraryTab.call({ tab: 'gpu' }), 'gpu') @@ -411,6 +413,46 @@ const pairPage = { selectionUncertain: false, status: {}, runtime: { status: 're assert.equal(ModelsPage.computed.runningModelLabel.call(pairPage), 'Small model/Big model') assert.equal(ModelsPage.computed.runningModelLabel.call({ ...pairPage, runtime: { status: 'stale', data: pairData } }), 'Status unavailable') assert.equal(ModelsPage.computed.runningModelLabel.call({ ...pairPage, runtime: { status: 'ready', data: { ...pairData, laboratory: { ...pairData.laboratory, active: false } } } }), 'Laboratory output unavailable') -assert.match(ModelsPage.template, /Turn off Laboratory/) -assert.match(ModelsPage.template, /href="#\/model_laboratory"/) assert.match(ModelsPage.template, /fallback choices/) + +// Merged page: search, row list, Single model / Model pair mode switcher, and pair saving. +{ + const { matchesSearch, laboratoryActionAllowed, hardwareTag } = await import("../web/js/models.js") + const row = { value: 'tr16223', label: 'TR16 👀📡', series: 'TR Series', version: 'v8', released: '2025-07-21' } + assert.equal(matchesSearch(row, ''), true) + assert.equal(matchesSearch(row, 'tr16'), true) + assert.equal(matchesSearch(row, 'TR16223'), true) + assert.equal(matchesSearch(row, 'tr series v8'), true) + assert.equal(matchesSearch(row, 'v9'), false) + + assert.match(ModelsPage.template, / +