From 722e7af3e283821f827cfec04e9c0cf902149392 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 18 Jan 2026 19:45:40 +0000 Subject: [PATCH] Improve tests --- .../src/sync-operations/unrestricted-syncer.ts | 2 +- frontend/test-client/src/agent/mock-agent.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts index 64644416..5514d617 100644 --- a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts +++ b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts @@ -299,7 +299,7 @@ export class UnrestrictedSyncer { remoteVersion.vaultUpdateId ) { this.logger.debug( - `Document ${remoteVersion.relativePath} is already at least as up to date as the fetched version` + `Document ${document.relativePath} is already at least as up-to-date as the fetched version` ); return; diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index abf7da2c..9f9e6a45 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -17,6 +17,7 @@ export class MockAgent extends MockClient { // The renamed file finding algorithm isn't too smart so we can't both update and rename the same file private readonly doNotTouchWhileOffline: string[] = []; + private lastSyncEnabledState: boolean = true; public constructor( initialSettings: Partial, @@ -113,7 +114,7 @@ export class MockAgent extends MockClient { ]; if ( - this.client.getSettings().isSyncEnabled && + this.lastSyncEnabledState && this.doNotTouchWhileOffline.length === 0 ) { options.push(this.disableSyncAction.bind(this)); @@ -287,7 +288,7 @@ export class MockAgent extends MockClient { const file = this.getFileName(); if ( - (!this.client.getSettings().isSyncEnabled && + (!this.lastSyncEnabledState && this.doNotTouchWhileOffline.includes(file)) || (await this.exists(file)) ) { @@ -306,12 +307,14 @@ export class MockAgent extends MockClient { private async disableSyncAction(): Promise { this.client.logger.info(`Decided to disable sync`); + this.lastSyncEnabledState = false; await this.client.setSetting("isSyncEnabled", false); } private async enableSyncAction(): Promise { this.client.logger.info(`Decided to enable sync`); await this.client.setSetting("isSyncEnabled", true); + this.lastSyncEnabledState = true; } private async renameFileAction(files: RelativePath[]): Promise { @@ -320,7 +323,7 @@ export class MockAgent extends MockClient { // We can't edit files offline that have been updated while offline. // Otherwise, the resolution logic couldn't handle it. if ( - !this.client.getSettings().isSyncEnabled && + !this.lastSyncEnabledState && this.doNotTouchWhileOffline.includes(file) ) { this.client.logger.info( @@ -332,7 +335,7 @@ export class MockAgent extends MockClient { const newName = this.getFileName(); if ( - (!this.client.getSettings().isSyncEnabled && + (!this.lastSyncEnabledState && this.doNotTouchWhileOffline.includes(newName)) || (await this.exists(newName)) ) { @@ -351,7 +354,7 @@ export class MockAgent extends MockClient { // We can't edit files offline that have been updated while offline. // Otherwise, the resolution logic couldn't handle it. if ( - !this.client.getSettings().isSyncEnabled && + !this.lastSyncEnabledState && this.doNotTouchWhileOffline.includes(file) ) { this.client.logger.info(