mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-05 18:20:39 -08:00
* feat: new config for tidgi mini window * chore: upgrade electron-forge * fix: use 汉语 和 漢語 * feat: shortcut to open mini window * test: TidGiMenubarWindow * feat: allow updateWindowProperties on the fly * fix: wrong icon path * fix: log not showing error message and stack * refactor: directly log error when using logger.error * feat: shortcut to open window * fix: menubar not closed * test: e2e for menubar * test: keyboard shortcut * test: wiki web content, and refactor to files * test: update command * Update Testing.md * test: menubar settings about menubarSyncWorkspaceWithMainWindow, menubarFixedWorkspaceId * test: simplify menubar test and cleanup test config * fix: view missing when execute several test all together * refactor: use hook to cleanup menubar setting * refactor: I clear test ai settings to before hook * Add option to show title bar on menubar window Introduces a new preference 'showMenubarWindowTitleBar' allowing users to toggle the title bar visibility on the menubar window. Updates related services, interfaces, and UI components to support this feature, and adds corresponding localization strings for English and Chinese. * refactor: tidgiminiwindow * refactor: preference keys to right order * Refactor window dimension checks to use constants Replaces hardcoded window dimensions with values from windowDimension and WindowNames constants for improved maintainability and consistency in window identification and checks. * I cleanup test wiki * Update defaultPreferences.ts * test: mini window workspace switch * fix: image broken by ai, and lint * fix: can't switch to mini window * refactor: useless todo * Update index.ts * refactor: reuse serialize-error * Update index.ts * Update testKeyboardShortcuts.ts * refactor: dup logic * Update ui.ts * fix: electron-ipc-cat
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
import { Then } from '@cucumber/cucumber';
|
|
import { getDOMContent, getTextContent, isLoaded } from '../supports/webContentsViewHelper';
|
|
import type { ApplicationWorld } from './application';
|
|
|
|
// Constants for retry logic
|
|
const MAX_ATTEMPTS = 3;
|
|
const RETRY_INTERVAL_MS = 500;
|
|
|
|
Then('I should see {string} in the browser view content', async function(this: ApplicationWorld, expectedText: string) {
|
|
if (!this.app) {
|
|
throw new Error('Application not launched');
|
|
}
|
|
|
|
if (!this.currentWindow) {
|
|
throw new Error('No current window available');
|
|
}
|
|
|
|
// Retry logic to check for expected text in content
|
|
const maxAttempts = MAX_ATTEMPTS;
|
|
const retryInterval = RETRY_INTERVAL_MS;
|
|
|
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
const content = await getTextContent(this.app);
|
|
if (content && content.includes(expectedText)) {
|
|
return; // Success, exit early
|
|
}
|
|
|
|
// Wait before retrying (except for the last attempt)
|
|
if (attempt < maxAttempts - 1) {
|
|
await new Promise(resolve => setTimeout(resolve, retryInterval));
|
|
}
|
|
}
|
|
|
|
// Final attempt to get content for error message
|
|
const finalContent = await getTextContent(this.app);
|
|
throw new Error(
|
|
`Expected text "${expectedText}" not found in browser view content after ${MAX_ATTEMPTS} attempts. Actual content: ${
|
|
finalContent ? finalContent.substring(0, 200) + '...' : 'null'
|
|
}`,
|
|
);
|
|
});
|
|
|
|
Then('I should see {string} in the browser view DOM', async function(this: ApplicationWorld, expectedText: string) {
|
|
if (!this.app) {
|
|
throw new Error('Application not launched');
|
|
}
|
|
|
|
if (!this.currentWindow) {
|
|
throw new Error('No current window available');
|
|
}
|
|
|
|
// Retry logic to check for expected text in DOM
|
|
const maxAttempts = MAX_ATTEMPTS;
|
|
const retryInterval = RETRY_INTERVAL_MS;
|
|
|
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
const domContent = await getDOMContent(this.app);
|
|
if (domContent && domContent.includes(expectedText)) {
|
|
return; // Success, exit early
|
|
}
|
|
|
|
// Wait before retrying (except for the last attempt)
|
|
if (attempt < maxAttempts - 1) {
|
|
await new Promise(resolve => setTimeout(resolve, retryInterval));
|
|
}
|
|
}
|
|
|
|
// Final attempt to get DOM content for error message
|
|
const finalDomContent = await getDOMContent(this.app);
|
|
throw new Error(
|
|
`Expected text "${expectedText}" not found in browser view DOM after ${MAX_ATTEMPTS} attempts. Actual DOM: ${
|
|
finalDomContent ? finalDomContent.substring(0, 200) + '...' : 'null'
|
|
}`,
|
|
);
|
|
});
|
|
|
|
Then('the browser view should be loaded and visible', async function(this: ApplicationWorld) {
|
|
if (!this.app) {
|
|
throw new Error('Application not launched');
|
|
}
|
|
|
|
if (!this.currentWindow) {
|
|
throw new Error('No current window available');
|
|
}
|
|
|
|
// Retry logic to check if browser view is loaded
|
|
const maxAttempts = MAX_ATTEMPTS;
|
|
const retryInterval = RETRY_INTERVAL_MS;
|
|
|
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
const isLoadedResult = await isLoaded(this.app);
|
|
if (isLoadedResult) {
|
|
return; // Success, exit early
|
|
}
|
|
|
|
// Wait before retrying (except for the last attempt)
|
|
if (attempt < maxAttempts - 1) {
|
|
await new Promise(resolve => setTimeout(resolve, retryInterval));
|
|
}
|
|
}
|
|
|
|
throw new Error(`Browser view is not loaded or visible after ${MAX_ATTEMPTS} attempts`);
|
|
});
|