TagSpaces is an offline, open source, document manager with tagging support
e2e fixes in fileopener.pw.e2e.js
sytolk2b67e1f6bbc8
diff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.jsindex 003b45748..77ba3a724 100644--- a/tests/e2e/fileopener.pw.e2e.js+++ b/tests/e2e/fileopener.pw.e2e.js@@ -10,6 +10,8 @@ import {createTxtFile,dnd,expectElementExist,+ expectFileContain,+ expectMetaFilesExist,getGridFileName,getGridFileSelector,selectorFile,@@ -26,7 +28,7 @@ import {getPropertiesTags} from './file.properties.helpers';import { openContextEntryMenu } from './test-utils';-import { startTestingApp, stopApp, testDataRefresh } from './hook';+import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';import { clearDataStorage } from './welcome.helpers';import { dataTidFormat } from '../../app/services/test';@@ -37,7 +39,7 @@ test.beforeAll(async () => {test.afterAll(async () => {await stopApp();- await testDataRefresh();+ // await testDataRefresh();});test.afterEach(async ({ page }, testInfo) => {@@ -45,6 +47,7 @@ test.afterEach(async ({ page }, testInfo) => {await takeScreenshot(testInfo);}await clearDataStorage();+ await testDataRefresh();});test.beforeEach(async () => {@@ -131,38 +134,48 @@ test.describe('TST08 - File folder properties', () => {});test('TST0805 - Rename opened file [web,minio,electron]', async () => {+ const fileName = 'sample.txt';const newTile = 'renamed.txt';- // await searchEngine('txt');+ // set setting PersistTagsInSidecarFile in order to add meta json file+ await setSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);+// open fileProperties- await clickOn(selectorFile);+ await clickOn(getGridFileSelector(fileName));//Toggle Propertiesawait clickOn('[data-tid=fileContainerToggleProperties]');+ await AddRemovePropertiesTags(['test-tag1', 'test-tag2'], {+ add: true,+ remove: false+ });const propsFileName = await getPropertiesFileName();+ expect(propsFileName).toBe(fileName);+await clickOn('[data-tid=startRenameEntryTID]');- // await setInputKeys('fileNameProperties', newTile);await setInputValue('[data-tid=fileNameProperties] input', newTile);await clickOn('[data-tid=confirmRenameEntryTID]');- // await waitForNotification();- // await isDisplayed('[data-tid=confirmRenameEntryTID]', false);+await global.client.waitForSelector('[data-tid=fileNameProperties] input[value="' + newTile + '"]');const propsNewFileName = await getPropertiesFileName();- expect(propsFileName).not.toBe(propsNewFileName);+ expect(propsNewFileName).toBe(newTile);++ const arrayMeta =+ global.isWeb || global.isMinio+ ? [propsNewFileName + '.json'] // check meta file renamed, thumbnails are not created on web or minio+ : [propsNewFileName + '.json', propsNewFileName + '.jpg']; // check meta and thumbnail renamed+ await expectMetaFilesExist(arrayMeta);//turn fileName back- await clickOn('[data-tid=startRenameEntryTID]');- // await setInputKeys('fileNameProperties', propsFileName);+ /*await clickOn('[data-tid=startRenameEntryTID]');await setInputValue('[data-tid=fileNameProperties] input', propsFileName);await clickOn('[data-tid=confirmRenameEntryTID]');- // await waitForNotification();- // await isDisplayed('[data-tid=confirmRenameEntryTID]', false);await global.client.waitForSelector('[data-tid=fileNameProperties] input[value="' + propsFileName + '"]');const propsOldFileName = await getPropertiesFileName();- expect(propsOldFileName).toBe(propsFileName);+ expect(propsOldFileName).toBe(propsFileName);*/});test.skip('TST0806 - Download file [manual]', async () => {});@@ -246,13 +259,19 @@ test.describe('TST08 - File folder properties', () => {/*** reload file button not visible on electron (github app size specific)*/- test('TST0812 - Reload file [web,minio]', async () => {+ test('TST0812 - Reload file [web,minio,electron]', async () => {// open fileProperties- await clickOn(selectorFile);+ await clickOn(getGridFileSelector('sample.txt'));//Toggle Propertiesawait clickOn('[data-tid=fileContainerToggleProperties]');- await clickOn('[data-tid=reloadFileTID]');- // TODO externally change the file to check if its reloaded++ await expectFileContain();++ const newFileContent = 'testing_file_content';+ await createFile('sample.txt', newFileContent, '.');++ await clickOn('[data-tid=reloadPropertiesTID]');+ await expectFileContain(newFileContent);});test('TST0813 - Delete file [web,minio,electron]', async () => {diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex aa132a38a..19c48c4bd 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -2,7 +2,7 @@import path from 'path';import { expect } from '@playwright/test';import { delay } from './hook';-import { firstFile } from './test-utils';+import { firstFile, toContainTID } from './test-utils';import AppConfig from '../../app/AppConfig';import { dataTidFormat } from '../../app/services/test';@@ -640,6 +640,36 @@ export async function expectTagsExist(gridElement, arrTagNames, exist = true) {expect(tags.includes(tagName)).toBe(exist);}}+export async function expectMetaFilesExist(arrMetaFiles) {+ await setSettings('[data-tid=settingsSetShowUnixHiddenEntries]');+ 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);+ }+ await setSettings('[data-tid=settingsSetShowUnixHiddenEntries]');+}++export async function expectFileContain(+ txtToContain = 'etete&5435',+ timeout = 10000+) {+ await expect+ .poll(+ async () => {+ const fLocator = await frameLocator();+ const bodyTxt = await fLocator.locator('body').innerText();+ return toContainTID(bodyTxt, [txtToContain]);+ },+ {+ message: 'make sure bodyTxt contain ' + txtToContain, // custom error message+ // Poll for 10 seconds; defaults to 5 seconds. Pass 0 to disable timeout.+ timeout: timeout+ }+ )+ .toBe(true);+}export async function waitForNotification(tid = 'notificationTID',diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex 0e021b577..0d6e943c9 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -186,11 +186,8 @@ export async function testDataRefresh() {const dst = pathLib.join(__dirname, '..', 'testdata-tmp', 'file-structure');let newPath = pathLib.join(dst, pathLib.basename(src));- fse.emptyDirSync(newPath);- fse.copySync(src, newPath, { overwrite: true });- /*if (global.isElectron && global.client) {- await global.client.waitForTimeout(1000);- }*/+ await fse.emptyDir(newPath);+ await fse.copy(src, newPath); //, { overwrite: true });}export async function createFile(diff --git a/tests/e2e/test-utils.js b/tests/e2e/test-utils.jsindex 37b4d9b2d..bbf5c8767 100644--- a/tests/e2e/test-utils.js+++ b/tests/e2e/test-utils.js@@ -31,9 +31,8 @@ export async function checkFilenameForExist(filename, selector) {expect(fileTxt).toBe(filename);}-export function toContainTID(text) {+export function toContainTID(text, tids = ['etete&5435']) {let pass = false;- const tids = ['etete&5435'];tids.forEach(tid => {pass = text.indexOf(tid) !== -1;});