TagSpaces is an offline, open source, document manager with tagging support
fix: correcting e2e test TST1009 / TST1010
Ilian Sapundshiev0230745dd7fe
diff --git a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsxindex 466c57699..9be8a0f57 100644--- a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx+++ b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx@@ -175,6 +175,22 @@ function MoveCopyFilesDialog(props: Props) {.map((fsentry) => fsentry.path): [];+ // Surface the progress dialog when the work might take a perceptible+ // amount of time. Any folder copy/move qualifies (size unknown until+ // we walk it). For file selections: 2+ files, or a single file large+ // enough that the copy isn't instant. 50 MiB is a conservative cut —+ // ~200 ms on a fast SSD, multiple seconds on HDD / network drives.+ const PROGRESS_DIALOG_BYTE_THRESHOLD = 50 * 1024 * 1024;+ const selectedFileBytes = currentEntries+ ? currentEntries+ .filter((e) => e.isFile)+ .reduce((sum, e) => sum + (e.size || 0), 0)+ : 0;+ const shouldShowProgress =+ selectedDirs.length > 0 ||+ selectedFiles.length > 1 ||+ selectedFileBytes > PROGRESS_DIALOG_BYTE_THRESHOLD;+// Android can't move directories; if the selection includes dirs, force copy mode.const moveDisallowed = AppConfig.isAndroid && selectedDirs.length > 0;const [mode, setModeState] = useState<'move' | 'copy'>(@@ -252,19 +268,23 @@ function MoveCopyFilesDialog(props: Props) {}function handleCopy() {- if (!skipTargetPicker) {+ // The dialog also auto-opens on a 0→N progress transition (see+ // FileUploadDialogContextProvider), so suppress onProgress when we+ // decided NOT to surface the dialog — keeps both surfaces in sync.+ const progressCb =+ !skipTargetPicker && shouldShowProgress ? onUploadProgress : undefined;+ if (!skipTargetPicker && shouldShowProgress) {dispatch(AppActions.resetProgress());openFileUploadDialog(targetDir, 'copyEntriesTitle');}if (selectedFiles.length > 0) {//todo use uploadFilesAPI && transferMeta = trueconst filePaths = selectedFiles;- const onProgress = skipTargetPicker ? undefined : onUploadProgress;const copyPromise = copyFiles(filePaths,targetPath,targetLocation.uuid,- onProgress,+ progressCb,);if (skipTargetPicker) {Promise.resolve(copyPromise).then((success) => {@@ -281,7 +301,7 @@ function MoveCopyFilesDialog(props: Props) {getEntriesCount(selectedDirs),targetPath,targetLocation.uuid,- skipTargetPicker ? undefined : onUploadProgress,+ progressCb,);}onClose(true);@@ -292,10 +312,10 @@ function MoveCopyFilesDialog(props: Props) {};function handleMove() {- if (- !skipTargetPicker &&- (selectedFiles.length > 0 || selectedDirs.length > 0)- ) {+ // See handleCopy for the gating rationale.+ const progressCb =+ !skipTargetPicker && shouldShowProgress ? onUploadProgress : undefined;+ if (!skipTargetPicker && shouldShowProgress) {dispatch(AppActions.resetProgress());openFileUploadDialog(targetDir, 'moveEntriesTitle');}@@ -305,7 +325,7 @@ function MoveCopyFilesDialog(props: Props) {filePaths,targetPath,targetLocation.uuid,- skipTargetPicker ? undefined : onUploadProgress,+ progressCb,true,true,);@@ -325,7 +345,7 @@ function MoveCopyFilesDialog(props: Props) {getEntriesCount(selectedDirs),targetPath,targetLocation.uuid,- skipTargetPicker ? undefined : onUploadProgress,+ progressCb,);}onClose(true);diff --git a/tests/e2e/move-copy-dialog.pw.e2e.js b/tests/e2e/move-copy-dialog.pw.e2e.jsindex ecd8ddd76..e8fab344b 100644--- a/tests/e2e/move-copy-dialog.pw.e2e.js+++ b/tests/e2e/move-copy-dialog.pw.e2e.js@@ -240,6 +240,16 @@ test.describe('TST10 - Move/Copy dialog new features', () => {// ships with ~69 sample files — enough to exercise the pool but small// enough that the copy completes in seconds, not minutes).await selectAllFiles();+ // gridPerspectiveSelectAllFiles is "select all entries" — it includes+ // dirs too. Deselect destName (the freshly-created destination folder+ // sitting at the root); otherwise the dialog's cyclic-target guard sees+ // it in `selectedDirs` and disables `confirmCopyFiles` when we descend+ // into destName as the target. The CardHeader's avatar span is the+ // selection toggle — same shape selectRowFiles uses (NOT `div button`,+ // which lands on the entry's three-dots context-menu trigger).+ await clickOn(+ `[data-tid="fsEntryName_${destName}"] div:nth-child(3) div span`,+ );// Open the bulk move/copy dialog via the toolbar action.await clickOn('[data-tid=gridPerspectiveCopySelectedFiles]');@@ -327,6 +337,11 @@ test.describe('TST10 - Move/Copy dialog new features', () => {await expectElementExist(getGridFileSelector(destName), true, 10000);await selectAllFiles();+ // Deselect destName so the cyclic-target guard doesn't disable the+ // primary CTA — see the same note in TST1009.+ await clickOn(+ `[data-tid="fsEntryName_${destName}"] div:nth-child(3) div span`,+ );await clickOn('[data-tid=gridPerspectiveCopySelectedFiles]');await clickOnIfVisible('[data-tid=mcfModeCopy]');await expectElementExist('[data-tid=confirmCopyFiles]', true, 5000);@@ -351,16 +366,16 @@ test.describe('TST10 - Move/Copy dialog new features', () => {// remain in the store so the indicator can read it.await clickOn('[data-tid=closeFileUploadTID]');- // Dialog is gone (no Close/Clear visible).- await expectElementExist(- '[data-tid=uploadCloseAndClearTID]',- false,- 3000,- );-+ // Dropped the previous `expectElementExist(uploadCloseAndClearTID,+ // false, ...)` check — `<Dialog keepMounted>` keeps the button attached+ // even when minimized, and the helper's "exists=false" path waits for+ // DOM detachment, so it can never go true. Indicator visibility below+ // is the load-bearing assertion anyway.+ //// The background-process indicator next to the search bar is now the// only surface showing progress. It only renders when `progress.length- // > 0`, so its presence after minimize is the load-bearing assertion.+ // > 0`, so its presence after minimize proves the minimize wiring kept+ // progress state intact (didn't fire a stray resetProgress).await expectElementExist('#progressButton', true, 10000);// Click the indicator to restore the dialog.