Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: fixing e2e test for revisions

Ilian Sapundshievb3c9a1c1cd63
diff --git a/src/renderer/components/dialogs/hooks/ResolveConflictContextProvider.tsx b/src/renderer/components/dialogs/hooks/ResolveConflictContextProvider.tsx
index 7f690ca48..f865818cf 100644
--- a/src/renderer/components/dialogs/hooks/ResolveConflictContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/ResolveConflictContextProvider.tsx
@@ -151,28 +151,34 @@ export const ResolveConflictContextProvider = ({
fileOpen.isFile,
);
const backupDir = getBackupFileDir(fileOpen.path, fileOpen.uuid);
- location.listDirectoryPromise(backupDir, []).then(async (backup) => {
+ // Preserve the pre-edit (original) content as the first revision.
+ // This MUST be awaited: leaving it fire-and-forget (a) risks losing
+ // the original version if the user navigates/closes before the copy
+ // lands, and (b) races the post-save tab recompute so the Revisions
+ // tab never appears on slower / object-store (S3) locations —
+ // haveRevisions()'s single checkDirExist() runs before the backup
+ // dir is durable. See fileopener TST0829.
+ try {
+ const backup = await location.listDirectoryPromise(backupDir, []);
const haveBackup = backup.some((b) =>
b.path.endsWith(fileOpen.extension),
);
if (!haveBackup) {
- try {
- const targetPath = getBackupFileLocation(
- fileOpen.path,
- id,
- location.getDirSeparator(),
- );
- await copyFilePromiseOverwrite(
- fileOpen.path,
- targetPath,
- fileOpen.locationID,
- false,
- );
- } catch (error) {
- console.log('copyFilePromiseOverwrite', error);
- }
+ const originalRevisionPath = getBackupFileLocation(
+ fileOpen.path,
+ id,
+ location.getDirSeparator(),
+ );
+ await copyFilePromiseOverwrite(
+ fileOpen.path,
+ originalRevisionPath,
+ fileOpen.locationID,
+ false,
+ );
}
- });
+ } catch (error) {
+ console.log('creating initial revision backup failed', error);
+ }
// wait 5ms in order ot get older timestamp
await new Promise((resolve) => setTimeout(resolve, 5));
const targetPath = getBackupFileLocation(
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index 0b69670bc..a3480bfbd 100644
--- a/tests/e2e/general.helpers.js
+++ b/tests/e2e/general.helpers.js
@@ -789,11 +789,14 @@ export async function createRevision(
await clickOn('[data-tid=fileContainerSaveFile]');
await clickOn('[data-tid=cancelEditingTID]');
- if (await isDisplayed('[data-tid=viewRevisionTID]', false, 3000)) {
- //Toggle Revisions
+ // The Revisions tab is rendered only once the just-created backup dir
+ // is detected; on object-store/remote (S3) locations that can lag the
+ // save. Wait for the tab to mount before clicking, unless a revision
+ // row is already visible.
+ if (!(await isDisplayed('[data-tid=viewRevisionTID]', true, 1000))) {
+ await expectElementExist('[data-tid=revisionsTabTID]', true, 15000);
await clickOn('[data-tid=revisionsTabTID]');
}
- //await clickOn('[data-tid=revisionsTID]');
await expectElementExist('[data-tid=viewRevisionTID]');
}