import Adw from 'gi://Adw'; import Gtk from 'gi://Gtk'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import { fillSettingsWindow } from '../apps/gnome-extension/jarvis@qvac.local/settings-window.js'; const root = Gio.File.new_for_uri(import.meta.url).get_parent().get_parent().get_path(); const directory = `${root}/apps/gnome-extension/jarvis@qvac.local`; const app = new Adw.Application({ application_id: 'io.qvac.Jarvis.SettingsSmoke', flags: Gio.ApplicationFlags.NON_UNIQUE }); app.connect('activate', () => { const source = Gio.SettingsSchemaSource.new_from_directory(`${directory}/schemas`, Gio.SettingsSchemaSource.get_default(), false); const settings = new Gio.Settings({ settings_schema: source.lookup('org.gnome.shell.extensions.jarvis', true) }); const window = new Adw.PreferencesWindow({ application: app }); const { editor, pages } = fillSettingsWindow(window, settings, directory); const snapshots = ['voice', 'listening', 'desktop', 'models']; let index = 0; window.present(); GLib.timeout_add(GLib.PRIORITY_DEFAULT, 700, () => { try { const paintable = new Gtk.WidgetPaintable({ widget: window }); const snapshot = new Gtk.Snapshot(); paintable.snapshot(snapshot, window.get_width(), window.get_height()); const texture = window.get_renderer().render_texture(snapshot.to_node(), null); texture.save_to_png(`/tmp/jarvis-settings-${snapshots[index]}.png`); if (++index === pages.length) { const field = editor.fields.find(f => f.key === 'ttsPreset'); editor.rows.get(field.key)._setValue('chatterbox'); if (!editor.rows.get('ttsReferenceAudio').visible || editor.rows.get('voiceId').visible) throw new Error('Model-dependent controls did not update'); print(`Settings UI smoke passed: ${editor.rows.size} controls across ${pages.length} pages`); app.quit(); return GLib.SOURCE_REMOVE; } window.set_visible_page(pages[index]); return GLib.SOURCE_CONTINUE; } catch (error) { printerr(error.stack); app.quit(); throw error; } }); }); app.run([]);