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.
This commit is contained in:
lin onetwo 2026-01-05 23:46:22 +08:00
parent fe66b9ecb9
commit 3d672a392b
3 changed files with 26 additions and 7 deletions

View file

@ -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)

View file

@ -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)');

View file

@ -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);
}