fix: cleanup

This commit is contained in:
lin onetwo 2025-10-27 02:43:17 +08:00
parent 7f3127b4d1
commit 3c979b2562
7 changed files with 18 additions and 48 deletions

View file

@ -8,7 +8,7 @@ Feature: TidGi Preference
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
@setup
@ai-setting
Scenario: Configure AI provider and default model
# Step 1: Configure AI settings first - Open preferences window, wait a second so its URL settle down.
When I click on a "settings button" element with selector "#open-preferences-button"

View file

@ -1,6 +1,6 @@
import { After, DataTable, Given, Then } from '@cucumber/cucumber';
import { backOff } from 'exponential-backoff';
import { AIGlobalSettings, AIProviderConfig } from '@services/externalAPI/interface';
import { backOff } from 'exponential-backoff';
import fs from 'fs-extra';
import { isEqual, omit } from 'lodash';
import path from 'path';
@ -14,7 +14,6 @@ const BACKOFF_OPTIONS = {
numOfAttempts: 10,
startingDelay: 200,
timeMultiple: 1.5,
maxDelay: 3000,
};
/**
@ -140,13 +139,7 @@ Then('I should see {int} messages in chat history', async function(this: Applica
throw new Error(`Expected ${expectedCount} messages but found ${currentCount}`);
}
},
{
...BACKOFF_OPTIONS,
retry: (error: Error) => {
// Retry if we don't have enough messages yet, but not if we have too many
return !error.message.includes('(too many)');
},
},
BACKOFF_OPTIONS,
).catch(async (error: unknown) => {
// Get final count for error message
try {

View file

@ -15,10 +15,9 @@ import { clearSubWikiRoutingTestData } from './wiki';
// Backoff configuration for retries
const BACKOFF_OPTIONS = {
numOfAttempts: 5,
numOfAttempts: 8,
startingDelay: 100,
timeMultiple: 2,
maxDelay: 2000,
};
// Helper function to check if window type is valid and return the corresponding WindowNames
@ -74,10 +73,7 @@ export class ApplicationWorld {
throw new Error('Condition not met');
}
},
{
...BACKOFF_OPTIONS,
retry: () => true,
},
BACKOFF_OPTIONS,
);
return true;
} catch {
@ -183,13 +179,7 @@ export class ApplicationWorld {
}
return window;
},
{
...BACKOFF_OPTIONS,
retry: (error: Error) => {
// Don't retry if it's an invalid window type error
return !error.message.includes('is not a valid WindowNames');
},
},
BACKOFF_OPTIONS,
);
} catch (error) {
// If it's an invalid window type error, re-throw it
@ -216,10 +206,10 @@ Before(function(this: ApplicationWorld, { pickle }) {
fs.mkdirSync(screenshotsDirectory, { recursive: true });
}
if (pickle.tags.some((tag) => tag.name === '@setup')) {
if (pickle.tags.some((tag) => tag.name === '@ai-setting')) {
clearAISettings();
}
if (pickle.tags.some((tag) => tag.name === '@tidgiminiwindow')) {
if (pickle.tags.some((tag) => tag.name === '@tidgi-mini-window')) {
clearTidgiMiniWindowSettings();
}
});
@ -246,13 +236,13 @@ After(async function(this: ApplicationWorld, { pickle }) {
this.mainWindow = undefined;
this.currentWindow = undefined;
}
if (pickle.tags.some((tag) => tag.name === '@tidgiminiwindow')) {
if (pickle.tags.some((tag) => tag.name === '@tidgi-mini-window')) {
clearTidgiMiniWindowSettings();
}
if (pickle.tags.some((tag) => tag.name === '@setup')) {
if (pickle.tags.some((tag) => tag.name === '@ai-setting')) {
clearAISettings();
}
if (pickle.tags.some((tag) => tag.name === '@subwiki-routing')) {
if (pickle.tags.some((tag) => tag.name === '@subwiki')) {
clearSubWikiRoutingTestData();
}
});

View file

@ -5,10 +5,9 @@ import type { ApplicationWorld } from './application';
// Backoff configuration for retries
const BACKOFF_OPTIONS = {
numOfAttempts: 5,
numOfAttempts: 8,
startingDelay: 100,
timeMultiple: 2,
maxDelay: 2000,
};
Then('I should see {string} in the browser view content', async function(this: ApplicationWorld, expectedText: string) {
@ -27,10 +26,7 @@ Then('I should see {string} in the browser view content', async function(this: A
throw new Error(`Expected text "${expectedText}" not found`);
}
},
{
...BACKOFF_OPTIONS,
retry: () => true,
},
BACKOFF_OPTIONS,
).catch(async () => {
const finalContent = await getTextContent(this.app!);
throw new Error(
@ -55,10 +51,7 @@ Then('I should see {string} in the browser view DOM', async function(this: Appli
throw new Error(`Expected text "${expectedText}" not found in DOM`);
}
},
{
...BACKOFF_OPTIONS,
retry: () => true,
},
BACKOFF_OPTIONS,
).catch(async () => {
const finalDomContent = await getDOMContent(this.app!);
throw new Error(
@ -83,10 +76,7 @@ Then('the browser view should be loaded and visible', async function(this: Appli
throw new Error('Browser view not loaded');
}
},
{
...BACKOFF_OPTIONS,
retry: () => true,
},
BACKOFF_OPTIONS,
).catch(() => {
throw new Error('Browser view is not loaded or visible after multiple attempts');
});
@ -174,10 +164,7 @@ Then('I should not see a(n) {string} element in browser view with selector {stri
throw new Error('Element still exists');
}
},
{
...BACKOFF_OPTIONS,
retry: () => true,
},
BACKOFF_OPTIONS,
).catch(() => {
throw new Error(`Element "${elementComment}" with selector "${selector}" was found in browser view after multiple attempts, but should not be visible`);
});

View file

View file

@ -1,4 +1,4 @@
@tidgiminiwindow
@tidgi-mini-window
Feature: TidGi Mini Window
As a user
I want to enable and use the TidGi mini window

View file

@ -1,4 +1,4 @@
@tidgiminiwindow
@tidgi-mini-window
Feature: TidGi Mini Window Workspace Switching
As a user with tidgi mini window already enabled
I want to test tidgi mini window behavior with different workspace configurations