mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-21 12:02:57 -08:00
fix: test that requires enableFileSystemWatch use new step set to true
This commit is contained in:
parent
11f7794b66
commit
307691fadf
8 changed files with 105 additions and 1 deletions
|
|
@ -11,6 +11,10 @@ Feature: AI-Generated Git Commit Messages
|
|||
And I launch the TidGi application
|
||||
And I wait for the page to load completely
|
||||
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ Feature: TidGi Default Wiki
|
|||
|
||||
@wiki @move-workspace
|
||||
Scenario: Move workspace to a new location
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
When I open edit workspace window for workspace with name "wiki"
|
||||
And I switch to "editWorkspace" window
|
||||
And I wait for the page to load completely
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ Feature: Filesystem Plugin
|
|||
And I launch the TidGi application
|
||||
And I wait for the page to load completely
|
||||
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ Feature: Git Log Window
|
|||
And I launch the TidGi application
|
||||
And I wait for the page to load completely
|
||||
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
|
|
|
|||
|
|
@ -714,6 +714,86 @@ When('I create a new wiki workspace with name {string}', async function(this: Ap
|
|||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Update workspace settings dynamically after app launch
|
||||
* This is useful for enabling features like enableFileSystemWatch in tests
|
||||
*
|
||||
* Usage:
|
||||
* When I update workspace "wiki" settings:
|
||||
* | property | value |
|
||||
* | enableFileSystemWatch | true |
|
||||
* | syncOnInterval | false |
|
||||
*/
|
||||
When('I update workspace {string} settings:', async function(this: ApplicationWorld, workspaceName: string, dataTable: DataTable) {
|
||||
if (!this.app) {
|
||||
throw new Error('Application is not available');
|
||||
}
|
||||
|
||||
// Parse settings from DataTable
|
||||
const rows = dataTable.hashes();
|
||||
const settingsUpdate: Record<string, unknown> = {};
|
||||
|
||||
for (const row of rows) {
|
||||
const { property, value } = row;
|
||||
|
||||
// Convert value to appropriate type
|
||||
let parsedValue: unknown = value;
|
||||
if (value === 'true') parsedValue = true;
|
||||
else if (value === 'false') parsedValue = false;
|
||||
else if (value === 'null') parsedValue = null;
|
||||
else if (!isNaN(Number(value))) parsedValue = Number(value);
|
||||
// Try to parse as JSON array
|
||||
else if (value.startsWith('[') && value.endsWith(']')) {
|
||||
try {
|
||||
parsedValue = JSON.parse(value);
|
||||
} catch {
|
||||
// Keep as string if JSON parse fails
|
||||
}
|
||||
}
|
||||
|
||||
settingsUpdate[property] = parsedValue;
|
||||
}
|
||||
|
||||
// Read settings file to get workspace ID
|
||||
const settings = await fs.readJson(settingsPath) as { workspaces?: Record<string, IWorkspace> };
|
||||
const workspaces: Record<string, IWorkspace> = settings.workspaces ?? {};
|
||||
|
||||
// Find workspace by name
|
||||
let targetWorkspaceId: string | undefined;
|
||||
for (const [id, workspace] of Object.entries(workspaces)) {
|
||||
if (!workspace.pageType && workspace.name === workspaceName) {
|
||||
targetWorkspaceId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetWorkspaceId) {
|
||||
throw new Error(`No workspace found with name: ${workspaceName}`);
|
||||
}
|
||||
|
||||
// Update workspace settings via main window
|
||||
await this.app.evaluate(async ({ BrowserWindow }, { workspaceId, updates }: { workspaceId: string; updates: Record<string, unknown> }) => {
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
const mainWindow = windows.find(win => !win.isDestroyed() && win.webContents && win.webContents.getURL().includes('index.html'));
|
||||
|
||||
if (!mainWindow) {
|
||||
throw new Error('Main window not found');
|
||||
}
|
||||
|
||||
// Call workspace service to update workspace settings
|
||||
await mainWindow.webContents.executeJavaScript(`
|
||||
(async () => {
|
||||
await window.service.workspace.update(${JSON.stringify(workspaceId)}, ${JSON.stringify(updates)});
|
||||
})();
|
||||
`);
|
||||
}, { workspaceId: targetWorkspaceId, updates: settingsUpdate });
|
||||
|
||||
// Wait for settings to propagate
|
||||
await this.app.evaluate(async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Clean up hibernation test data - remove wiki2 folder and its workspace config
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ Feature: Sub-Wiki Functionality
|
|||
Then I should see "page body and workspaces" elements with selectors:
|
||||
| div[data-testid^='workspace-']:has-text('wiki') |
|
||||
| div[data-testid^='workspace-']:has-text('SubWiki') |
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ Feature: Git Sync
|
|||
And I launch the TidGi application
|
||||
And I wait for the page to load completely
|
||||
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
# Enable file system watch for testing (default is false in production)
|
||||
When I update workspace "wiki" settings:
|
||||
| property | value |
|
||||
| enableFileSystemWatch | true |
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
And I wait for "git initialization" log marker "[test-id-git-init-complete]"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Feature: Tiddler Creation and Editing
|
|||
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
|
||||
Then the browser view should be loaded and visible
|
||||
And I wait for SSE and watch-fs to be ready
|
||||
And I wait for "SSE backend ready" log marker "[test-id-SSE_READY]"
|
||||
|
||||
@tiddler @tiddler-create
|
||||
Scenario: Create a new tiddler with tag and custom field via UI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue