// `just ui-test connectivity`: the registry connectivity feature in the real Bar // inside nested niri, driven by real pointer and keyboard against the feature's // Network and Bluetooth doubles. A secured network's passphrase is only ever // masked presence: it survives a live service refresh, never close and reopen, // while the expanded SSID is retained across close and reorientation. // Then every designed state: bluetooth off, empty and populated, with visible // trust and block toggles and a forget that arms first and disarms on every // dismissal; a failed join // with its next step; offline, no link of any kind, which turns the Bar chip // into a strong warning and names the unplugged cable; wireless off; no // wireless device, whose controls are disabled; and a wired link without // wireless, which reads wired · connected and keeps the chip quiet. // The suite contract (snapshot shape, helpers) is documented in .system/RULES.md. export default async function connectivitySuite({ assert, snapshot, open, check, click, input, key, screenshot, within, call, fixture }) { const connectivity = value => value.features.connectivity; const service = value => connectivity(value).service; const control = (value, name) => connectivity(value).controls[name]; const texts = value => connectivity(value).texts; const passphrase = value => control(value, 'passphrase'); const expanded = value => connectivity(value).retained.expandedSsid === 'fixture-secure' && !!control(value, 'collapse fixture-secure'); const chip = value => value.chips.connectivity; const quietChip = value => !chip(value).active && !chip(value).strong && chip(value).role === 'ui.accent'; const warningChip = value => chip(value).active && chip(value).strong && chip(value).role === 'warning'; let state = await open('connectivity', value => control(value, 'expand fixture-secure')?.rect); state = await check('opening focuses the first network row', value => control(value, 'expand fixture-home')?.focused); assert.equal(chip(state).label, 'network'); assert(quietChip(state), 'a joined network keeps the chip quiet'); assert(connectivity(state).items.networkRateRow, 'network rates render from the system service'); assert(control(state, 'wireless')?.checked && control(state, 'wireless').enabled, 'the wireless toggle is a checked noun'); assert(control(state, 'bluetooth') && !control(state, 'bluetooth').checked, 'the bluetooth toggle is an unchecked noun'); assert(control(state, 'scan for networks')?.enabled && control(state, 'scan for devices')?.enabled, 'each section has its own scan'); assert(texts(state).includes('connected'), 'the joined network is marked connected'); assert(!passphrase(state), 'no credential editor before a secured network expands'); assert.equal(connectivity(state).retained.expandedSsid, ''); assert(connectivity(state).items.bluetoothEmptyState && texts(state).includes('bluetooth is off') && control(state, 'turn on bluetooth'), 'bluetooth off is a sentence with its action'); assert(!texts(state).includes('trust') && !texts(state).includes('battery'), 'no device table header without devices'); assert(!connectivity(state).items.wiredStatus && !texts(state).some(text => text.startsWith('wired')), 'no wired line without a wired port'); await screenshot('connectivity-open'); click(control(state, 'expand fixture-secure').rect); state = await check('secured network expands a focused masked editor', value => expanded(value) && passphrase(value)?.rect && passphrase(value).focused && passphrase(value).masked && !passphrase(value).filled); assert(within(passphrase(state).rect, state.width, state.height)); assert(texts(state).includes('secured · fair signal') && !texts(state).some(text => text.includes('dBm')), 'security and signal in words, without the raw reading'); input('type', 'fixture-only'); state = await check('network secret remains represented only as masked presence', value => passphrase(value)?.filled && passphrase(value).masked && passphrase(value).text === ''); const editor = passphrase(state).id; call('connectivity', 'externalUpdate'); state = await check('live network update preserves masked input and row identity', value => service(value).generation === 1 && expanded(value) && passphrase(value)?.filled && passphrase(value).masked && passphrase(value).id === editor && service(value).connects === 0 && texts(value).includes('secured · strong signal')); await screenshot('connectivity-masked-update'); click(chip(state).rect); await check('same Bar chip closes connectivity', value => !value.popup.open && value.popup.lastCloseReason === 'bar-toggle'); fixture('vertical'); await check('real Bar moves to vertical layout', value => value.orientation === 'vertical' && within(value.chips.connectivity.rect, value.width, value.height)); state = await open('connectivity', value => passphrase(value)?.rect); state = await check('SSID survives close and reorientation but credential input does not', value => expanded(value) && passphrase(value) && !passphrase(value).filled && passphrase(value).masked && service(value).connects === 0); await screenshot('connectivity-vertical'); click(passphrase(state).rect); await check('passphrase editor takes focus by pointer', value => passphrase(value)?.focused); input('type', 'fixture-only'); await check('typed passphrase is masked presence again', value => passphrase(value)?.filled && passphrase(value).masked); key('Return'); state = await check('Enter joins once with the typed passphrase and collapses the row', value => service(value).connects === 1 && service(value).knownPassphrase && connectivity(value).retained.expandedSsid === '' && !passphrase(value) && !!control(value, 'expand fixture-secure')); key('Escape'); await check('Escape closes connectivity', value => !value.popup.open); fixture('horizontal'); await check('real Bar returns to horizontal layout', value => value.orientation === 'horizontal'); // Bluetooth: off, then on without devices, then a scan that finds one. state = await open('connectivity', value => control(value, 'turn on bluetooth')?.rect); click(control(state, 'turn on bluetooth').rect); state = await check('powered bluetooth without devices says so and points at scan', value => control(value, 'bluetooth')?.checked && texts(value).includes('no devices') && texts(value).includes('put a device in pairing mode, then scan') && !control(value, 'turn on bluetooth') && !texts(value).includes('trust')); await screenshot('connectivity-bluetooth-empty'); click(control(state, 'scan for devices').rect); state = await check('a found device brings its row without a column header', value => !!control(value, 'disconnect fixture headphones') && texts(value).includes('connected') && !texts(value).includes('linked') && !texts(value).includes('trust') && !texts(value).includes('device') && !connectivity(value).items.bluetoothEmptyState && !texts(value).includes('no devices')); for (const name of ['untrust device', 'block device', 'forget device']) assert(control(state, name)?.rect.width >= 24 && control(state, name).rect.height >= 24, `${name} is a visible 24 px target`); await screenshot('connectivity-bluetooth-devices'); // Trust and block are separate visible toggles, each with its own opposite. click(control(state, 'untrust device').rect); state = await check('untrust device leaves an untrusted device unblocked', value => texts(value).includes('untrusted') && !!control(value, 'trust device') && !!control(value, 'block device')); click(control(state, 'trust device').rect); state = await check('trust device trusts it again', value => texts(value).includes('trusted') && !!control(value, 'untrust device')); click(control(state, 'block device').rect); state = await check('block device marks the device blocked', value => control(value, 'unblock device')?.checked && texts(value).includes('trusted')); click(control(state, 'unblock device').rect); state = await check('unblock device clears the block', value => !!control(value, 'block device') && !control(value, 'block device').checked); // Forgetting needs pairing again: it arms a confirmation below the row first. const confirmForget = value => control(value, 'confirm forget device'); const forgetArmed = value => confirmForget(value)?.rect && control(value, 'forget device')?.checked && texts(value).includes('forget fixture headphones?') && !!control(value, 'disconnect fixture headphones') && within(connectivity(value).items.forgetConfirmation.rect, value.width, value.height); click(control(state, 'forget device').rect); state = await check('forget device arms a confirmation and keeps the device', value => forgetArmed(value)); await screenshot('connectivity-forget-armed'); key('Escape'); await check('Escape closes connectivity and disarms forget', value => !value.popup.open); state = await open('connectivity', value => control(value, 'forget device')?.rect); assert(!confirmForget(state) && !control(state, 'forget device').checked && control(state, 'disconnect fixture headphones'), 'connectivity reopens unarmed with the device kept'); click(control(state, 'forget device').rect); state = await check('forget device arms again', value => forgetArmed(value)); click(control(state, 'cancel').rect); state = await check('cancel disarms and returns focus to forget device', value => !confirmForget(value) && control(value, 'forget device')?.focused && !!control(value, 'disconnect fixture headphones')); key('Return'); state = await check('Enter arms forget without forgetting', value => forgetArmed(value) && control(value, 'forget device').focused); key('Tab'); await check('Tab reaches cancel before the confirmation', value => control(value, 'cancel')?.focused); key('Tab'); await check('Tab reaches the explicit forget confirmation', value => confirmForget(value)?.focused); key('Return'); state = await check('confirming forgets the device and moves focus to bluetooth', value => !control(value, 'disconnect fixture headphones') && texts(value).includes('no devices') && control(value, 'bluetooth')?.focused); // A device that sends no name reads as a bluetooth device, never as its address. click(control(state, 'scan for devices').rect); state = await check('a nameless device renders as bluetooth device', value => control(value, 'connect bluetooth device') && texts(value).includes('bluetooth device') && !texts(value).some(text => text.includes('AA:BB'))); await screenshot('connectivity-nameless-device'); // A failed secured join names the problem and the next step in the panel. call('connectivity', 'setScenario', 'failed'); state = await check('a failed join names its network and next step', value => texts(value).includes('could not join fixture-secure · check the passphrase') && quietChip(value)); await screenshot('connectivity-join-next-step'); // Offline, no link of any kind: the chip turns into a strong warning; the // panel says why, the unplugged cable included. call('connectivity', 'setScenario', 'offline'); state = await check('offline turns the chip into a strong warning', value => warningChip(value) && chip(value).title === 'network offline' && texts(value).includes('not connected · pick a network to join') && texts(value).includes('wired · unplugged') && !texts(value).includes('connected')); await screenshot('connectivity-offline'); click(control(state, 'wireless').rect); state = await check('wireless off empties the list into a sentence with its action', value => !service(value).wifiEnabled && !control(value, 'wireless').checked && texts(value).includes('wireless is off') && control(value, 'turn on wireless') && !control(value, 'scan for networks').enabled && warningChip(value)); await screenshot('connectivity-wireless-off'); click(control(state, 'turn on wireless').rect); state = await check('turn on brings the networks back', value => service(value).wifiEnabled && control(value, 'wireless').checked && !!control(value, 'expand fixture-secure')); // No wireless device: unavailable in words, controls disabled, a retry. call('connectivity', 'setScenario', 'no-device'); state = await check('a missing device disables wireless and offers a retry', value => texts(value).includes('no wireless device') && !control(value, 'wireless').enabled && !control(value, 'wireless').checked && !control(value, 'scan for networks').enabled && control(value, 'find wireless device')?.enabled && warningChip(value)); await screenshot('connectivity-no-device'); click(control(state, 'find wireless device').rect); await check('retry looks for the device again', value => service(value).retries === 1); // A wired link without wireless is online: the panel says so and the chip stays quiet. call('connectivity', 'setScenario', 'wired'); state = await check('a wired link without wireless reads wired · connected and quiets the chip', value => texts(value).includes('wired · connected') && connectivity(value).items.wiredStatus && texts(value).includes('no wireless device') && !texts(value).includes('start the wireless service or plug in an adapter') && !texts(value).includes('not connected · pick a network to join') && quietChip(value) && chip(value).title === 'network and bluetooth'); await screenshot('connectivity-wired'); call('connectivity', 'setScenario', 'no-device'); await check('without any link the missing device names its next step again', value => texts(value).includes('start the wireless service or plug in an adapter') && !texts(value).some(text => text.startsWith('wired')) && warningChip(value)); key('Escape'); await check('Escape closes connectivity and leaves the strong warning chip', value => !value.popup.open && warningChip(value) && chip(value).label === 'network'); await screenshot('connectivity-offline-bar'); // The vertical Bar trades the word for the wifi-off glyph and keeps the warning. fixture('vertical'); await check('the vertical offline chip shows wifi-off with strong warning emphasis', value => value.orientation === 'vertical' && chip(value).icon === '\u{F05AA}' && warningChip(value)); await screenshot('connectivity-offline-vertical-bar'); call('connectivity', 'setScenario', 'wired'); await check('the vertical wired chip shows the ethernet glyph without emphasis', value => quietChip(value) && chip(value).icon === '\u{F0200}'); await screenshot('connectivity-wired-vertical-bar'); call('connectivity', 'setScenario', 'online'); await check('a joined network quiets the chip and restores the wifi glyph', value => quietChip(value) && chip(value).icon === '\u{F05A9}' && chip(value).title === 'network and bluetooth'); }