From 3d672a392bdfd4b961e51ec3e9f1904763f96a02 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Mon, 5 Jan 2026 23:46:22 +0800 Subject: [PATCH] Improve GitLog i18n test and config refresh logic Updated gitLog.feature to use only Chinese selectors for actions, revert, and discard buttons, improving i18n test reliability. In FileSystemWatcher, re-fetch workspace config before checking enableFileSystemWatch to ensure latest settings are respected. In useGitLogData, prevent file-change events from overriding commit/undo events to maintain correct auto-selection behavior. --- features/gitLog.feature | 12 +++++++----- .../watchFileSystemAdaptor/FileSystemWatcher.ts | 16 +++++++++++++++- src/windows/GitLog/useGitLogData.ts | 5 ++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/features/gitLog.feature b/features/gitLog.feature index e5e1553a..dc1f6eb5 100644 --- a/features/gitLog.feature +++ b/features/gitLog.feature @@ -70,7 +70,7 @@ Feature: Git Log Window # Verify we can see the modified Index.tid file Then I should see a "Index.tid file in uncommitted list" element with selector "li:has-text('Index.tid')" # Switch to Actions tab - When I click on a "actions tab" element with selector "button[role='tab']:has-text('操作'), button[role='tab']:has-text('Actions')" + When I click on a "actions tab" element with selector "button[role='tab']:has-text('操作')" # Verify the commit now button is visible Then I should see a "commit now button" element with selector "button[data-testid='commit-now-button']" # Click the commit now button @@ -83,8 +83,10 @@ Feature: Git Log Window # Don't need to Click on the commit row we just created (contains the commit message) Because we should automatically select it And I wait for 1 seconds for "commit details panel to load and git lock to release" # Don't need to Switch to Actions tab to test rollback, because we are already on Actions tab + # Wait for revert button to be visible (should auto-select first commit after commit) + Then I should see a "revert button" element with selector "button:has-text('回滚')" # Click revert button - When I click on a "revert button" element with selector "button:has-text('回退此提交'), button:has-text('Revert')" + When I click on a "revert button" element with selector "button:has-text('回滚')" # Wait for git revert operation to complete - git operations can be slow on CI and may take longer than usual when system is under load # The git revert process involves file system operations that may be queued by the OS Then I wait for "git revert completed" log marker "[test-id-git-revert-complete]" @@ -124,11 +126,11 @@ Feature: Git Log Window Then I should see a "file name header in diff panel" element with selector "h6:has-text('Index.tid')" # Click the Actions tab in the file diff panel (the one that has the file name above it) # We need to find the Actions tab that is a sibling of the h6 containing "Index.tid" - When I click on a "actions tab in file diff panel" element with selector "h6:has-text('Index.tid') ~ div button[role='tab']:has-text('操作'), h6:has-text('Index.tid') ~ div button[role='tab']:has-text('Actions')" + When I click on a "actions tab in file diff panel" element with selector "h6:has-text('Index.tid') ~ div button[role='tab']:has-text('操作')" And I wait for 1 seconds for "actions tab content to render" # Verify the discard changes button exists (only shows for uncommitted changes) - Then I should see a "discard changes button" element with selector "button:has-text('放弃修改'), button:has-text('Discard changes')" - When I click on a "discard changes button" element with selector "button:has-text('放弃修改'), button:has-text('Discard changes')" + Then I should see a "discard changes button" element with selector "button:has-text('放弃修改')" + When I click on a "discard changes button" element with selector "button:has-text('放弃修改')" # Wait for git discard operation to complete And I wait for 2 seconds for "git discard to complete and UI to refresh" # Verify the file is no longer in the uncommitted list (should go back to showing no selection) diff --git a/src/services/wiki/plugin/watchFileSystemAdaptor/FileSystemWatcher.ts b/src/services/wiki/plugin/watchFileSystemAdaptor/FileSystemWatcher.ts index 1b302cfb..8a7f0a39 100644 --- a/src/services/wiki/plugin/watchFileSystemAdaptor/FileSystemWatcher.ts +++ b/src/services/wiki/plugin/watchFileSystemAdaptor/FileSystemWatcher.ts @@ -70,7 +70,7 @@ export class FileSystemWatcher { private readonly boot: typeof $tw.boot; private readonly watchPathBase: string; private readonly workspaceID: string; - private readonly workspaceConfig: IWikiWorkspace | undefined; + private workspaceConfig: IWikiWorkspace | undefined; /** Inverse index for mapping file paths to tiddler information */ private readonly inverseFilesIndex: InverseFilesIndex = new InverseFilesIndex(); @@ -156,6 +156,20 @@ export class FileSystemWatcher { return; } + // Re-fetch workspace config to get the latest enableFileSystemWatch value + // This ensures we pick up config changes that happened after constructor + if (this.workspaceID) { + try { + const latestConfig = await workspace.get(this.workspaceID); + if (latestConfig && typeof latestConfig === 'object') { + this.workspaceConfig = latestConfig as IWikiWorkspace; + this.logger.log(`FileSystemWatcher Re-fetched workspace config, enableFileSystemWatch=${this.workspaceConfig.enableFileSystemWatch}`); + } + } catch (error) { + this.logger.log(`FileSystemWatcher Failed to re-fetch workspace config: ${error instanceof Error ? error.message : String(error)}`); + } + } + // Check if file system watch is enabled for this workspace if (this.workspaceConfig && !this.workspaceConfig.enableFileSystemWatch) { this.logger.log('[test-id-WATCH_FS_STABILIZED] Watcher has stabilized (disabled by config)'); diff --git a/src/windows/GitLog/useGitLogData.ts b/src/windows/GitLog/useGitLogData.ts index 6a18d2fa..b6c811f4 100644 --- a/src/windows/GitLog/useGitLogData.ts +++ b/src/windows/GitLog/useGitLogData.ts @@ -108,7 +108,10 @@ export function useGitLogData(workspaceID: string): IGitLogData { lastRefreshTime.current = now; lastChangeTimestamp.current = change?.timestamp ?? 0; // Store the type of change so we can auto-select first commit after a manual commit - setLastChangeType(change?.type ?? null); + // Don't let file-change events override commit/undo events to preserve auto-selection behavior + if (change?.type !== 'file-change' || !lastChangeType || lastChangeType === 'file-change') { + setLastChangeType(change?.type ?? null); + } // Trigger refresh when git state changes setRefreshTrigger((previous) => previous + 1); }