TagSpaces is an offline, open source, document manager with tagging support
add perspective-grid.pw.e2e.js (#1488)
Stanimir15a72c2fd07c
diff --git a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsxindex 179f5e14c..90e5b1cbc 100644--- a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx+++ b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx@@ -131,6 +131,7 @@ const GridSettingsDialog = (props: Props) => {<FormControlLabelcontrol={<Switch+ data-tid="gridPerspectiveToggleShowDirectories"checked={showDirectories}onChange={toggleShowDirectories}name="checkedB"@@ -142,6 +143,7 @@ const GridSettingsDialog = (props: Props) => {<FormControlLabelcontrol={<Switch+ data-tid="gridPerspectiveToggleShowTags"checked={showTags}onChange={toggleShowTags}name="checkedB"diff --git a/package.json b/package.jsonindex e4629a511..48c7a7345 100644--- a/package.json+++ b/package.json@@ -92,7 +92,7 @@"test-one": "cross-env HEADLESS_MODE=true jest --detectOpenHandles --config=jest.config.web.js -t 'TST5016' --runInBand --verbose ./tests/e2e/","test-playwright": "yarn test-refresh-data && cross-env JEST_JUNIT_OUTPUT_DIR=./tests DISABLE_WORKER=true NODE_ENV=test jest --config=jest.config.playwright.js -t 'electron' --verbose ./tests/e2e/","test-refresh-data": "rimraf tests/testdata-tmp && shx mkdir -p tests/testdata-tmp/file-structure && shx cp -rL tests/testdata/file-structure tests/testdata-tmp",- "test-playwright-web": "yarn test-refresh-data && cross-env DEBUG=pw:api PLAYWRIGHT=test_playwright jest --config=jest.config.web.js -t 'web' --verbose ./tests/e2e/",+ "test-playwright-web": "yarn test-refresh-data && cross-env SHOW_CONSOLE=true DEBUG=pw:api PLAYWRIGHT=test_playwright jest --config=jest.config.web.js -t 'web' --verbose ./tests/e2e/","test-playwright-web-headless": "yarn test-refresh-data && cross-env JEST_JUNIT_OUTPUT_DIR=./tests PLAYWRIGHT=test_playwright HEADLESS_MODE=true jest --config=jest.config.web.js -t 'web' --verbose ./tests/e2e/","playwright-show-trace": "npx playwright show-trace \"tests/test-reports/TST0813 - Delete file [web,minio,electron].zip\"","test-one-suite-headless": "cross-env HEADLESS_MODE=true jest --config=jest.config.web.js --verbose ./tests/e2e/fileopener.e2e.js",diff --git a/tests/e2e/fileopener.e2e.js b/tests/e2e/fileopener.e2e.jsindex 0f49095ab..ea2c4168c 100644--- a/tests/e2e/fileopener.e2e.js+++ b/tests/e2e/fileopener.e2e.js@@ -220,6 +220,7 @@ describe('TST08 - File folder properties', () => {await expectElementExist('[data-tid=fullscreenTID]', true);await clickOn('[data-tid=fullscreenTID]');await expectElementExist('[data-tid=fullscreenTID]', false);+ await global.client.waitForTimeout(500);});it.skip('TST0815 - Test opening file, while TS is in fullscreen(F11) [manual]', async () => {});diff --git a/tests/e2e/folder.pw.e2e.js b/tests/e2e/folder.pw.e2e.jsnew file mode 100644index 000000000..15a82f436--- /dev/null+++ b/tests/e2e/folder.pw.e2e.js@@ -0,0 +1,111 @@+/*+ * Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.+ */+import {+ defaultLocationPath,+ defaultLocationName,+ createPwMinioLocation,+ createPwLocation+} from './location.helpers';+import {+ reloadDirectory,+ createNewDirectory,+ deleteDirectory,+ clickOn,+ expectElementExist+} from './general.helpers';+import { renameFolder } from './test-utils';+import { startTestingApp, stopSpectronApp, testDataRefresh } from './hook';++// export const firstFile = '/span';+// export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';+// const newDirectoryName = 'newDirectory';++describe('TST01 - Folder management', () => {+ beforeAll(async () => {+ await startTestingApp('extconfig-with-welcome.js');+ });++ afterAll(async () => {+ await stopSpectronApp();+ await testDataRefresh();+ });+ beforeEach(async () => {+ if (global.isMinio) {+ await createPwMinioLocation('', defaultLocationName, true);+ } else {+ await createPwLocation(defaultLocationPath, defaultLocationName, true);+ }+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ // If its have opened file+ // await closeFileProperties();+ });++ it('TST0101 - Create subfolder [web,minio,electron]', async () => {+ const testFolder = await createNewDirectory();+ await expectElementExist('[data-tid=fsEntryName_' + testFolder + ']');+ await global.client.dblclick('[data-tid=fsEntryName_' + testFolder + ']');+ await deleteDirectory();+ await expectElementExist(+ '[data-tid=fsEntryName_' + testFolder + ']',+ false+ );+ });++ it('TST0102 - Reload folder [web,minio,electron]', async () => {+ const testFolder = await createNewDirectory();+ await global.client.dblclick('[data-tid=fsEntryName_' + testFolder + ']');+ await reloadDirectory();+ await deleteDirectory();+ await expectElementExist(+ '[data-tid=fsEntryName_' + testFolder + ']',+ false+ );+ });++ it('TST0103 - Rename folder [web,minio,electron]', async () => {+ const testFolder = await createNewDirectory();+ await global.client.dblclick('[data-tid=fsEntryName_' + testFolder + ']');+ const newDirectoryName = await renameFolder();+ await clickOn('[data-tid=gridPerspectiveOnBackButton]');+ await expectElementExist('[data-tid=fsEntryName_' + newDirectoryName + ']');+ // cleanup+ await global.client.dblclick(+ '[data-tid=fsEntryName_' + newDirectoryName + ']'+ );+ await deleteDirectory();+ await expectElementExist(+ '[data-tid=fsEntryName_' + newDirectoryName + ']',+ false+ );+ });++ it('TST0104 - Delete empty folder [web,minio,electron]', async () => {+ // await setSettings('[data-tid=settingsSetUseTrashCan]');+ // await global.client.pause(500);+ const testFolder = await createNewDirectory();+ await expectElementExist('[data-tid=fsEntryName_' + testFolder + ']');+ await global.client.dblclick('[data-tid=fsEntryName_' + testFolder + ']');+ await deleteDirectory();+ await expectElementExist(+ '[data-tid=fsEntryName_' + testFolder + ']',+ false+ );+ });++ it.skip('TST0105 - Show folder tags [electron, TODO]', async () => {});++ it.skip('TST0106 - Show folder tags [TODO]', async () => {+ // await createNewDirectory();+ });++ it.skip('TST0107 - Show in file manager [manual]', async () => {});++ it.skip('TST0108 - Show directory properties [electron, TODO]', async () => {});++ it.skip('TST0109 - Delete non empty folder by disabled trashcan should not be possible [electron, TODO]', async () => {});++ it.skip('TST0110 - Delete not empty folder to trashcan [electron, TODO]', async () => {});++ it.skip('TST0111 - Open parent directory [electron, TODO]', async () => {});+});diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex bd2eef623..7dc03a6be 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -72,6 +72,9 @@ export async function waitUntilClassChanged(selector, className) {return await element.getAttribute('class');}+/**+ * @deprecated Spectron specific use await global.client.dblclick(selector);+ */export async function doubleClickOn(selector) {const element = await global.client.$(selector);await element.waitUntil(@@ -108,6 +111,9 @@ export async function setInputValue(selector, value) {}}+/*+ * @deprecated spectron specific use setInputKeys instead+ */export async function addInputKeys(tid, value) {const element = await global.client.$('[data-tid=' + tid + ']');await element.waitUntil(@@ -141,7 +147,6 @@ export async function addInputKeys(tid, value) {}/**- * TODO not work in Playwright* @param tid* @param value* @param delay@@ -150,9 +155,13 @@ export async function addInputKeys(tid, value) {export async function setInputKeys(tid, value, delay = 50) {if (isPlaywright) {// global.client.keyboard.type('[data-tid=' + tid + '] input', value, { delay: 100 });+ const oldValue = await global.client.inputValue(+ '[data-tid=' + tid + '] input'+ );await global.client.type('[data-tid=' + tid + '] input', value, {delay});+ return oldValue;} else {return await setSelectorKeys('[data-tid=' + tid + ']', value);}@@ -253,6 +262,28 @@ export async function getElementText(el) {return await el.getText();}+export async function isElementDisplayed(+ element,+ displayed = true,+ timeout = 500+) {+ try {+ const el = await element.waitForSelector(selector, {+ timeout,+ state: displayed ? 'visible' : 'detached'+ });+ if (!displayed) {+ if (el === null) {+ return true;+ }+ }+ return el !== null;+ } catch (error) {+ console.log('isElementDisplayed error', error);+ }+ return false;+}+export async function isDisplayed(selector, displayed = true, timeout = 500) {if (global.isPlaywright) {try {@@ -267,7 +298,7 @@ export async function isDisplayed(selector, displayed = true, timeout = 500) {}return el !== null;} catch (error) {- console.log('The FileProperties not open:' + selector);+ console.log('The isDisplayed:' + selector);}return false;}@@ -276,18 +307,20 @@ export async function isDisplayed(selector, displayed = true, timeout = 500) {}export async function getGridElement(fileIndex = 0) {- const filesList = await global.client.$$(selectorFile);- if (filesList.length > 0) {- let file =- fileIndex < 0- ? filesList[filesList.length + fileIndex]- : filesList[fileIndex];- // await file.waitForDisplayed({ timeout: 5000 });- file = await file.$('div');- file = await file.$('div');- return file;- } else {- console.log("Can't getGridElement:" + fileIndex + ' filesList is empty');+ if (await isDisplayed(selectorFile)) {+ const filesList = await global.client.$$(selectorFile);+ if (filesList.length > 0) {+ let file =+ fileIndex < 0+ ? filesList[filesList.length + fileIndex]+ : filesList[fileIndex];+ // await file.waitForDisplayed({ timeout: 5000 });+ file = await file.$('div');+ file = await file.$('div');+ return file;+ } else {+ console.log("Can't getGridElement:" + fileIndex + ' filesList is empty');+ }}return undefined;}@@ -378,62 +411,100 @@ export async function createTxtFile() {await waitForNotification();}+export async function showDirectories(show = true) {+ //open Option menu+ await clickOn('[data-tid=gridPerspectiveOptionsMenu]');+ if (show) {+ await global.client.check(+ '[data-tid=gridPerspectiveToggleShowDirectories] input'+ );+ } else {+ await global.client.uncheck(+ '[data-tid=gridPerspectiveToggleShowDirectories] input'+ );+ }+ await clickOn('[data-tid=cancelDialog]');+}/**** @param classNotSelected* @returns {Promise<void>} classSelected*/-export async function selectAllFiles(classNotSelected) {- await clickOn('[data-tid=gridPerspectiveOptionsMenu]');+export async function selectAllFiles() {+ //classNotSelected) {+ // await clickOn('[data-tid=gridPerspectiveOptionsMenu]');// todo temp fix: is not clickable- await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');- await global.client.pause(500);+ // await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');//SelectAllFilesawait clickOn('[data-tid=gridPerspectiveSelectAllFiles]');- return await waitUntilClassChanged(+ // await expectElementExist('[class="' + classNotSelected + '"]', false, 1000);+ // return await global.client.$(selectorFile + '/div/div').getAttribute('class');+ /*return await waitUntilClassChanged(selectorFile + '/div/div',classNotSelected- );+ );*/}export async function selectFilesByID(arrEntryIds = []) {- await global.client.pause(500);await clickOn('[data-tid=gridPerspectiveSwitchLayoutToRow]');for (let i = 0; i < arrEntryIds.length; i++) {- let entry = await global.client.$(+ await clickOn(+ 'div[data-entry-id="' + arrEntryIds[i] + '"] div[data-tid=rowCellTID]'+ );+ /*let entry = await global.client.$('[data-entry-id="' + arrEntryIds[i] + '"]');entry = await entry.$('[data-tid=rowCellTID]');- await entry.click();+ await entry.click();*/}await clickOn('[data-tid=gridPerspectiveSwitchLayoutToGrid]');}+/**+ * TODO element 0 is not clickable+ * @param arrIndex+ * @returns {Promise<*>}+ */export async function selectRowFiles(arrIndex = []) {- await global.client.pause(500);await clickOn('[data-tid=gridPerspectiveSwitchLayoutToRow]');// const filesList = await global.client.$('[data-tid=perspectiveGridFileTable]');const filesList = await global.client.$$('[data-tid=rowCellTID]');const arrElements = [];- for (let i = 0; i < arrIndex.length; i++) {- const index =- arrIndex[i] < 0 ? filesList.length + arrIndex[i] : arrIndex[i];- if (filesList[index]) {- let parent = await filesList[index].$('..');- parent = await parent.$('..');- parent = await parent.$('..');- arrElements.push(await parent.getAttribute('data-entry-id'));- filesList[index].click();- } else {- console.log(- 'selectRowFiles filesList.length:' +- filesList.length +- ' with index:' +- index +- ' not exist'- );+ if (filesList.length > 0) {+ for (let i = 0; i < arrIndex.length; i++) {+ const index =+ arrIndex[i] < 0 ? filesList.length + arrIndex[i] : arrIndex[i];+ if (filesList[index]) {+ let parent = await filesList[index].$('..');+ parent = await parent.$('..');+ parent = await parent.$('..');+ const id = await parent.getAttribute('data-entry-id');+ arrElements.push(id);+ // const classNotSelected = await parent.getAttribute('class');+ // const elNotSelected = await parent.$('//*[@class="' + classNotSelected + '"]');+ await clickOn(+ 'div[data-entry-id="' + id + '"] div[data-tid=rowCellTID]'+ );+ // filesList[index].click();+ //const selector = '//*[@class="' + classNotSelected + '"]';+ /*const selector =+ 'div[data-entry-id=' + id + '].' + classNotSelected.replace(/ /g, '.');+ await isDisplayed(selector, false);*/+ /*await global.client.waitForFunction(selector => {+ const el = document.querySelector(selector);+ return el === null;+ }, selector);*/+ } else {+ console.debug(+ 'selectRowFiles filesList.length:' ++ filesList.length ++ ' with index:' ++ index ++ ' not exist'+ );+ }}}await clickOn('[data-tid=gridPerspectiveSwitchLayoutToGrid]');@@ -504,6 +575,7 @@ export async function removeTagFromTagMenu(tagName) {await clickOn('[data-tid=tagMoreButton_' + tagName + ']');await clickOn('[data-tid=deleteTagMenu]');await clickOn('[data-tid=confirmRemoveTagFromFile]');+ await isDisplayed('[data-tid=tagMoreButton_' + tagName + ']', false);}export async function showFilesWithTag(tagName) {@@ -572,7 +644,7 @@ export async function expectTagsExistBySelector(}export async function expectTagsExist(gridElement, arrTagNames, exist = true) {- await expectExist(gridElement);+ // await expectExist(gridElement);const tags = await extractTags(gridElement);for (let i = 0; i < arrTagNames.length; i++) {const tagName = arrTagNames[i];diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex 061dc7574..355c7f589 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -164,8 +164,10 @@ export async function startTestingApp(extconfig) {// Print the title.// console.log(await global.client.title());- // Direct Electron console to Node terminal.- global.client.on('console', console.log);+ if (process.env.SHOW_CONSOLE) {+ // Direct Electron console to Node terminal.+ global.client.on('console', console.debug);+ }// Click button./*await global.client.click('[data-tid=location_supported-filestypes]');// Capture a screenshot.diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.jsindex 3b1a3f219..93d34aa0c 100644--- a/tests/e2e/location.helpers.js+++ b/tests/e2e/location.helpers.js@@ -202,15 +202,16 @@ export async function checkForIdExist(tid) {// expect(dataTid.selector).toBe('[data-tid=' + tid + ']');}+/**+ * @param newFileName+ * @param selector+ * @returns {Promise<oldFileName: string>}+ */export async function renameFileFromMenu(newFileName, selector = selectorFile) {- let fileName;await openContextEntryMenu(selector, 'fileMenuRenameFile');- // await global.client.pause(500);- const renameFileDialogInput = await global.client.$(+ const fileName = await global.client.inputValue('[data-tid=renameEntryDialogInput] input');- await renameFileDialogInput.waitForDisplayed({ timeout: 5000 });- fileName = await renameFileDialogInput.getValue();await setInputKeys('renameEntryDialogInput', newFileName);await clickOn('[data-tid=confirmRenameEntry]');diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.jsnew file mode 100644index 000000000..0175838e9--- /dev/null+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js@@ -0,0 +1,425 @@+/*+ * Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.+ */+import {+ defaultLocationPath,+ defaultLocationName,+ renameFileFromMenu,+ deleteFileFromMenu,+ createPwMinioLocation,+ createPwLocation+} from './location.helpers';+import { searchEngine } from './search.helpers';+import { openContextEntryMenu, toContainTID } from './test-utils';+import {+ clickOn,+ createNewDirectory,+ createTxtFile,+ expectElementExist,+ expectTagsExist,+ expectTagsExistBySelector,+ generateFileName,+ getGridFileName,+ getGridFileSelector,+ isDisplayed,+ isElementDisplayed,+ removeTagFromTagMenu,+ selectorFile,+ selectorFolder,+ selectRowFiles,+ setInputKeys,+ showDirectories,+ showFilesWithTag,+ waitForNotification+} from './general.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';+import { startTestingApp, stopSpectronApp, testDataRefresh } from './hook';++const testTagName = 'testTag'; // TODO fix camelCase tag name++// Test the functionality of the right button on a file on a grid perspective table+// Scenarios for right button on a file+describe('TST50** - Right button on a file', () => {+ beforeAll(async () => {+ await startTestingApp('extconfig-with-welcome.js');+ });++ afterAll(async () => {+ await stopSpectronApp();+ await testDataRefresh();+ });+ beforeEach(async () => {+ if (global.isMinio) {+ await createPwMinioLocation('', defaultLocationName, true);+ } else {+ await createPwLocation(defaultLocationPath, defaultLocationName, true);+ }+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ // If its have opened file+ // await closeFileProperties();+ });++ test('TST5016 - Open file [web,minio,electron]', async () => {+ //await searchEngine('txt');+ await openContextEntryMenu(+ '[data-tid="fsEntryName_sample.txt"]', // perspectiveGridTable + firstFile,+ 'fileMenuOpenFile'+ );+ // Check if the file is opened+ // await delay(1500);+ await expectElementExist('#FileViewer');+ const webViewer = await global.client.$('#FileViewer');+ // await webViewer.waitForDisplayed();+ //await delay(5000);+ // expect(await webViewer.isDisplayed()).toBe(true);+ const iframe = await webViewer.contentFrame();+ // await global.client.switchToFrame(webViewer);+ const iframeBody = await iframe.$('body');+ await isElementDisplayed(iframeBody);+ const bodyTxt = await iframeBody.innerText();++ //await global.client.switchToParentFrame();+ expect(toContainTID(bodyTxt)).toBe(true);+ });++ test('TST5017 - Rename file [web,minio,electron]', async () => {+ const newFileName = 'newFileName';+ const fileExtension = '.txt';+ // await searchEngine('txt');+ const sampleFileName = 'sample.txt';+ const oldName = await renameFileFromMenu(+ newFileName,+ getGridFileSelector(sampleFileName)+ );+ expect(oldName).toBe(sampleFileName);++ await expectElementExist(getGridFileSelector(newFileName + fileExtension));+ await expectElementExist(getGridFileSelector(oldName), false);++ // const fileNameTxt = await getFirstFileName();+ // expect(fileNameTxt).toContain(newFileName);++ // rename back to oldName+ const fileName = await renameFileFromMenu(+ oldName,+ getGridFileSelector(newFileName + fileExtension)+ );+ expect(fileName).toBe(newFileName + fileExtension);+ });++ test('TST5018 - Delete file [web,minio,electron]', async () => {+ // await createTxtFile();+ // await searchEngine('note'); //select new created file - note[date_created].txt+ let fileName = 'sample.html'; // await getGridFileName(-1);+ // expect(firstFileName).toBe('note.txt');++ // await expectElementExist(selectorFile, true);++ await deleteFileFromMenu(getGridFileSelector(fileName));+ await expectElementExist(getGridFileSelector(fileName), false);+ /* firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe(undefined); */+ });++ test('TST5019 - Rename tag in file [web,minio,electron]', async () => {+ // await searchEngine('desktop');+ // Select file+ await clickOn(selectorFile);+ await AddRemoveTagsToSelectedFiles([testTagName], true);+ await expectTagsExistBySelector(selectorFile, [testTagName], true);++ /*await AddRemoveTagsToFile(perspectiveGridTable + firstFile, [testTagName], {+ add: true+ });*/+ await clickOn('[data-tid=tagMoreButton_' + testTagName + ']');+ await clickOn('[data-tid=editTagDialogMenu]');+ await global.client.dblclick('[data-tid=editTagEntryDialog_input] input');+ await setInputKeys('editTagEntryDialog_input', testTagName + 'Edited');+ await clickOn('[data-tid=confirmEditTagEntryDialog]');+ await waitForNotification();++ await expectTagsExistBySelector(+ selectorFile,+ [testTagName + 'Edited'],+ true+ );++ //cleanup+ await clickOn(selectorFile);+ await AddRemoveTagsToSelectedFiles([testTagName + 'Edited'], false);+ await expectTagsExistBySelector(+ selectorFile,+ [testTagName + 'Edited'],+ false+ );+ });++ test('TST5023 - Remove tag from file (tag menu) [web,minio,electron]', async () => {+ // await searchEngine('desktop');+ // select file+ await clickOn(selectorFile);+ await AddRemoveTagsToSelectedFiles([testTagName], true);+ await expectTagsExistBySelector(selectorFile, [testTagName], true);++ await removeTagFromTagMenu(testTagName);++ await expectTagsExistBySelector(selectorFile, [testTagName], false);+ });++ /**+ * todo search not work+ */+ test('TST5024 - Show files with a given tag (tag menu)', async () => {+ //click on hide directories+ await showDirectories(false);++ await selectRowFiles([0, 1, 2]);+ await AddRemoveTagsToSelectedFiles([testTagName], true);+ await showFilesWithTag(testTagName);++ const filesList = await global.client.$$(selectorFile);+ for (let i = 0; i < filesList.length; i++) {+ await expectTagsExist(filesList[i], [testTagName], true);+ }++ //cleanup+ await selectRowFiles([0, 1, 2]);+ await AddRemoveTagsToSelectedFiles([testTagName], false);++ /*const classNotSelected = await getGridCellClass(0);+ const classSelected = await selectAllFiles(classNotSelected);+ expect(classNotSelected).not.toBe(classSelected);++ await AddRemoveTagsToSelectedFiles([testTagName], true);+ await showFilesWithTag(testTagName);++ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ for (let i = 0; i < filesList.length; i++) {+ await expectTagsExist(filesList[i], [testTagName], true);+ }++ // cleanup+ await selectAllFiles(classNotSelected);+ expect(classNotSelected).not.toBe(classSelected);+ await AddRemoveTagsToSelectedFiles([testTagName], false);*/+ });++ /**+ * TODO web sometimes: stale element reference: stale element reference: element is not attached to the page document+ * TODO minio sometimes: stale element reference: stale element reference: element is not attached to the page document+ */+ test('TST5025 - Add - Remove tags (file menu) [web,electron]', async () => {+ // await searchEngine('desktop');+ const fileName = 'sample';+ const fileExt = 'desktop';+ const tags = [testTagName, testTagName + '2'];+ // select file+ await clickOn(getGridFileSelector(fileName + '.' + fileExt));+ await AddRemoveTagsToSelectedFiles(tags, true);++ let gridElement = await global.client.$(+ getGridFileSelector(generateFileName(fileName, fileExt, tags, ' '))+ );+ gridElement = await gridElement.$('..');+ await expectTagsExist(gridElement, tags, true);+ // await expectTagsExistBySelector(selectorFile, tags, true);++ // remove tags+ await gridElement.click();+ await AddRemoveTagsToSelectedFiles(tags, false);++ gridElement = await global.client.$(+ getGridFileSelector(fileName + '.' + fileExt)+ );+ gridElement = await gridElement.$('..');+ await expectTagsExist(gridElement, tags, false);+ // await expectTagsExistBySelector(selectorFile, tags, false);+ });++ test('TST5026 - Open file natively [electron]', async () => {+ if (!global.isMinio) {+ // Open file natively option is missing for Minio Location+ await searchEngine('txt');+ await openContextEntryMenu(selectorFile, 'fileMenuOpenFileNatively');+ }+ // check parent directory+ });++ test('TST5027 - Open containing folder [web,minio,electron]', async () => {+ if (!global.isMinio) {+ // Show in File Manager option is missing for Minio Location+ await searchEngine('txt');+ await openContextEntryMenu(selectorFile, 'fileMenuOpenContainingFolder');+ }+ // check parent directory+ });++ /*test('TST50** - Add / Remove tags', async () => {+ await searchEngine('txt');+ await openContextEntryMenu(+ perspectiveGridTable + firstFile,+ 'fileMenuAddRemoveTags'+ );+ //TODO cannot find cancelTagsMultipleEntries ??+ await delay(500);+ const cancelButton = await global.client+ .$('[data-tid=cancelTagsMultipleEntries]');+ await cancelButton.waitForDisplayed();+ await cancelButton.click();+ });*/++ /**+ * todo web: io-actions.ts:120 Moving files failed with Renaming file failedSignatureDoesNotMatch+ */+ test('TST5028 - Move - Copy file (file menu) [minio,electron]', async () => {+ // Move file in child folder+ // const fileExtension = 'pdf'; //'eml' -> todo search found extra files (.gitkeep) with fuseOptions = {threshold: 0.4,+ // await searchEngine(fileExtension);+ const fileName = 'sample.pdf';+ const fileSelector = getGridFileSelector(fileName);+ await openContextEntryMenu(fileSelector, 'fileMenuMoveCopyFile');+ await setInputKeys(+ 'targetPathInput',+ defaultLocationPath + '/empty_folder'+ );++ await clickOn('[data-tid=confirmMoveFiles]');+ await waitForNotification();+ await expectElementExist(getGridFileSelector(fileName), false);+ //await clickOn('#clearSearchID');+ await global.client.dblclick(selectorFolder);+ //await searchEngine(fileExtension, { reindexing: true }); // TODO temp fix: https://trello.com/c/ZfcGGvOM/527-moved-files-is-not-indexing-not-found-in-search++ await expectElementExist(getGridFileSelector(fileName), true);+ // let firstFileName = await getGridFileName(0);+ // expect(firstFileName).toBe(fileName);++ //Copy file in parent directory+ await openContextEntryMenu(fileSelector, 'fileMenuMoveCopyFile');+ await setInputKeys('targetPathInput', defaultLocationPath);+ await clickOn('[data-tid=confirmCopyFiles]');+ await waitForNotification();+ //await clickOn('#clearSearchID');+ await clickOn('[data-tid=gridPerspectiveOnBackButton]');+ await expectElementExist(getGridFileSelector(fileName), true);+ //await searchEngine(fileExtension);+ /*firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.' + fileExtension);+*/+ // cleanup+ await global.client.dblclick(selectorFolder);+ await expectElementExist(selectorFile, true);+ await deleteFileFromMenu();+ await expectElementExist(selectorFile, false);+ });++ it.skip('TST5029 - Add file from file manager with dnd [manual]', async () => {});++ test('TST5033 - Open directory (directory menu) [web,minio,electron]', async () => {+ // open empty_folder+ await openContextEntryMenu(selectorFolder, 'openDirectory');+ await expectElementExist(selectorFile, false);+ //const firstFileName = await getGridFileName(0);+ //expect(firstFileName).toBe(undefined); //'sample.eml');+ });++ test('TST5034 - Rename directory (directory menu) [web,minio,electron]', async () => {+ const newDirName = 'new_dir_name';+ await openContextEntryMenu(selectorFolder, 'renameDirectory');+ const oldDirName = await setInputKeys('renameEntryDialogInput', newDirName);+ await clickOn('[data-tid=confirmRenameEntry]');+ await waitForNotification();++ //turn dir name back+ await openContextEntryMenu(selectorFolder, 'renameDirectory');+ const renamedDir = await setInputKeys('renameEntryDialogInput', oldDirName);+ await clickOn('[data-tid=confirmRenameEntry]');+ await waitForNotification();+ expect(renamedDir).toBe(newDirName);+ });++ /**+ * delete dir is not supported on minio+ */+ test('TST5035 - Delete directory (directory menu) [web,minio,electron]', async () => {+ // await setSettings('[data-tid=settingsSetUseTrashCan]');+ // await global.client.pause(500);+ await global.client.dblclick(selectorFolder);+ const testFolder = await createNewDirectory('aaa');++ await openContextEntryMenu(selectorFolder, 'deleteDirectory');+ await clickOn('[data-tid=confirmDeleteFileDialog]');++ await expectElementExist(+ '[data-tid=fsEntryName_' + testFolder + ']',+ false+ );+ // dir back to check if parent folder exist+ // await clickOn('[data-tid=gridPerspectiveOnBackButton]');+ // await expectElementExist(selectorFolder, true);+ });++ test('TST5036 - Open directory properties (directory menu) [web,minio,electron]', async () => {+ await openContextEntryMenu(selectorFolder, 'showProperties');+ await expectElementExist('[data-tid=fileNameProperties]', true);+ });++ test('TST5037 - Show sub folders [TST5037,web,minio,electron]', async () => {+ //click on hide directories+ await showDirectories(false);++ //file+ await expectElementExist(selectorFile, true);+ //folder+ await expectElementExist(selectorFolder, false);++ // show sub folder in the grid perspective+ await showDirectories(true);++ //file+ await expectElementExist(selectorFile, true);+ //folder+ await expectElementExist(selectorFolder, true);+ });++ test('TST5038 - Return directory back [web,minio,electron]', async () => {+ // await expectElementExist(selectorFolder);++ //Open folder+ await global.client.dblclick(selectorFolder);++ await expectElementExist(selectorFolder, false);+ await clickOn('[data-tid=gridPerspectiveOnBackButton]');+ await expectElementExist(selectorFolder);+ });++ test('TST5039 - Changing the Perspective View [web,minio,electron]', async () => {+ await isDisplayed('[data-tid=perspectiveGridFileTable]');+ const grid = await global.client.$('[data-tid=perspectiveGridFileTable]');+ let gridStyle = await grid.getAttribute('style');++ expect(gridStyle).toContain(+ 'grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));'+ );++ await clickOn('[data-tid=gridPerspectiveSwitchLayoutToRow]');+ // check perspective view++ gridStyle = await grid.getAttribute('style');+ expect(gridStyle).toContain('grid-template-columns: none;');+ });++ test('TST5040 - Create file [TST5040,web,minio,electron]', async () => {+ //Open empty folder+ await global.client.dblclick(selectorFolder);++ await createTxtFile();+ // await searchEngine('note');+ await expectElementExist(selectorFile, true);++ //cleanup+ //await deleteFirstFile();+ //const firstFileName = await getGridFileName(0);+ //expect(firstFileName).toBe(undefined);+ });+});diff --git a/tests/e2e/perspective-grid.helpers.js b/tests/e2e/perspective-grid.helpers.jsindex 420a70c69..4074f25a6 100644--- a/tests/e2e/perspective-grid.helpers.js+++ b/tests/e2e/perspective-grid.helpers.js@@ -1,4 +1,4 @@-import { addInputKeys, clickOn, waitForNotification } from './general.helpers';+import { clickOn, setInputKeys, waitForNotification } from './general.helpers';/***@@ -15,9 +15,8 @@ export async function AddRemoveTagsToSelectedFiles(for (let i = 0; i < tagNames.length; i++) {const tagName = tagNames[i];- await addInputKeys('AddRemoveTagsSelectTID', tagName);- await global.client.keys('Enter');- await global.client.pause(500);+ await setInputKeys('AddRemoveTagsSelectTID', tagName);+ await global.client.keyboard.press('Enter');}if (addTag) {@@ -25,7 +24,6 @@ export async function AddRemoveTagsToSelectedFiles(} else {await clickOn('[data-tid=removeTagsMultipleEntries]');}- await global.client.pause(1000);await waitForNotification();/*const filesList = await global.client.$$(perspectiveGridTable + firstFile); // Selected file can be only one this check all filesdiff --git a/tests/e2e/perspective-grid.pw.e2e.js b/tests/e2e/perspective-grid.pw.e2e.jsnew file mode 100644index 000000000..b9f8bea5b--- /dev/null+++ b/tests/e2e/perspective-grid.pw.e2e.js@@ -0,0 +1,341 @@+/*+ * Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.+ */+import {+ defaultLocationPath,+ defaultLocationName,+ deleteFileFromMenu,+ createPwMinioLocation,+ createPwLocation+} from './location.helpers';+import { searchEngine } from './search.helpers';+import {+ clickOn,+ createTxtFile,+ expectElementExist,+ expectTagsExistBySelector,+ extractTags,+ getGridCellClass,+ getGridFileName,+ getGridFileSelector,+ isElementDisplayed,+ selectAllFiles,+ selectFilesByID,+ selectorFile,+ selectorFolder,+ selectRowFiles,+ setInputKeys,+ showDirectories,+ waitForNotification+} from './general.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';+import { getPropertiesFileName } from './file.properties.helpers';+import { startTestingApp, stopSpectronApp, testDataRefresh } from './hook';++/*const subFolderName = '/test-perspective-grid';+const subFolderContentExtractionPath =+ defaultLocationPath + '/content-extraction';+const subFolderThumbnailsPath = defaultLocationPath + '/thumbnails';+const testTestFilename = 'sample';+*/++describe('TST50 - Perspective Grid', () => {+ beforeAll(async () => {+ await startTestingApp('extconfig-with-welcome.js');+ });++ afterAll(async () => {+ await stopSpectronApp();+ await testDataRefresh();+ });+ beforeEach(async () => {+ if (global.isMinio) {+ await createPwMinioLocation('', defaultLocationName, true);+ } else {+ await createPwLocation(defaultLocationPath, defaultLocationName, true);+ }+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ // If its have opened file+ // await closeFileProperties();+ });++ test('TST5002 - Open file with click [web,minio,electron]', async () => {+ // await searchEngine('txt'); //testTestFilename);+ const fileName = 'sample.txt';++ // const firstFileName = await getGridFileName(0);+ await clickOn(getGridFileSelector(fileName)); // perspectiveGridTable + firstFile);+ //Toggle Properties+ await clickOn('[data-tid=fileContainerToggleProperties]');+ const propsFileName = await getPropertiesFileName();+ expect(fileName).toBe(propsFileName);+ // await checkFilenameForExist(testTestFilename);+ });++ // Scenarios for sorting files in grid perspective+ describe('TST5003 - Testing sort files in the grid perspective [web,minio,electron]', () => {+ beforeEach(async () => {+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ });++ test('TST10xx - Sort by name [web,minio,electron]', async () => {+ //DESC+ await clickOn('[data-tid=gridPerspectiveSortByName]');+ let firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample_exif.jpg');+ // ASC+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ await clickOn('[data-tid=gridPerspectiveSortByName]');+ firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.bmp');+ });++ test('TST10xx - Sort by size [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortBySize]');+ let firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.desktop');++ //ASC+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ await clickOn('[data-tid=gridPerspectiveSortBySize]');+ firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.ogv');+ });++ test('TST10xx - Sort by date [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByDate]');++ await createTxtFile();+ // await global.client.pause(500);++ // ASC+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ await clickOn('[data-tid=gridPerspectiveSortByDate]');++ let firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('note.txt');++ //cleanup+ // await setSettings('[data-tid=settingsSetUseTrashCan]');+ // await global.client.pause(500);+ await deleteFileFromMenu();+ // firstFileName = await getGridFileName(0);+ // expect(firstFileName).not.toBe('note.txt'); TODO its have note.txt from another tests+ });++ test('TST10xx - Sort by extension [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByExt]');+ let firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.bmp');++ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ await clickOn('[data-tid=gridPerspectiveSortByExt]');+ firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.zip');+ });++ test('TST10xx - Sort by tags [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByFirstTag]');+ let firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.bmp');+ //ASC+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ await clickOn('[data-tid=gridPerspectiveSortByFirstTag]');+ firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample_exif.jpg');+ });+ });++ test('TST5004 - Select-deselect all files [web,minio,electron]', async () => {+ const classNotSelected = await getGridCellClass(0);+ await selectAllFiles(); // classNotSelected);+ const classSelected = await getGridCellClass(0);++ expect(classNotSelected).not.toBe(classSelected);++ const filesList = await global.client.$$(selectorFile);+ for (let i = 0; i < filesList.length; i++) {+ let file = await filesList[i].$('div');+ file = await file.$('div');+ const style = await file.getAttribute('class');+ expect(style).toBe(classSelected);+ }+ });++ // This scenario includes "Add tags" && "Remove tags" to be fulfilled+ test('TST5005 - Add tags to the selected files [web,minio,electron]', async () => {+ //click on hide directories+ await showDirectories(false);++ const selectedIds = await selectRowFiles([0, 1, 2]);++ const tags = ['test-tag1', 'test-tag2'];+ await AddRemoveTagsToSelectedFiles(tags);++ for (let i = 0; i < selectedIds.length; i++) {+ // const selectBox = await global.client.$('[data-tid=perspectiveGridFileTable]');+ await expectTagsExistBySelector(+ '[data-entry-id="' + selectedIds[i] + '"]',+ tags,+ true+ );+ }+ });++ /**+ * TODO merge with TST5005+ */+ test('TST5006 - Remove tags from selected files [web,minio,electron]', async () => {+ //click on hide directories+ await showDirectories(false);++ const selectedIds = await selectRowFiles([0, 1, 2]);++ const tags = ['test-tag1', 'test-tag2'];+ await AddRemoveTagsToSelectedFiles(tags, false);++ for (let i = 0; i < selectedIds.length; i++) {+ await expectTagsExistBySelector(+ '[data-entry-id="' + selectedIds[i] + '"]',+ tags,+ false+ );+ }+ });++ test('TST5007 - Remove all tags from selected files [web,minio,electron]', async () => {+ //click on hide directories+ await showDirectories(false);++ const selectedIds = await selectRowFiles([0, 1, 2]);+ const tags = ['test-tag1', 'test-tag2', 'test-tag3'];+ await AddRemoveTagsToSelectedFiles(tags, true);++ await selectFilesByID(selectedIds);++ await clickOn('[data-tid=gridPerspectiveAddRemoveTags]');+ await clickOn('[data-tid=cleanTagsMultipleEntries]');++ for (let i = 0; i < tags.length; i++) {+ await expectElementExist(+ '[data-tid=tagMoreButton_' + tags[i] + ']',+ false+ );+ }+ /*for (let i = 0; i < selectedIds.length; i++) {+ const gridElement = await global.client.$(+ '[data-entry-id="' + selectedIds[i] + '"]'+ );+ await isElementDisplayed(gridElement);+ const tags = await extractTags(gridElement);+ expect(tags.length).toBe(0);+ }*/+ });++ test('TST5008 - Copy file [web,minio,electron]', async () => {+ const sampleFileName = 'sample.txt';+ // Electron path: ./testdata-tmp/file-structure/supported-filestypes/empty_folder+ let copyLocationPath = global.isElectron+ ? defaultLocationPath + '/empty_folder'+ : 'empty_folder';+ // const fileName = await getFirstFileName();++ // select file+ await clickOn(getGridFileSelector(sampleFileName));+ // open Copy File Dialog+ await clickOn('[data-tid=gridPerspectiveCopySelectedFiles]');+ await setInputKeys('targetPathInput', copyLocationPath);+ await clickOn('[data-tid=confirmCopyFiles]');+ await waitForNotification();++ await global.client.dblclick(selectorFolder);+ await expectElementExist(selectorFile, true);+ // const firstFileName = await getGridFileName(0);+ // expect(firstFileName).toBe(sampleFileName);+ // cleanup+ await deleteFileFromMenu();+ await expectElementExist(selectorFile, false);+ });++ it.skip('TST5009 - Copy file on different partition [manual]', async () => {});++ /**+ * TODO reindexing don't work in web+ * TODO search not work SplashWorker windows is disabled+ */+ test('TST5010 - Move file', async () => {+ await searchEngine('epub');++ // select file+ await clickOn(selectorFile);+ // open Copy File Dialog+ await clickOn('[data-tid=gridPerspectiveCopySelectedFiles]');+ await setInputKeys(+ 'targetPathInput',+ defaultLocationPath + '/empty_folder'+ );+ await clickOn('[data-tid=confirmMoveFiles]');+ await waitForNotification();+ await clickOn('#clearSearchID');+ await global.client.dblclick(selectorFolder);+ await searchEngine('epub', { reindexing: true }); // TODO temp fix: https://trello.com/c/ZfcGGvOM/527-moved-files-is-not-indexing-not-found-in-search+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.epub');+ // cleanup+ await deleteFileFromMenu();+ await expectElementExist(selectorFile, false);+ });++ it.skip('TST5011 - Move file drag&drop in location navigator [manual]', async () => {});++ it.skip('TST5012 - Move file different partition [manual]', async () => {});++ test('TST5013 - Delete files from selection (many files) [web,minio,electron]', async () => {+ //click on hide directories+ await showDirectories(false);++ const selectedIds = await selectRowFiles([0, 1, 2]);++ await clickOn('[data-tid=gridPerspectiveDeleteMultipleFiles]');+ await clickOn('[data-tid=confirmDeleteFileDialog]');+ await waitForNotification();++ for (let i = 0; i < selectedIds.length; i++) {+ await expectElementExist(+ '[data-entry-id="' + selectedIds[i] + '"]',+ false,+ 1000+ );+ }++ /*await doubleClickOn(selectorFolder);+ await createTxtFile();+ await searchEngine('note');+ await expectElementExist(selectorFile, true);++ const classNotSelected = await getGridCellClass(0);+ await clickOn(selectorFile);+ const classSelected = await waitUntilClassChanged(+ selectorFile + '/div/div',+ classNotSelected+ );+ expect(classNotSelected).not.toBe(classSelected);++ await clickOn('[data-tid=gridPerspectiveDeleteMultipleFiles]');+ await clickOn('[data-tid=confirmDeleteFileDialog]');+ await waitForNotification();+ await expectElementExist(selectorFile, false);*/+ });++ it.skip('TST5015 - Tag file drag&drop in perspective [manual]', async () => {});++ /*test('TST51** - Show/Hide directories in perspective view', async () => { //TODO+ await global.client.waitForVisible(+ '[data-tid=gridPerspectiveToggleShowDirectories]'+ );+ await global.client.click(+ '[data-tid=gridPerspectiveToggleShowDirectories]'+ );+ // Check if the directories are displayed+ });*/+});