Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
import { describe, expect, it } from 'vitest';
import { buildWindowConfigOverrides } from '../../bin/helpers/merge';
import { DEFAULT_PAKE_OPTIONS } from '../../bin/defaults';
import type { PakeAppOptions } from '../../bin/types';
function makeOptions(overrides: Partial<PakeAppOptions> = {}): PakeAppOptions {
return {
...DEFAULT_PAKE_OPTIONS,
identifier: 'com.pake.test',
...overrides,
};
}
describe('buildWindowConfigOverrides', () => {
it.each(['darwin', 'win32', 'linux'] as const)(
'disables URL restoration without enabling private mode on %s',
(platform) => {
expect(
buildWindowConfigOverrides(
makeOptions({ restoreLastUrl: false }),
platform,
),
).toMatchObject({ restore_last_url: false, incognito: false });
},
);
it.each([false, true])(
'forwards password autosave=%s to native config',
(enabled) => {
expect(
buildWindowConfigOverrides(
makeOptions({ passwordAutosave: enabled }),
'win32',
).password_autosave,
).toBe(enabled);
},
);
it('matches the default snapshot on macOS', () => {
const result = buildWindowConfigOverrides(makeOptions(), 'darwin');
expect(result).toMatchSnapshot();
});
it('matches the default snapshot on Windows', () => {
const result = buildWindowConfigOverrides(makeOptions(), 'win32');
expect(result).toMatchSnapshot();
});
it('matches the default snapshot on Linux', () => {
const result = buildWindowConfigOverrides(makeOptions(), 'linux');
expect(result).toMatchSnapshot();
});
it('respects explicit hideOnClose=false on macOS', () => {
const result = buildWindowConfigOverrides(
makeOptions({ hideOnClose: false }),
'darwin',
);
expect(result.hide_on_close).toBe(false);
});
it('defaults hideOnClose to true on macOS when undefined', () => {
const result = buildWindowConfigOverrides(
makeOptions({ hideOnClose: undefined }),
'darwin',
);
expect(result.hide_on_close).toBe(true);
});
it('defaults hideOnClose to false on Linux/Windows when undefined', () => {
expect(
buildWindowConfigOverrides(
makeOptions({ hideOnClose: undefined }),
'linux',
).hide_on_close,
).toBe(false);
expect(
buildWindowConfigOverrides(
makeOptions({ hideOnClose: undefined }),
'win32',
).hide_on_close,
).toBe(false);
});
it('only forwards hideTitleBar on macOS', () => {
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideTitleBar: true },
'darwin',
).hide_title_bar,
).toBe(true);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideTitleBar: true },
'linux',
).hide_title_bar,
).toBe(false);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideTitleBar: true },
'win32',
).hide_title_bar,
).toBe(false);
});
it('only forwards navigationButtons on macOS', () => {
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), navigationButtons: true },
'darwin',
).navigation_buttons,
).toBe(true);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), navigationButtons: true },
'linux',
).navigation_buttons,
).toBe(false);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), navigationButtons: true },
'win32',
).navigation_buttons,
).toBe(false);
});
it('only forwards hideWindowDecorations on Windows and Linux', () => {
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideWindowDecorations: true },
'darwin',
).hide_window_decorations,
).toBe(false);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideWindowDecorations: true },
'linux',
).hide_window_decorations,
).toBe(true);
expect(
buildWindowConfigOverrides(
{ ...makeOptions(), hideWindowDecorations: true },
'win32',
).hide_window_decorations,
).toBe(true);
});
it('only enables start_to_tray when both flag and tray are on', () => {
expect(
buildWindowConfigOverrides(
makeOptions({ startToTray: true, showSystemTray: false }),
'darwin',
).start_to_tray,
).toBe(false);
expect(
buildWindowConfigOverrides(
makeOptions({ startToTray: true, showSystemTray: true }),
'darwin',
).start_to_tray,
).toBe(true);
});
it('forwards window/zoom/wasm/new_window flags verbatim', () => {
const result = buildWindowConfigOverrides(
makeOptions({
width: 1400,
height: 900,
zoom: 120,
minWidth: 800,
minHeight: 600,
wasm: true,
enableDragDrop: true,
ignoreCertificateErrors: true,
newWindow: true,
enableFind: true,
forceInternalNavigation: true,
internalUrlRegex: '^https://example\\.com',
}),
'darwin',
);
expect(result).toMatchObject({
width: 1400,
height: 900,
zoom: 120,
min_width: 800,
min_height: 600,
enable_wasm: true,
ignore_certificate_errors: true,
new_window: true,
enable_find: true,
force_internal_navigation: true,
internal_url_regex: '^https://example\\.com',
});
// --enable-drag-drop is still accepted but no longer reaches the window.
expect(result).not.toHaveProperty('enable_drag_drop');
});
});