diff --git a/features/stepDefinitions/cleanup.ts b/features/stepDefinitions/cleanup.ts index 0be5d633..1d1e384e 100644 --- a/features/stepDefinitions/cleanup.ts +++ b/features/stepDefinitions/cleanup.ts @@ -37,16 +37,33 @@ After(async function(this: ApplicationWorld, { pickle }) { allWindows.map(async (window) => { try { if (!window.isClosed()) { - await window.close(); + // Add timeout protection for window.close() to prevent hanging + await Promise.race([ + window.close(), + new Promise((_, reject) => setTimeout(() => reject(new Error('Window close timeout')), 5000)), + ]); } } catch (error) { console.error('Error closing window:', error); } }), ); - await this.app.close(); + + // Add timeout protection for app.close() to prevent hanging + await Promise.race([ + this.app.close(), + new Promise((_, reject) => setTimeout(() => reject(new Error('App close timeout')), 10000)), + ]); } catch (error) { console.error('Error during cleanup:', error); + // Force kill the app if it hangs + try { + if (this.app) { + await this.app.context().close(); + } + } catch (forceCloseError) { + console.error('Error force closing app:', forceCloseError); + } } this.app = undefined; this.mainWindow = undefined; diff --git a/features/stepDefinitions/wiki.ts b/features/stepDefinitions/wiki.ts index b0348352..c85074d8 100644 --- a/features/stepDefinitions/wiki.ts +++ b/features/stepDefinitions/wiki.ts @@ -1,4 +1,5 @@ import { Then, When } from '@cucumber/cucumber'; +import { exec as gitExec } from 'dugite'; import { backOff } from 'exponential-backoff'; import fs from 'fs-extra'; import path from 'path'; @@ -536,14 +537,18 @@ When('I create a new wiki workspace with name {string}', async function(this: Ap // Ignore if .git doesn't exist }); - // Initialize fresh git repository for the new wiki - const { execSync } = await import('child_process'); + // Initialize fresh git repository for the new wiki using dugite try { - execSync('git init', { cwd: wikiPath }); - execSync('git config user.email "test@tidgi.test"', { cwd: wikiPath }); - execSync('git config user.name "TidGi Test"', { cwd: wikiPath }); - execSync('git add .', { cwd: wikiPath }); - execSync('git commit -m "Initial commit"', { cwd: wikiPath }); + // Initialize git repository with master branch + await gitExec(['init', '-b', 'master'], wikiPath); + + // Configure git user + await gitExec(['config', 'user.email', 'test@tidgi.test'], wikiPath); + await gitExec(['config', 'user.name', 'TidGi Test'], wikiPath); + + // Add all files and create initial commit + await gitExec(['add', '.'], wikiPath); + await gitExec(['commit', '-m', 'Initial commit'], wikiPath); } catch (error) { // Git initialization is not critical for the test, continue anyway console.log('Git initialization skipped:', (error as Error).message); diff --git a/package.json b/package.json index d5913d86..7e226d80 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tidgi", "productName": "TidGi", "description": "Customizable personal knowledge-base with Github as unlimited storage and blogging platform.", - "version": "0.13.0-prerelease5", + "version": "0.13.0-prerelease6", "license": "MPL 2.0", "packageManager": "pnpm@10.18.2", "scripts": {