mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-08 14:51:50 -07:00
* chore: upgrade Electron 39->41, forge 7.10->7.11, fix native ABI and preload naming
- electron: 39.2.3 -> 41.1.1
- @electron-forge/*: 7.10.2 -> 7.11.1
- better-sqlite3: 12.4.5 -> 12.8.0 (rebuild against Electron 41 ABI 145)
- electron-unhandled: 5.0.0 -> 4.0.1 (v5 uses top-level await, breaks CJS main build)
- vite.preload.config.ts: emit preload.js (not index.js) to avoid collision with main
- viteEntry.ts: getPreloadPath() -> preload.js, renderer path unchanged
- package.json main: .vite/build/main.js (matches forge lib output)
- package.json: strip UTF-8 BOM that broke Volta manifest parsing
* fix: resolve AbortSignal realm mismatch in Electron 41 for streaming tests
In Electron 41, ELECTRON_RUN_AS_NODE mode uses Chromium-based fetch which
requires Blink's AbortSignal. Node.js AbortSignal fails the instanceof check.
Fixes:
- vitest.config.ts: set features/** to node environment via environmentMatchGlobs
so HTTP-only tests use Node.js fetch (not Chromium fetch)
- setup-vitest.ts: guard all document/window access behind typeof document check
so setup is safe in both jsdom and node environments
- callProviderAPI.ts: no change needed (signal issue is env-specific)
* ci: increase test timeout to 60min, fix find -o with xargs rm
- timeout-minutes: 25 -> 60 (packaging ~22min + unit tests ~1min + e2e needed)
- fix 'find ... -o ... | xargs rm' -> 'find ... \( -o \) ... -exec rm -rf {} +'
(the unparenthesized -o with xargs caused 'rm: invalid option -- o' in CI)
* fix: copy tiddlywiki/core-server to packaged output
TiddlyWiki 5.4.0-prerelease introduced core-server/ directory which contains
commander.js (module-type: global). Without it, \.Commander is undefined
when load-modules.js startup runs \.Commander.initCommands(), crashing the
wiki worker with 'Cannot read properties of undefined (reading initCommands)'.
core-server is loaded by boot.js via loadPluginFolder(\.boot.coreServerPath),
which silently returns null when the directory is missing, so the error was
non-obvious and only manifested when actually starting a wiki workspace.
* perf: only screenshot on failure, revert timeout to 25min
AfterStep was capturing a screenshot after every step (~1191 of 1446 steps).
Each screenshot requires IPC round-trip: getFirstWebContentsView capturePage
serialize PNG transfer buffer fs.writeFile. On CI this costs ~200-400ms
per step, totaling ~6 minutes of pure screenshot overhead.
Now screenshots are only taken for FAILED steps, saving ~6 minutes on CI.
This brings the total test time well within the 25-minute budget.
* fix: flaky tests + merge scenarios to save 8 Electron launches
- crossWindowSync: wait for tiddler to be saved to disk via watch-fs before opening second window
- tidgiMiniWindowWorkspace: add retry backoff to 'should not see elements' step
- tidgiMiniWindow: add explicit window switch after addTiddler
- Merge 5 filesystemPlugin scenarios into 1 (save 4 launches)
- Merge 2 defaultWiki scenarios into 1 (save 1 launch)
- Merge 2 preference scenarios into 1 (save 1 launch)
- Merge smoke + logging into 1 (save 1 launch)
- Merge 2 tiddler scenarios into 1 (save 1 launch)
- Total: 65 57 scenarios (8 fewer Electron launches)
* fix: address CI failures - use IPC for mini window toggle, split talkWithAI clicks
- tidgiMiniWindow: use direct IPC toggle instead of keyboard shortcut after addTiddler
to avoid race condition between TW syncer and keyboard event dispatch
- talkWithAI: split multi-click step into individual clicks so each gets its own
25s timeout budget on CI
* fix: await showWindow() in openTidgiMiniWindow to prevent race condition
The two showWindow() calls were using void (fire-and-forget), meaning
toggleTidgiMiniWindow returned before the window was actually shown.
On CI/Xvfb, the test checked isVisible() before show() completed.
* perf: merge scenarios + split CI steps for faster E2E
- Merge 3 defaultWiki scenarios into 1 (save 2 app launches)
- Merge 2 scheduledTask scenarios into 1 (save 1 app launch)
- Split CI test step into unit/prepare/e2e for visibility
- Add pnpm store cache to CI
- Fix viteEntry.ts: remove UTF-8 BOM, update stale JSDoc comment
- Set E2E timeout to 22min (was 25min in single step)
* fix: address Copilot review - main window lookup and comment clarity
- tidgiMiniWindow.ts: use index.html URL pattern to find main window
(consistent with other step defs, avoids matching preferences window)
- ui.ts: clarify networkidle timeout comment
* fix: use IPC toggle for tidgiMiniWindow sync scenario to avoid flaky keyboard shortcut on CI
---------
Co-authored-by: CI Auto <cidevel@tiddlygit.local>
115 lines
4.5 KiB
TypeScript
115 lines
4.5 KiB
TypeScript
import { Given, When } from '@cucumber/cucumber';
|
|
import fs from 'fs-extra';
|
|
import { omit } from 'lodash';
|
|
import path from 'path';
|
|
import type { ISettingFile } from '../../src/services/database/interface';
|
|
import { getSettingsPath } from '../supports/paths';
|
|
import type { ApplicationWorld } from './application';
|
|
|
|
Given('I configure tidgi mini window with shortcut', async function(this: ApplicationWorld) {
|
|
const settingsPath = getSettingsPath(this);
|
|
let existing = {} as ISettingFile;
|
|
if (await fs.pathExists(settingsPath)) {
|
|
existing = await fs.readJson(settingsPath) as ISettingFile;
|
|
} else {
|
|
// ensure settings directory exists so writeJsonSync won't fail
|
|
await fs.ensureDir(path.dirname(settingsPath));
|
|
}
|
|
|
|
// Convert CommandOrControl to platform-specific format
|
|
const isWindows = process.platform === 'win32';
|
|
const isLinux = process.platform === 'linux';
|
|
let shortcut = 'CommandOrControl+Shift+M';
|
|
if (isWindows || isLinux) {
|
|
shortcut = 'Ctrl+Shift+M';
|
|
} else {
|
|
shortcut = 'Cmd+Shift+M';
|
|
}
|
|
|
|
const updatedPreferences = {
|
|
...existing.preferences,
|
|
tidgiMiniWindow: true,
|
|
keyboardShortcuts: {
|
|
...(existing.preferences?.keyboardShortcuts || {}),
|
|
'Window.toggleTidgiMiniWindow': shortcut,
|
|
},
|
|
};
|
|
const finalSettings = { ...existing, preferences: updatedPreferences } as ISettingFile;
|
|
await fs.writeJson(settingsPath, finalSettings, { spaces: 2 });
|
|
});
|
|
|
|
Given('I configure tidgi mini window and disable runOnBackground', async function(this: ApplicationWorld) {
|
|
const settingsPath = getSettingsPath(this);
|
|
let existing = {} as ISettingFile;
|
|
if (await fs.pathExists(settingsPath)) {
|
|
existing = await fs.readJson(settingsPath) as ISettingFile;
|
|
} else {
|
|
await fs.ensureDir(path.dirname(settingsPath));
|
|
}
|
|
|
|
const updatedPreferences = {
|
|
...existing.preferences,
|
|
tidgiMiniWindow: true,
|
|
runOnBackground: false,
|
|
};
|
|
const finalSettings = { ...existing, preferences: updatedPreferences } as ISettingFile;
|
|
await fs.writeJson(settingsPath, finalSettings, { spaces: 2 });
|
|
});
|
|
|
|
// Cleanup function to be called after tidgi mini window tests (after app closes)
|
|
async function clearTidgiMiniWindowSettings(scenarioRoot?: string) {
|
|
const root = scenarioRoot || process.cwd();
|
|
const settingsPath = path.resolve(root, 'userData-test', 'settings', 'settings.json');
|
|
if (!(await fs.pathExists(settingsPath))) return;
|
|
let parsed: ISettingFile;
|
|
try {
|
|
parsed = await fs.readJson(settingsPath) as ISettingFile;
|
|
} catch {
|
|
// File may be empty or truncated due to an in-progress write when the app
|
|
// was shut down — nothing meaningful to clean up, so skip.
|
|
return;
|
|
}
|
|
// Remove tidgi mini window-related preferences to avoid affecting other tests
|
|
const cleanedPreferences = omit(parsed.preferences || {}, [
|
|
'tidgiMiniWindow',
|
|
'tidgiMiniWindowSyncWorkspaceWithMainWindow',
|
|
'tidgiMiniWindowFixedWorkspaceId',
|
|
'tidgiMiniWindowAlwaysOnTop',
|
|
'tidgiMiniWindowShowSidebar',
|
|
'tidgiMiniWindowShowTitleBar',
|
|
]);
|
|
// Also clean up the tidgi mini window shortcut from keyboardShortcuts
|
|
if (cleanedPreferences.keyboardShortcuts) {
|
|
cleanedPreferences.keyboardShortcuts = omit(cleanedPreferences.keyboardShortcuts, ['Window.toggleTidgiMiniWindow']);
|
|
}
|
|
|
|
// Reset active workspace to first wiki workspace to avoid agent workspace being active
|
|
const workspaces = parsed.workspaces || {};
|
|
const workspaceEntries = Object.entries(workspaces);
|
|
// Set all workspaces to inactive first
|
|
for (const [, workspace] of workspaceEntries) {
|
|
workspace.active = false;
|
|
}
|
|
// Find first non-page-type workspace (wiki) and activate it
|
|
const firstWikiWorkspace = workspaceEntries.find(([, workspace]) => !workspace.pageType);
|
|
if (firstWikiWorkspace) {
|
|
firstWikiWorkspace[1].active = true;
|
|
}
|
|
|
|
const cleaned = { ...parsed, preferences: cleanedPreferences, workspaces };
|
|
await fs.writeJson(settingsPath, cleaned, { spaces: 2 });
|
|
}
|
|
|
|
When('I toggle tidgi mini window via IPC', async function(this: ApplicationWorld) {
|
|
if (!this.app) {
|
|
throw new Error('Application not launched');
|
|
}
|
|
await this.app.evaluate(async ({ BrowserWindow }) => {
|
|
// Find the main window by URL (consistent with other step defs)
|
|
const mainWindow = BrowserWindow.getAllWindows().find(w => !w.isDestroyed() && w.webContents?.getURL().includes('index.html'));
|
|
if (!mainWindow) throw new Error('Main window not found');
|
|
await mainWindow.webContents.executeJavaScript('window.service.window.toggleTidgiMiniWindow()');
|
|
});
|
|
});
|
|
|
|
export { clearTidgiMiniWindowSettings };
|