Skip to content

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

add TST0204 - Reload folder from toolbar

sytolk2905cb51146c
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index f49a85c84..43e44a0a7 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -26,7 +26,6 @@ import React, {
} from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
-import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { GlobalHotKeys } from 'react-hotkeys';
import fscreen from 'fscreen';
import Button from '@mui/material/Button';
@@ -60,9 +59,12 @@ import {
} from '-/components/CommonIcons';
import HistoryIcon from '@mui/icons-material/History';
import { Split } from 'ts-react-splitter';
+import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { buffer } from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
import {
+ getMetaFileLocationForDir,
+ getMetaFileLocationForFile,
extractContainingDirectoryPath,
extractTitle,
extractFileExtension,
@@ -105,6 +107,7 @@ import { Switch } from '@mui/material';
import useFirstRender from '-/utils/useFirstRender';
import ResolveConflictDialog from '-/components/dialogs/ResolveConflictDialog';
import { dataTidFormat } from '-/services/test';
+import { getMetaForEntry, loadJSONFile } from '-/services/utils-io';
const defaultSplitSize = '7.86%'; // '7.2%'; // 103;
// const openedSplitSize = AppConfig.isElectron ? 560 : 360;
@@ -574,11 +577,30 @@ function EntryContainer(props: Props) {
// openedFile.changed) {
setSaveBeforeReloadConfirmDialogOpened(true);
} else {
- updateOpenedFile(openedFile.path, {
- ...openedFile,
- editMode: false,
- shouldReload: !openedFile.shouldReload
- });
+ const metaFilePath = openedFile.isFile
+ ? getMetaFileLocationForFile(
+ openedFile.path,
+ PlatformIO.getDirSeparator()
+ )
+ : getMetaFileLocationForDir(
+ openedFile.path,
+ PlatformIO.getDirSeparator()
+ );
+ try {
+ loadJSONFile(metaFilePath).then(fsEntryMeta => {
+ updateOpenedFile(openedFile.path, {
+ ...fsEntryMeta,
+ editMode: false,
+ shouldReload: !openedFile.shouldReload
+ });
+ });
+ } catch (e) {
+ updateOpenedFile(openedFile.path, {
+ ...openedFile,
+ editMode: false,
+ shouldReload: !openedFile.shouldReload
+ });
+ }
}
}
};
@@ -1090,8 +1112,12 @@ function EntryContainer(props: Props) {
)}
<Tooltip title={i18n.t('core:reloadFile')}>
<IconButton
- data-tid="reloadFileTID"
- aria-label={i18n.t('core:reloadFile')}
+ data-tid="reloadPropertiesTID"
+ aria-label={i18n.t(
+ openedFile.isFile
+ ? 'core:reloadFileProperties'
+ : 'core:reloadFolderProperties'
+ )}
onClick={reloadDocument}
size="large"
>
@@ -1185,6 +1211,7 @@ function EntryContainer(props: Props) {
)}
<Tooltip title={i18n.t('core:reloadDirectory')}>
<IconButton
+ data-tid="reloadFolderTID"
aria-label={i18n.t('core:reloadDirectory')}
onClick={reloadDocument}
size="large"
@@ -1210,6 +1237,7 @@ function EntryContainer(props: Props) {
{!isReadOnlyMode && (
<Tooltip title={i18n.t('core:deleteDirectory')}>
<IconButton
+ data-tid="deleteFolderTID"
aria-label={i18n.t('core:deleteDirectory')}
onClick={() => setDeleteEntryModalOpened(true)}
size="large"
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 646e70c78..ad79c3637 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -156,6 +156,8 @@
"duplicateFile": "Duplicate File",
"deleteEntry": "Delete",
"reloadFile": "Reload File",
+ "reloadFileProperties": "Reload File Properties",
+ "reloadFolderProperties": "Reload Folder Properties",
"closeFile": "Close File",
"fileProperties": "Properties",
"editFile": "Edit File",
diff --git a/tests/e2e/file.properties.helpers.js b/tests/e2e/file.properties.helpers.js
index a42585afe..6cc4cd8ad 100644
--- a/tests/e2e/file.properties.helpers.js
+++ b/tests/e2e/file.properties.helpers.js
@@ -2,10 +2,25 @@
import { expect } from '@playwright/test';
import {
expectElementExist,
+ getElementText,
removeTagFromTagMenu,
setInputKeys
} from './general.helpers';
-import { getPropertiesTags } from './location.helpers';
+
+export async function getPropertiesTags() {
+ const arrTags = [];
+ const tags = await global.client.$$(
+ '[data-tid=PropertiesTagsSelectTID] div div div'
+ );
+ for (let i = 0; i < tags.length; i++) {
+ const dataTid = await tags[i].getAttribute('data-tid');
+ if (dataTid && dataTid.startsWith('tagContainer_')) {
+ const label = await tags[i].$('button span');
+ arrTags.push(await getElementText(label));
+ }
+ }
+ return arrTags;
+}
/**
* Add and then Remove tags from file/folder Properties (open Properties first)
diff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.js
index 10a94f50c..7f34debd0 100644
--- a/tests/e2e/fileopener.pw.e2e.js
+++ b/tests/e2e/fileopener.pw.e2e.js
@@ -3,8 +3,7 @@ import {
createPwMinioLocation,
createPwLocation,
defaultLocationName,
- defaultLocationPath,
- getPropertiesTags
+ defaultLocationPath
} from './location.helpers';
import {
clickOn,
@@ -21,7 +20,8 @@ import {
} from './general.helpers';
import {
AddRemovePropertiesTags,
- getPropertiesFileName
+ getPropertiesFileName,
+ getPropertiesTags
} from './file.properties.helpers';
import { openContextEntryMenu } from './test-utils';
import { startTestingApp, stopApp, testDataRefresh } from './hook';
diff --git a/tests/e2e/folderprops.pw.e2e.js b/tests/e2e/folderprops.pw.e2e.js
index a4c7c59c8..d16a6f1ed 100644
--- a/tests/e2e/folderprops.pw.e2e.js
+++ b/tests/e2e/folderprops.pw.e2e.js
@@ -9,22 +9,15 @@ import {
createPwLocation
} from './location.helpers';
import {
- reloadDirectory,
- createNewDirectory,
- deleteDirectory,
clickOn,
expectElementExist,
takeScreenshot,
- selectorFile,
- setInputKeys,
getGridFileSelector
} from './general.helpers';
-import { openContextEntryMenu, renameFolder } from './test-utils';
+import { openContextEntryMenu } from './test-utils';
import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
import { clearDataStorage } from './welcome.helpers';
-import { emptyFolderName } from './search.helpers';
-import { AddRemovePropertiesTags } from './file.properties.helpers';
-import { dataTidFormat } from '../../app/services/test';
+import { getPropertiesTags } from './file.properties.helpers';
test.beforeAll(async () => {
await startTestingApp('extconfig.js');
@@ -50,20 +43,53 @@ test.beforeEach(async () => {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
}
await clickOn('[data-tid=location_' + defaultLocationName + ']');
- // If its have opened file
- // await closeFileProperties();
+
+ await openContextEntryMenu(
+ '[data-tid=fsEntryName_empty_folder]',
+ 'showProperties'
+ );
});
test.describe('TST02 - Folder properties', () => {
test('TST0201 - Open in main area [web,minio,electron]', async () => {
const testFile = 'file_in_empty_folder.txt';
await createFile(testFile);
- await openContextEntryMenu(
- '[data-tid=fsEntryName_empty_folder]',
- 'showProperties'
- );
- await clickOn('[data-tid=openInMainAreaTID]');
+ await clickOn('[data-tid=openInMainAreaTID]');
await expectElementExist(getGridFileSelector(testFile), true, 5000);
});
+
+ test('TST0204 - Reload folder from toolbar [web,minio,electron]', async () => {
+ let propsTags = await getPropertiesTags();
+ expect(propsTags).toHaveLength(0);
+ const tagTitle = 'test-tag';
+ const tsmJson = {
+ appName: 'TagSpaces',
+ appVersion: '5.3.5',
+ description:
+ "**Lorem Ipsum** is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n\n## Why do we use it?\n\nIt is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose \n",
+ lastUpdated: 1684224090695,
+ tags: [
+ {
+ title: 'test-tag',
+ color: '#61DD61',
+ textcolor: 'white',
+ type: 'sidecar'
+ }
+ ],
+ id: '73e839b38d034a4a807971e755c17091'
+ };
+ await createFile('tsm.json', JSON.stringify(tsmJson), 'empty_folder/.ts');
+
+ await clickOn('[data-tid=reloadFolderTID]');
+
+ propsTags = await getPropertiesTags();
+ expect(propsTags).toContain(tagTitle);
+
+ const editor = await global.client.waitForSelector(
+ '[data-tid=descriptionTID] .milkdown'
+ );
+ const description = await editor.innerText();
+ expect(description.replace(/[\s*#]/g, '')).toMatch(tsmJson.description.replace(/[\s*#]/g, ''));
+ });
});
diff --git a/tests/e2e/hook.js b/tests/e2e/hook.js
index 2496596e0..0e021b577 100644
--- a/tests/e2e/hook.js
+++ b/tests/e2e/hook.js
@@ -195,7 +195,8 @@ export async function testDataRefresh() {
export async function createFile(
fileName = 'empty_file.html',
- fileContent = undefined
+ fileContent = undefined,
+ rootFolder = 'empty_folder'
) {
const filePath = pathLib.join(
__dirname,
@@ -203,7 +204,7 @@ export async function createFile(
'testdata-tmp',
'file-structure',
'supported-filestypes',
- 'empty_folder',
+ rootFolder,
fileName
);
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.js
index fd2db5ff3..21d1655dc 100644
--- a/tests/e2e/location.helpers.js
+++ b/tests/e2e/location.helpers.js
@@ -192,20 +192,6 @@ export async function getFirstFileName() {
return fileName;
}
-export async function getPropertiesTags() {
- const arrTags = [];
- const tags = await global.client.$$(
- '[data-tid=PropertiesTagsSelectTID] div div div'
- );
- for (let i = 0; i < tags.length; i++) {
- const dataTid = await tags[i].getAttribute('data-tid');
- if (dataTid && dataTid.startsWith('tagContainer_')) {
- const label = await tags[i].$('button span');
- arrTags.push(await getElementText(label));
- }
- }
- return arrTags;
-}
/*export async function checkForValidExt(selector, ext) {
const getExt = await global.client