TagSpaces is an offline, open source, document manager with tagging support
e2e fix
sytolk4c2784ef02ff
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex e49b9af25..8f55efff7 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -586,13 +586,21 @@ function EntryContainer(props: Props) {PlatformIO.getDirSeparator());try {- loadJSONFile(metaFilePath).then(fsEntryMeta => {- updateOpenedFile(openedFile.path, {- ...fsEntryMeta,- editMode: false,- shouldReload: !openedFile.shouldReload- });- });+ loadJSONFile(metaFilePath)+ .then(fsEntryMeta => {+ updateOpenedFile(openedFile.path, {+ ...fsEntryMeta,+ editMode: false,+ shouldReload: !openedFile.shouldReload+ });+ })+ .catch(() =>+ updateOpenedFile(openedFile.path, {+ ...openedFile,+ editMode: false,+ shouldReload: !openedFile.shouldReload+ })+ );} catch (e) {updateOpenedFile(openedFile.path, {...openedFile,diff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.jsindex 77ba3a724..53abd5267 100644--- a/tests/e2e/fileopener.pw.e2e.js+++ b/tests/e2e/fileopener.pw.e2e.js@@ -6,8 +6,8 @@ import {defaultLocationPath} from './location.helpers';import {+ checkSettings,clickOn,- createTxtFile,dnd,expectElementExist,expectFileContain,@@ -135,7 +135,7 @@ test.describe('TST08 - File folder properties', () => {test('TST0805 - Rename opened file [web,minio,electron]', async () => {const fileName = 'sample.txt';- const newTile = 'renamed.txt';+ const newTitle = 'renamed.txt';// set setting PersistTagsInSidecarFile in order to add meta json fileawait setSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);@@ -152,14 +152,14 @@ test.describe('TST08 - File folder properties', () => {expect(propsFileName).toBe(fileName);await clickOn('[data-tid=startRenameEntryTID]');- await setInputValue('[data-tid=fileNameProperties] input', newTile);+ await setInputValue('[data-tid=fileNameProperties] input', newTitle);await clickOn('[data-tid=confirmRenameEntryTID]');await global.client.waitForSelector(- '[data-tid=fileNameProperties] input[value="' + newTile + '"]'+ '[data-tid=fileNameProperties] input[value="' + newTitle + '"]');const propsNewFileName = await getPropertiesFileName();- expect(propsNewFileName).toBe(newTile);+ expect(propsNewFileName).toBe(newTitle);const arrayMeta =global.isWeb || global.isMinio@@ -275,26 +275,36 @@ test.describe('TST08 - File folder properties', () => {});test('TST0813 - Delete file [web,minio,electron]', async () => {- await global.client.dblclick(selectorFolder);-- await createTxtFile();- // await searchEngine('note');- // await waitForNotification();- // await global.client.waitForTimeout(1500); // To do wait for search results- await expectElementExist(selectorFile, true, 5000);+ const fileName = 'empty_file.txt';+ await createFile(fileName);+ await openContextEntryMenu(+ getGridFileSelector('empty_folder'),+ 'showProperties'+ );+ await global.client.dblclick(getGridFileSelector('empty_folder'));+ await expectElementExist(getGridFileSelector(fileName));+ await clickOn(getGridFileSelector(fileName));- // open fileProperties- await clickOn(selectorFile);//Toggle Propertiesawait clickOn('[data-tid=fileContainerToggleProperties]');+ // add meta json to file+ await checkSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);+ await AddRemovePropertiesTags(['test-tag1', 'test-tag2'], {+ add: true,+ remove: false+ });+ const arrayMeta =+ global.isWeb || global.isMinio+ ? [fileName + '.json'] // check meta, thumbnails are not created on web or minio+ : [fileName + '.json', fileName + '.jpg']; // check meta and thumbnail++ await expectMetaFilesExist(arrayMeta, true);- // const propsFileName = await getPropertiesFileName();await clickOn('[data-tid=deleteEntryTID]');await clickOn('[data-tid=confirmSaveBeforeCloseDialog]');- await waitForNotification();- await expectElementExist(selectorFile, false, 2000);- //const firstFileName = await getGridFileName(0);- //expect(propsFileName).not.toBe(firstFileName);+ await expectElementExist(getGridFileSelector(fileName), false, 5000);++ await expectMetaFilesExist(arrayMeta, false);});/**diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 19c48c4bd..59d3071ec 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -640,15 +640,23 @@ export async function expectTagsExist(gridElement, arrTagNames, exist = true) {expect(tags.includes(tagName)).toBe(exist);}}-export async function expectMetaFilesExist(arrMetaFiles) {- await setSettings('[data-tid=settingsSetShowUnixHiddenEntries]');++export async function expectMetaFilesExist(arrMetaFiles, exist = true) {+ await checkSettings('[data-tid=settingsSetShowUnixHiddenEntries]', true);await clickOn('[data-tid=folderContainerOpenDirMenu]');await clickOn('[data-tid=reloadDirectory]');- await global.client.dblclick(getGridFileSelector(AppConfig.metaFolder));- for (let i = 0; i < arrMetaFiles.length; i++) {- await expectElementExist(getGridFileSelector(arrMetaFiles[i]), true);+ if (exist || (await isDisplayed(getGridFileSelector(AppConfig.metaFolder)))) {+ await global.client.dblclick(getGridFileSelector(AppConfig.metaFolder));+ for (let i = 0; i < arrMetaFiles.length; i++) {+ await expectElementExist(+ getGridFileSelector(arrMetaFiles[i]),+ exist,+ 10000+ );+ }+ await checkSettings('[data-tid=settingsSetShowUnixHiddenEntries]', false);+ await clickOn('[data-tid=gridPerspectiveOnBackButton]');}- await setSettings('[data-tid=settingsSetShowUnixHiddenEntries]');}export async function expectFileContain(@@ -671,6 +679,12 @@ export async function expectFileContain(.toBe(true);}+/**+ * @deprecated+ * @param tid+ * @param forceClose+ * @returns {Promise<void>}+ */export async function waitForNotification(tid = 'notificationTID',forceClose = true@@ -698,6 +712,12 @@ export async function waitForNotification(} */}+/**+ * for check settings use checkSettings instead+ * @param selector+ * @param click+ * @returns {Promise<void>}+ */export async function setSettings(selector, click = false) {await clickOn('[data-tid=settings]');if (click) {@@ -710,6 +730,18 @@ export async function setSettings(selector, click = false) {await clickOn('[data-tid=closeSettingsDialog]');}+export async function checkSettings(selector, isChecked = true) {+ await clickOn('[data-tid=settings]');+ if (isChecked) {+ await global.client.check(selector + ' input');+ expect(await global.client.isChecked(selector + ' input')).toBeTruthy();+ } else {+ await global.client.uncheck(selector + ' input');+ expect(await global.client.isChecked(selector + ' input')).not.toBeTruthy();+ }+ await clickOn('[data-tid=closeSettingsDialog]');+}+export async function dnd(originSelector, destinationSelector) {const source = global.client.locator(originSelector);const target = global.client.locator(destinationSelector);@@ -853,11 +885,11 @@ export async function openCloseAboutDialog(title) {await delay(500);}-export async function openSettings(selectedTab) {+/*export async function openSettings(selectedTab) {await global.client.waitForVisible('[data-tid=settings]');await global.client.click('[data-tid=settings]');if (selectedTab) {await global.client.waitForVisible('[data-tid=' + selectedTab + ']');await global.client.click('[data-tid=' + selectedTab + ']');}-}+}*/