Improve tests
This commit is contained in:
parent
f53ac121e8
commit
722e7af3e2
2 changed files with 9 additions and 6 deletions
|
|
@ -299,7 +299,7 @@ export class UnrestrictedSyncer {
|
||||||
remoteVersion.vaultUpdateId
|
remoteVersion.vaultUpdateId
|
||||||
) {
|
) {
|
||||||
this.logger.debug(
|
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;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -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
|
// 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 readonly doNotTouchWhileOffline: string[] = [];
|
||||||
|
private lastSyncEnabledState: boolean = true;
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
initialSettings: Partial<SyncSettings>,
|
initialSettings: Partial<SyncSettings>,
|
||||||
|
|
@ -113,7 +114,7 @@ export class MockAgent extends MockClient {
|
||||||
];
|
];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.client.getSettings().isSyncEnabled &&
|
this.lastSyncEnabledState &&
|
||||||
this.doNotTouchWhileOffline.length === 0
|
this.doNotTouchWhileOffline.length === 0
|
||||||
) {
|
) {
|
||||||
options.push(this.disableSyncAction.bind(this));
|
options.push(this.disableSyncAction.bind(this));
|
||||||
|
|
@ -287,7 +288,7 @@ export class MockAgent extends MockClient {
|
||||||
const file = this.getFileName();
|
const file = this.getFileName();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!this.client.getSettings().isSyncEnabled &&
|
(!this.lastSyncEnabledState &&
|
||||||
this.doNotTouchWhileOffline.includes(file)) ||
|
this.doNotTouchWhileOffline.includes(file)) ||
|
||||||
(await this.exists(file))
|
(await this.exists(file))
|
||||||
) {
|
) {
|
||||||
|
|
@ -306,12 +307,14 @@ export class MockAgent extends MockClient {
|
||||||
|
|
||||||
private async disableSyncAction(): Promise<void> {
|
private async disableSyncAction(): Promise<void> {
|
||||||
this.client.logger.info(`Decided to disable sync`);
|
this.client.logger.info(`Decided to disable sync`);
|
||||||
|
this.lastSyncEnabledState = false;
|
||||||
await this.client.setSetting("isSyncEnabled", false);
|
await this.client.setSetting("isSyncEnabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async enableSyncAction(): Promise<void> {
|
private async enableSyncAction(): Promise<void> {
|
||||||
this.client.logger.info(`Decided to enable sync`);
|
this.client.logger.info(`Decided to enable sync`);
|
||||||
await this.client.setSetting("isSyncEnabled", true);
|
await this.client.setSetting("isSyncEnabled", true);
|
||||||
|
this.lastSyncEnabledState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async renameFileAction(files: RelativePath[]): Promise<void> {
|
private async renameFileAction(files: RelativePath[]): Promise<void> {
|
||||||
|
|
@ -320,7 +323,7 @@ export class MockAgent extends MockClient {
|
||||||
// We can't edit files offline that have been updated while offline.
|
// We can't edit files offline that have been updated while offline.
|
||||||
// Otherwise, the resolution logic couldn't handle it.
|
// Otherwise, the resolution logic couldn't handle it.
|
||||||
if (
|
if (
|
||||||
!this.client.getSettings().isSyncEnabled &&
|
!this.lastSyncEnabledState &&
|
||||||
this.doNotTouchWhileOffline.includes(file)
|
this.doNotTouchWhileOffline.includes(file)
|
||||||
) {
|
) {
|
||||||
this.client.logger.info(
|
this.client.logger.info(
|
||||||
|
|
@ -332,7 +335,7 @@ export class MockAgent extends MockClient {
|
||||||
const newName = this.getFileName();
|
const newName = this.getFileName();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!this.client.getSettings().isSyncEnabled &&
|
(!this.lastSyncEnabledState &&
|
||||||
this.doNotTouchWhileOffline.includes(newName)) ||
|
this.doNotTouchWhileOffline.includes(newName)) ||
|
||||||
(await this.exists(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.
|
// We can't edit files offline that have been updated while offline.
|
||||||
// Otherwise, the resolution logic couldn't handle it.
|
// Otherwise, the resolution logic couldn't handle it.
|
||||||
if (
|
if (
|
||||||
!this.client.getSettings().isSyncEnabled &&
|
!this.lastSyncEnabledState &&
|
||||||
this.doNotTouchWhileOffline.includes(file)
|
this.doNotTouchWhileOffline.includes(file)
|
||||||
) {
|
) {
|
||||||
this.client.logger.info(
|
this.client.logger.info(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue