+289
-97
@@ -3,41 +3,93 @@ import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
|
||||
const source = readFileSync(new URL('../apps/gnome-extension/[email protected]/extension.js', import.meta.url), 'utf8');
|
||||
const uiSource = readFileSync(new URL('../apps/gnome-extension/[email protected]/ui.js', import.meta.url), 'utf8');
|
||||
const extensionSource = readFileSync(new URL('../apps/gnome-extension/[email protected]/extension.js', import.meta.url), 'utf8');
|
||||
|
||||
function stripModules(source) {
|
||||
return source
|
||||
.replace(/^import(?:\s+type)?\s+[\s\S]*?from\s+['"][^'"]+['"];\s*$/gm, '')
|
||||
.replace(/^export default class/gm, 'class')
|
||||
.replace(/^export class/gm, 'class')
|
||||
.replace(/^export const /gm, 'const ')
|
||||
.replace(/^export function /gm, 'function ')
|
||||
.replace(/^export \{[\s\S]*?\};$/gm, '');
|
||||
}
|
||||
|
||||
function harness() {
|
||||
const timers = new Map();
|
||||
const chrome = [];
|
||||
class Actor {
|
||||
constructor(props = {}) {
|
||||
if ('hexpand' in props) throw new Error('No property hexpand on StWidget');
|
||||
Object.assign(this, props);
|
||||
this.children = [];
|
||||
this.visible = props.visible !== false;
|
||||
this.text = props.text || props.hint_text || '';
|
||||
this.clutter_text = { connect() {}, ellipsize: null };
|
||||
}
|
||||
add_child(child) { this.children.push(child); }
|
||||
add_child(child) { this.children.push(child); child.get_parent = () => this; }
|
||||
remove_child(child) { this.children = this.children.filter((item) => item !== child); }
|
||||
destroy_all_children() { this.children = []; }
|
||||
get_n_children() { return this.children.length; }
|
||||
contains() { return false; }
|
||||
get_last_child() { return this.children[this.children.length - 1] || null; }
|
||||
connect() { return 1; }
|
||||
get_first_child() { return this.children[0] || null; }
|
||||
connect(name, handler) {
|
||||
this.handlers = this.handlers || {};
|
||||
this.handlers[name] = handler;
|
||||
return 1;
|
||||
}
|
||||
hide() { this.visible = false; }
|
||||
show() { this.visible = true; }
|
||||
destroy() { this.destroyed = true; }
|
||||
destroy() { this.destroyed = true; this.visible = false; }
|
||||
set_position() {}
|
||||
set_width() {}
|
||||
set_height() {}
|
||||
grab_key_focus() {}
|
||||
set_style() {}
|
||||
add_style_class_name() {}
|
||||
get_first_child() { return this.children[0] || null; }
|
||||
get_text() { return this.text || ''; }
|
||||
set_text(value) { this.text = value; }
|
||||
}
|
||||
const menu = {
|
||||
box: new Actor(),
|
||||
actor: new Actor(),
|
||||
opened: false,
|
||||
connect(_name, handler) { this._handler = handler; return 2; },
|
||||
disconnect() {},
|
||||
addMenuItem(item) { this.box.add_child(item.actor || item); },
|
||||
open() { this.opened = true; this._handler?.(this, true); },
|
||||
close() { this.opened = false; this._handler?.(this, false); },
|
||||
removeAll() { this.box.destroy_all_children(); },
|
||||
};
|
||||
const context = vm.createContext({
|
||||
Extension: class {},
|
||||
global: { stage: { get_key_focus() { return null; } } },
|
||||
St: { BoxLayout: Actor, Label: Actor, Widget: Actor, Button: Actor, Entry: Actor, ScrollView: Actor, PolicyType: { NEVER: 0, AUTOMATIC: 1 } },
|
||||
Clutter: { ActorAlign: { CENTER: 0, START: 1 }, EVENT_STOP: 1, EVENT_PROPAGATE: 0 },
|
||||
Clutter: { ActorAlign: { CENTER: 0, START: 1 }, EVENT_STOP: 1, EVENT_PROPAGATE: 0, KEY_space: 32, KEY_Return: 65293, KEY_Escape: 65307 },
|
||||
Pango: { WrapMode: { WORD_CHAR: 2 }, EllipsizeMode: { NONE: 0, END: 3 } },
|
||||
Main: { layoutManager: { addChrome() {}, primaryMonitor: { x: 0, y: 0, width: 1920, height: 1080 } } },
|
||||
PopupMenu: {
|
||||
PopupBaseMenuItem: class extends Actor {
|
||||
constructor(props) { super(props); this.actor = this; }
|
||||
},
|
||||
PopupMenuItem: class extends Actor {
|
||||
constructor(props) { super(props); this.actor = this; this.label = typeof props === 'string' ? props : props?.label; }
|
||||
},
|
||||
PopupSeparatorMenuItem: class extends Actor { constructor() { super(); this.actor = this; } },
|
||||
PopupMenuSection: class extends Actor {
|
||||
constructor() { super(); this.actor = this; this.box = this; }
|
||||
},
|
||||
},
|
||||
PanelMenu: { Button: class extends Actor {
|
||||
constructor() { super(); this.menu = menu; }
|
||||
} },
|
||||
Main: {
|
||||
layoutManager: { addChrome(actor) { chrome.push(actor); }, primaryMonitor: { x: 0, y: 0, width: 1920, height: 1080 } },
|
||||
panel: { addToStatusArea() {} },
|
||||
wm: { addKeybinding() {}, removeKeybinding() {} },
|
||||
screenShield: { connect() { return 1; }, disconnect() {}, locked: false },
|
||||
},
|
||||
GLib: {
|
||||
PRIORITY_DEFAULT: 0, PRIORITY_DEFAULT_IDLE: 200, SOURCE_REMOVE: false,
|
||||
idle_add(_priority, callback) { callback(); return 1; },
|
||||
@@ -46,75 +98,98 @@ function harness() {
|
||||
},
|
||||
log() {},
|
||||
});
|
||||
vm.runInContext(source.replace(/^import .*;\n/gm, '').replace('export default class', 'class') +
|
||||
'\nglobalThis.classes = { ArcOverlay, JarvisExtension, JarvisProxy };', context);
|
||||
return { ...context.classes, timers };
|
||||
vm.runInContext(
|
||||
`${stripModules(uiSource)}\n${stripModules(extensionSource)}\nglobalThis.classes = { ConversationView, JarvisOsd, ComputerUseChrome, SessionPanel, JarvisExtension, JarvisProxy };`,
|
||||
context,
|
||||
);
|
||||
return { ...context.classes, timers, chrome, menu };
|
||||
}
|
||||
|
||||
test('overlay constructs and destroys with pending halo animation', () => {
|
||||
const { ArcOverlay, timers } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
assert.equal(overlay.header.children[1].x_expand, true);
|
||||
overlay.attach();
|
||||
overlay.show(true);
|
||||
overlay.showHalo();
|
||||
overlay.showHalo();
|
||||
assert.equal(timers.size, 1);
|
||||
overlay.destroy();
|
||||
assert.equal(timers.size, 0);
|
||||
test('compact popup constructs without a floating 720px overlay', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
assert.equal(popup.compact, true);
|
||||
assert.match(popup.root.style_class, /jarvis-popup/);
|
||||
assert.equal(popup.header.children[1].x_expand, true);
|
||||
assert.equal(popup.expand.label, 'Open');
|
||||
assert.equal(popup.expand.accessible_name, 'Open conversation');
|
||||
assert.equal(popup.settings.label, 'Settings');
|
||||
assert.equal(popup.header.children.includes(popup.settings), true);
|
||||
assert.doesNotMatch(popup.root.style_class, /jarvis-arc/);
|
||||
});
|
||||
|
||||
test('empty chrome widgets start hidden', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
assert.equal(overlay.job.visible, false);
|
||||
assert.equal(overlay.target.visible, false);
|
||||
assert.equal(overlay.cursor.visible, false);
|
||||
assert.equal(overlay.wave.visible, false);
|
||||
const { ConversationView, ComputerUseChrome } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const cu = new ComputerUseChrome();
|
||||
assert.equal(popup.confirm.visible, false);
|
||||
assert.equal(popup.thinking.visible, false);
|
||||
assert.equal(popup.chipScroll.visible, false);
|
||||
assert.equal(cu.root.visible, false);
|
||||
assert.equal(cu.target.visible, false);
|
||||
assert.equal(cu.cursor.visible, false);
|
||||
});
|
||||
|
||||
test('Reply finalizes a streaming row instead of duplicating [object Object]', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.token('Hello! I am ready.');
|
||||
overlay.finalizeReply('[object Object]');
|
||||
overlay.finalizeReply({ text: 'ignored duplicate' });
|
||||
assert.equal(overlay.transcript.children.length, 1);
|
||||
assert.match(overlay.transcript.children[0].text, /Hello! I am ready/);
|
||||
assert.doesNotMatch(overlay.transcript.children[0].text, /object Object/);
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.token('Hello! I am ready.');
|
||||
popup.finalizeReply('[object Object]');
|
||||
popup.finalizeReply({ text: 'ignored duplicate' });
|
||||
assert.equal(popup.transcript.children.length, 1);
|
||||
assert.match(popup.transcript.children[0].text, /Hello! I am ready/);
|
||||
assert.doesNotMatch(popup.transcript.children[0].text, /object Object/);
|
||||
});
|
||||
|
||||
test('final reply is shown after tool result rows', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.addToolCall('{"name":"runtime_status"}');
|
||||
overlay.addToolResult('{"name":"runtime_status"}');
|
||||
overlay.finalizeReply('Your computer is ready.');
|
||||
assert.equal(overlay.transcript.children.length, 3);
|
||||
assert.match(overlay.transcript.children[2].text, /Your computer is ready/);
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.addToolCall('{"name":"runtime_status"}');
|
||||
popup.addToolResult('{"name":"runtime_status"}');
|
||||
popup.finalizeReply('Your computer is ready.');
|
||||
assert.equal(popup.transcript.children.length, 3);
|
||||
assert.match(popup.transcript.children[2].text, /Your computer is ready/);
|
||||
});
|
||||
|
||||
test('tokens after a tool result start a new spoken Jarvis row', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.addToolCall('{"name":"capability_status"}');
|
||||
overlay.addToolResult('{"name":"capability_status"}');
|
||||
overlay.token('Your computer is ready.');
|
||||
overlay.finalizeReply('Your computer is ready.');
|
||||
assert.equal(overlay.transcript.children.length, 3);
|
||||
assert.match(overlay.transcript.children[2].text, /Your computer is ready/);
|
||||
assert.doesNotMatch(overlay.transcript.children[2].style_class, /jarvis-row-tool/);
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.addToolCall('{"name":"capability_status"}');
|
||||
popup.addToolResult('{"name":"capability_status"}');
|
||||
popup.token('Your computer is ready.');
|
||||
popup.finalizeReply('Your computer is ready.');
|
||||
assert.equal(popup.transcript.children.length, 3);
|
||||
assert.match(popup.transcript.children[2].text, /Your computer is ready/);
|
||||
assert.doesNotMatch(popup.transcript.children[2].style_class, /jarvis-row-tool/);
|
||||
});
|
||||
|
||||
test('whitespace-only tokens do not open an empty Jarvis row', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.token(' \n');
|
||||
assert.equal(popup.transcript.children.length, 0);
|
||||
popup.token('Hostname is nest.');
|
||||
assert.equal(popup.transcript.children.length, 1);
|
||||
popup.token(' ');
|
||||
assert.match(popup.transcript.children[0].text, /Hostname is nest/);
|
||||
});
|
||||
|
||||
test('addRow and token coerce objects to readable text', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.addRow('U', { text: 'Hi there' });
|
||||
overlay.token({ text: 'Hello from Jarvis' });
|
||||
assert.equal(overlay.transcript.children.length, 2);
|
||||
assert.match(overlay.transcript.children[0].text, /Hi there/);
|
||||
assert.match(overlay.transcript.children[1].text, /Hello from Jarvis/);
|
||||
assert.doesNotMatch(overlay.transcript.children.map((row) => row.text).join('\n'), /object Object/);
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.addRow('U', { text: 'Hi there' });
|
||||
popup.token({ text: 'Hello from Jarvis' });
|
||||
assert.equal(popup.transcript.children.length, 2);
|
||||
assert.match(popup.transcript.children[0].text, /Hi there/);
|
||||
assert.match(popup.transcript.children[1].text, /Hello from Jarvis/);
|
||||
assert.doesNotMatch(popup.transcript.children.map((row) => row.text).join('\n'), /object Object/);
|
||||
});
|
||||
|
||||
test('popup transcript stays short', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
for (let i = 0; i < 12; i++) popup.addRow('U', `line ${i}`);
|
||||
assert.equal(popup.transcript.children.length, 8);
|
||||
});
|
||||
|
||||
for (const fails of [false, true]) {
|
||||
@@ -125,22 +200,33 @@ for (const fails of [false, true]) {
|
||||
extension.proxy = { connect: () => new Promise((resolve, reject) => { finish = fails ? reject : resolve; }) };
|
||||
const pending = extension._connectDaemon();
|
||||
extension.proxy = null;
|
||||
extension.overlay = null;
|
||||
extension.popup = null;
|
||||
extension.session = null;
|
||||
finish(fails ? new Error('Disconnected') : undefined);
|
||||
await pending;
|
||||
});
|
||||
}
|
||||
|
||||
test('GNOME GI imports expose default namespaces and panel has a real menu', () => {
|
||||
assert.match(source, /import Shell from 'gi:\/\/Shell'/);
|
||||
assert.match(source, /import Meta from 'gi:\/\/Meta'/);
|
||||
assert.match(source, /import Pango from 'gi:\/\/Pango'/);
|
||||
assert.match(source, /new PanelMenu.Button\(0.0, 'Jarvis QVAC', false\)/);
|
||||
assert.match(source, /PushToTalk/);
|
||||
assert.match(source, /finalizeReply/);
|
||||
assert.match(source, /\['Thinking'/);
|
||||
assert.match(source, /\['ToolCall'/);
|
||||
assert.match(source, /Minimize/);
|
||||
assert.match(extensionSource, /import Shell from 'gi:\/\/Shell'/);
|
||||
assert.match(extensionSource, /import Meta from 'gi:\/\/Meta'/);
|
||||
assert.match(extensionSource, /new PanelMenu.Button\(0.0, 'Jarvis QVAC', false\)/);
|
||||
assert.match(extensionSource, /PushToTalk/);
|
||||
assert.match(extensionSource, /\['Thinking'/);
|
||||
assert.match(extensionSource, /\['ToolCall'/);
|
||||
assert.match(extensionSource, /_openPopup/);
|
||||
assert.match(uiSource, /Open conversation/);
|
||||
assert.match(extensionSource, /PopupMenuSection/);
|
||||
assert.match(extensionSource, /_openSettings/);
|
||||
assert.match(extensionSource, /PopupMenuItem\('Settings'\)/);
|
||||
assert.match(extensionSource, /PopupMenuItem\('Grant desktop'\)/);
|
||||
assert.doesNotMatch(uiSource, /button-press-event', \(\) => Clutter\.EVENT_STOP/);
|
||||
assert.match(uiSource, /notify::pressed/);
|
||||
assert.match(extensionSource, /ComputerGrant/);
|
||||
assert.match(extensionSource, /OpenExtensionPrefs/);
|
||||
assert.match(uiSource, /finalizeReply/);
|
||||
assert.doesNotMatch(extensionSource, /this\.overlay\.show\(true\)/);
|
||||
assert.doesNotMatch(extensionSource, /Minimize/);
|
||||
});
|
||||
|
||||
test('D-Bus confirmation signal does not call missing Interface.emit', () => {
|
||||
@@ -151,42 +237,143 @@ test('D-Bus confirmation signal does not call missing Interface.emit', () => {
|
||||
assert.match(dbusSource, /Confirm: \{ inSignature: 'sss'/);
|
||||
});
|
||||
|
||||
test('minimize stays closed while Jarvis speaks, then restore shows the transcript', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.attach();
|
||||
overlay.show(true);
|
||||
overlay.minimize();
|
||||
overlay.setState('SPEAKING');
|
||||
overlay.finalizeReply('I am still talking in the background.');
|
||||
assert.equal(overlay.root.visible, false);
|
||||
overlay.show(true);
|
||||
assert.equal(overlay.root.visible, true);
|
||||
assert.match(overlay.transcript.children[0].text, /still talking/);
|
||||
test('session panel stays closed while Jarvis speaks unless expanded', () => {
|
||||
const { SessionPanel } = harness();
|
||||
const session = new SessionPanel();
|
||||
session.attach();
|
||||
session.view.setState('SPEAKING');
|
||||
session.view.finalizeReply('I am still talking in the background.');
|
||||
assert.equal(session.root.visible, false);
|
||||
session.show(true);
|
||||
assert.equal(session.root.visible, true);
|
||||
assert.match(session.view.transcript.children[0].text, /still talking/);
|
||||
});
|
||||
|
||||
test('OSD shows listening without opening a conversation panel', () => {
|
||||
const { JarvisOsd, SessionPanel, timers } = harness();
|
||||
const osd = new JarvisOsd();
|
||||
const session = new SessionPanel();
|
||||
osd.attach();
|
||||
session.attach();
|
||||
osd.setState('LISTENING');
|
||||
assert.equal(osd.root.visible, true);
|
||||
assert.match(osd.label.text, /Listening/);
|
||||
assert.equal(session.root.visible, false);
|
||||
osd.setState('ARMED');
|
||||
assert.equal(osd.root.visible, false);
|
||||
osd.setState('SPEAKING');
|
||||
assert.equal(osd.root.visible, true);
|
||||
assert.ok(timers.size >= 1);
|
||||
osd.showWake();
|
||||
assert.equal(timers.size, 1);
|
||||
osd.destroy();
|
||||
assert.equal(timers.size, 0);
|
||||
});
|
||||
|
||||
test('computer-use chrome shows a target without a transcript', () => {
|
||||
const { ComputerUseChrome } = harness();
|
||||
const cu = new ComputerUseChrome();
|
||||
cu.attach();
|
||||
assert.equal(cu.root.visible, false);
|
||||
cu.setTarget('{"rect":[1,2,3,4]}');
|
||||
assert.equal(cu.root.visible, true);
|
||||
assert.equal(cu.target.visible, true);
|
||||
assert.equal(cu.cursor.visible, true);
|
||||
assert.ok(!cu.transcript);
|
||||
cu.hide();
|
||||
assert.equal(cu.root.visible, false);
|
||||
});
|
||||
|
||||
test('ConfirmationRequired chips answer Confirm with job and tool ids', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const answers = [];
|
||||
overlay.onConfirm = (...args) => answers.push(args);
|
||||
overlay.offerConfirm('write_file', JSON.stringify({ jobId: 'job-1', toolCallId: 'call-9', args: { path: '~/notes' } }), 'destructive');
|
||||
assert.equal(overlay.confirm.visible, true);
|
||||
overlay._answerConfirm('allow');
|
||||
assert.equal(overlay.confirm.visible, false);
|
||||
const shown = [];
|
||||
popup.onConfirm = (...args) => answers.push(args);
|
||||
popup.onConfirmShown = () => shown.push(true);
|
||||
popup.offerConfirm('write_file', JSON.stringify({ jobId: 'job-1', toolCallId: 'call-9', args: { path: '~/notes' } }), 'destructive');
|
||||
assert.equal(popup.confirm.visible, true);
|
||||
assert.equal(popup.confirmButtons.children.length, 3);
|
||||
assert.equal(popup.confirmButtons.children[1].label, 'Always allow');
|
||||
assert.equal(shown.length, 1);
|
||||
popup._answerConfirm('allow');
|
||||
assert.equal(popup.confirm.visible, false);
|
||||
assert.deepEqual(answers, [['job-1', 'call-9', 'allow']]);
|
||||
});
|
||||
|
||||
test('Always allow Confirm remembers the decision string', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const answers = [];
|
||||
popup.onConfirm = (...args) => answers.push(args);
|
||||
popup.offerConfirm('run_terminal_cmd', JSON.stringify({ jobId: 'job-2', toolCallId: 'call-3', args: { command: 'uname -a' } }), 'uname -a');
|
||||
assert.match(popup.confirmLabel.text, /uname -a/);
|
||||
popup._answerConfirm('always');
|
||||
assert.deepEqual(answers, [['job-2', 'call-3', 'always']]);
|
||||
});
|
||||
|
||||
test('tool results show a stdout preview instead of only complete', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.addToolCall('{"name":"run_terminal_cmd"}');
|
||||
popup.addToolResult(JSON.stringify({ name: 'run_terminal_cmd', result: 'Linux 6.8\nexit 0' }));
|
||||
assert.match(popup.transcript.children[1].text, /Linux 6\.8/);
|
||||
});
|
||||
|
||||
test('errors and reset failures are one-line notices, not chat rows', () => {
|
||||
const { ArcOverlay } = harness();
|
||||
const overlay = new ArcOverlay();
|
||||
overlay.setNotice('ResetContext failed:\nTypeError: Cannot read properties of undefined (reading \'apply\')');
|
||||
assert.equal(overlay.transcript.children.length, 0);
|
||||
assert.equal(overlay.notice.visible, true);
|
||||
assert.doesNotMatch(overlay.notice.text, /\n/);
|
||||
overlay.clear();
|
||||
overlay.setNotice('New conversation');
|
||||
assert.equal(overlay.notice.text, 'New conversation');
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
popup.setNotice('ResetContext failed:\nTypeError: Cannot read properties of undefined (reading \'apply\')');
|
||||
assert.equal(popup.transcript.children.length, 0);
|
||||
assert.equal(popup.notice.visible, true);
|
||||
assert.doesNotMatch(popup.notice.text, /\n/);
|
||||
popup.clear();
|
||||
popup.setNotice('New conversation');
|
||||
assert.equal(popup.notice.text, 'New conversation');
|
||||
});
|
||||
|
||||
test('Settings chip is in the header and opens preferences', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const calls = [];
|
||||
popup.onSettings = () => calls.push('settings');
|
||||
popup.settings.handlers.clicked();
|
||||
assert.deepEqual(calls, ['settings']);
|
||||
const session = new ConversationView({ compact: false });
|
||||
session.onSettings = () => calls.push('session');
|
||||
session.settings.handlers.clicked();
|
||||
assert.deepEqual(calls, ['settings', 'session']);
|
||||
});
|
||||
|
||||
test('HUD chips and hold-to-talk receive clicks instead of swallowing them', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const calls = [];
|
||||
popup.onStop = () => calls.push('stop');
|
||||
popup.onReset = () => calls.push('reset');
|
||||
popup.onExpand = () => calls.push('open');
|
||||
popup.onSettings = () => calls.push('settings');
|
||||
popup.onTalk = (pressed) => calls.push(pressed ? 'talk-down' : 'talk-up');
|
||||
popup.stop.handlers.clicked();
|
||||
popup.reset.handlers.clicked();
|
||||
popup.expand.handlers.clicked();
|
||||
popup.settings.handlers.clicked();
|
||||
popup.talk.pressed = true;
|
||||
popup.talk.handlers['notify::pressed']();
|
||||
popup.talk.pressed = false;
|
||||
popup.talk.handlers['notify::pressed']();
|
||||
assert.deepEqual(calls, ['stop', 'reset', 'open', 'settings', 'talk-down', 'talk-up']);
|
||||
assert.equal(popup.stop.handlers['button-press-event'], undefined);
|
||||
assert.equal(popup.settings.handlers['button-press-event'], undefined);
|
||||
});
|
||||
|
||||
test('closing the popup ends hold-to-talk', () => {
|
||||
const { ConversationView } = harness();
|
||||
const popup = new ConversationView({ compact: true });
|
||||
const talks = [];
|
||||
popup.onTalk = (pressed) => talks.push(pressed);
|
||||
popup.endTalk();
|
||||
assert.deepEqual(talks, [false]);
|
||||
});
|
||||
|
||||
test('prefs bind every GSettings schema key', () => {
|
||||
@@ -198,4 +385,9 @@ test('prefs bind every GSettings schema key', () => {
|
||||
assert.match(prefs, /wakePhrase/);
|
||||
assert.match(prefs, /ttsEnabled/);
|
||||
assert.match(prefs, /modelProfile/);
|
||||
assert.match(prefs, /'tray'/);
|
||||
assert.match(prefs, /'expanded'/);
|
||||
assert.match(prefs, /ComputerGrant/);
|
||||
assert.match(prefs, /Allow now/);
|
||||
assert.match(prefs, /ComputerRevoke/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user