TagSpaces is an offline, open source, document manager with tagging support
TST50 - Added e2e tests for perspective grid (#1264)
Stanimir9fccad6cbf37
diff --git a/.github/workflows/workflow_scheduled.yml b/.github/workflows/workflow_scheduled.ymlindex 657a81217..6282678d6 100644--- a/.github/workflows/workflow_scheduled.yml+++ b/.github/workflows/workflow_scheduled.yml@@ -5,13 +5,14 @@ on:jobs:e2eTestsElectronWin:- name: E2E Windows+ name: E2E Windows Electronruns-on: windows-lateststeps:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:@@ -38,6 +39,7 @@ jobs:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:@@ -49,6 +51,13 @@ jobs:yarn type-check- name: Run Unit testsrun: yarn test-unit+ - uses: suisei-cn/actions-download-file@v1+ id: minio+ name: Download the Minio.exe+ with:+ url: 'https://dl.min.io/server/minio/release/windows-amd64/minio.exe'+ target: tests/bin/+ auto-match: true- name: Run Electron testsrun: |yarn setup-ext@@ -64,6 +73,7 @@ jobs:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:@@ -75,6 +85,13 @@ jobs:yarn type-check- name: Run Unit testsrun: yarn test-unit+ - uses: suisei-cn/actions-download-file@v1+ id: minio+ name: Download the Minio.exe+ with:+ url: 'https://dl.min.io/server/minio/release/windows-amd64/minio.exe'+ target: tests/bin/+ auto-match: true- name: Run Electron testsrun: |yarn setup-ext@@ -83,12 +100,13 @@ jobs:yarn test-e2e-webe2eTestsElectronMac:- name: E2E Mac+ name: E2E Mac Electronruns-on: macos-lateststeps:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:@@ -108,12 +126,13 @@ jobs:yarn test-e2e-electrone2eTestsMinioMac:- name: E2E Minio Mac+ name: E2E Mac Minioruns-on: macos-lateststeps:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:@@ -132,13 +151,14 @@ jobs:yarn build-e2eyarn test-e2e-electron-minio- e2eTestsWinMac:- name: E2E Win Mac+ e2eTestsWebMac:+ name: E2E Mac Webruns-on: macos-lateststeps:- name: Checking out default branchuses: actions/checkout@v2with:+ ref: developsubmodules: true- uses: actions/setup-node@v2-betawith:diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex ca6f13581..eefa7bc94 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -752,6 +752,7 @@ const EntryProperties = (props: Props) => {<div className={classes.gridItem}><TagDropContainer entryPath={currentEntry.path}><TagsSelect+ dataTid="PropertiesTagsSelectTID"placeholderText={i18n.t('core:dropHere')}isReadOnlyMode={isReadOnlyMode ||diff --git a/app/components/TagsSelect.tsx b/app/components/TagsSelect.tsxindex c97af6a79..21d2e5c8e 100644--- a/app/components/TagsSelect.tsx+++ b/app/components/TagsSelect.tsx@@ -22,12 +22,10 @@ import { connect } from 'react-redux';import { withStyles } from '@material-ui/core/styles';import TextField from '@material-ui/core/TextField';import Autocomplete from '@material-ui/lab/Autocomplete';-import { bindActionCreators } from 'redux';import { Tag, getAllTags } from '-/reducers/taglibrary';import { getTagColor, getTagTextColor } from '-/reducers/settings';import TagContainer from './TagContainer';import EntryTagMenu from '-/components/menus/EntryTagMenu';-import TaggingActions from '-/reducers/tagging-actions';const styles: any = (theme: any) => ({root: {@@ -67,6 +65,7 @@ const styles: any = (theme: any) => ({});interface Props {+ dataTid?: string;classes?: any;theme?: any;tags: Array<Tag>;@@ -175,6 +174,7 @@ const TagsSelect = (props: Props) => {return (<div className={classes.root}><Autocomplete+ data-tid={props.dataTid}multipleoptions={!props.isReadOnlyMode ? allTags : []}getOptionLabel={option => option.title}diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 6fae55296..947dd6696 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -1,6 +1,6 @@/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */-import { delay } from './hook';-import { firstFile } from './test-utils.spec';+import {delay} from './hook';+import {firstFile} from './test-utils.spec';export const defaultLocationPath ='./testdata/file-structure/supported-filestypes';@@ -61,6 +61,38 @@ export async function setInputValue(selector, value) {await element.setValue(value);}+export async function addInputKeys(tid, value) {+ const element = await global.client.$('[data-tid=' + tid + ']');+ await element.waitUntil(+ async function() {+ const displayed = await this.isDisplayedInViewport();+ return displayed === true;+ },+ {+ timeout: 5000,+ timeoutMsg:+ 'setInputKeys selector ' + element.selector + ' to exist after 5s'+ }+ );+ await element.click();++ const elemInput = await global.client.$('[data-tid=' + tid + '] input');+ await elemInput.waitUntil(+ async function() {+ // const displayed = await this.isDisplayed();+ const displayed = await this.isDisplayedInViewport();+ return displayed === true;+ },+ {+ timeout: 5000,+ timeoutMsg:+ 'setInputKeys selector ' + element.selector + ' to exist after 5s'+ }+ );+ await elemInput.click();+ await elemInput.keys(value);+}+export async function setInputKeys(tid, value) {const element = await global.client.$('[data-tid=' + tid + ']');await element.waitUntil(@@ -112,6 +144,41 @@ export async function clearInputValue(inputElement) {}}+/**+ *+ * @param fileIndex+ * @returns {Promise<string>} fileName; example usage: getFileName(-1) will return the last one+ */+export async function getGridFileName(fileIndex) {+ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ let file =+ fileIndex < 0+ ? filesList[filesList.length + fileIndex]+ : filesList[fileIndex];+ file = await file.$('div');+ file = await file.$('div');+ file = await file.$('div');+ const fileNameElem = await file.$('p');+ const fileName = await fileNameElem.getText();+ const divs = await file.$$('div');+ const lastDiv = await divs[divs.length - 1];+ const fileExtElem = await lastDiv.$('span');+ const fileExt = await fileExtElem.getText();+ return fileName + '.' + fileExt.toLowerCase();+}++export async function getGridCellClass(fileIndex = 0) {+ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ let file =+ fileIndex < 0+ ? filesList[filesList.length + fileIndex]+ : filesList[fileIndex];+ file = await file.$('div');+ file = await file.$('div');++ return await file.getAttribute('class');+}+export async function expectElementExist(selector, exist = true) {const element = await global.client.$(selector);await element.waitUntil(diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.jsindex 1e345e3f4..ce32dfe3e 100644--- a/tests/e2e/location.helpers.js+++ b/tests/e2e/location.helpers.js@@ -92,14 +92,6 @@ export async function createMinioLocation(await elemInput.keys(value);}*/-export async function selectAllFilesClick() {- const gridPerspectiveSelectAllFiles = await global.client.$(- '[data-tid=gridPerspectiveSelectAllFiles]'- );- await gridPerspectiveSelectAllFiles.waitForDisplayed();- await gridPerspectiveSelectAllFiles.click();-}-export async function openLocationMenu(locationName) {await clickOn('[data-tid=locationMoreButton_' + locationName + ']');}@@ -184,6 +176,29 @@ export async function getFirstFileName() {return fileName;}+export async function getPropertiesFileName() {+ const propsFileNameInput = await global.client.$(+ '[data-tid=fileNameProperties] input'+ );+ await propsFileNameInput.waitForDisplayed({ timeout: 5000 });+ return await propsFileNameInput.getValue();+}++export async function getPropertiesTags() {+ const arrTags = [];+ const tags = await global.client.$$(+ '[data-tid=PropertiesTagsSelectTID] 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 span');+ arrTags.push(await label.getText());+ }+ }+ return arrTags;+}+/*export async function checkForValidExt(selector, ext) {const getExt = await global.client.waitForVisible(selector)diff --git a/tests/e2e/perspective-grid.e2e.js b/tests/e2e/perspective-grid.e2e.jsindex df8530036..6e8dab5c3 100644--- a/tests/e2e/perspective-grid.e2e.js+++ b/tests/e2e/perspective-grid.e2e.js@@ -9,22 +9,27 @@ import {getFirstFileName,renameFirstFile,deleteFirstFile,- createMinioLocation+ createMinioLocation,+ getPropertiesFileName,+ getPropertiesTags} from './location.helpers';import { searchEngine } from './search.spec';import {- checkFilenameForExist,openContextEntryMenu,perspectiveGridTable,firstFile,toContainTID} from './test-utils.spec';import {+ addInputKeys,clickOn,doubleClickOn,expectElementExist,+ getGridCellClass,+ getGridFileName,selectorFile,- selectorFolder+ selectorFolder,+ setInputKeys} from './general.helpers';const subFolderName = '/test-perspective-grid';@@ -32,12 +37,11 @@ const subFolderContentExtractionPath =defaultLocationPath + '/content-extraction';const subFolderThumbnailsPath = defaultLocationPath + '/thumbnails';-const testTagName = 'testTag';+const testTagName = 'test-tag'; // TODO fix camelCase tag nameconst testTestFilename = 'sample';const newFileName = 'newFileName.txt';-const newTagName = 'newTagName';-describe('TST51 - Perspective Grid', () => {+describe('TST50 - Perspective Grid', () => {beforeEach(async () => {// await clearLocalStorage();// await closeWelcome();@@ -52,45 +56,102 @@ describe('TST51 - Perspective Grid', () => {await closeFileProperties();});- test('TST5037 - Show sub folders [TST5037,web,electron]', async () => {- //open Option menu- await clickOn('[data-tid=gridPerspectiveOptionsMenu]');- //click on hide directories- await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');+ /*test('TST5113 - Show sub folders content', async () => {});*/- //file- await expectElementExist(selectorFile, true);- //folder- await expectElementExist(selectorFolder, false);+ test('TST5001 - Arrow keys select next/prev file [TST5001,web,minio,electron]', async () => {+ const firstFileName = await getGridFileName(0);- // show sub folder in the grid perspective- await clickOn('[data-tid=gridPerspectiveOptionsMenu]');- await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');+ // open fileProperties+ await clickOn(perspectiveGridTable + firstFile);+ //Toggle Properties+ await clickOn('[data-tid=fileContainerToggleProperties]');- //file- await expectElementExist(selectorFile, true);- //folder- await expectElementExist(selectorFolder, true);- });+ const propsFileName = await getPropertiesFileName();+ expect(firstFileName).toBe(propsFileName);- /*test('TST5113 - Show sub folders content', async () => {});*/+ await clickOn('[data-tid=fileContainerNextFile]');+ const propsNextFileName = await getPropertiesFileName();- test('TST5002 - Open file with click [web,electron]', async () => {+ const secondFileName = await getGridFileName(1);+ expect(secondFileName).toBe(propsNextFileName);+ });++ test('TST5002 - Open file with click [TST5002,web,minio,electron]', async () => {await searchEngine('txt'); //testTestFilename);+ const firstFileName = await getGridFileName(0);await clickOn(perspectiveGridTable + firstFile);- await checkFilenameForExist(testTestFilename);+ //Toggle Properties+ await clickOn('[data-tid=fileContainerToggleProperties]');+ const propsFileName = await getPropertiesFileName();+ expect(firstFileName).toBe(propsFileName);+ // await checkFilenameForExist(testTestFilename);});- test('TST5004 - Select/deselect all files [web]', async () => {- await clickOn('[data-tid=gridPerspectiveOptionsMenu]');+ // Scenarios for sorting files in grid perspective+ describe('TST5003 - Testing sort files in the grid perspective [TST5003,web,minio,electron]', () => {+ beforeEach(async () => {+ await clickOn('[data-tid=gridPerspectiveSortMenu]');+ });++ test('TST10** - Sort by name [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByName]');+ await global.client.pause(500); // TODO+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample_exif.jpg');+ });++ test('TST10** - Sort by size [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortBySize]');+ await global.client.pause(500); // TODO+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.ogv');+ });++ test('TST10** - Sort by date [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByDate]');+ await global.client.pause(500); // TODO+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.txt');+ });++ test('TST10** - Sort by extension [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByExt]');+ await global.client.pause(500); // TODO+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample.zip');+ });++ test('TST10** - Sort by tags [web,minio,electron]', async () => {+ await clickOn('[data-tid=gridPerspectiveSortByFirstTag]');+ await global.client.pause(1000); // TODO+ const firstFileName = await getGridFileName(0);+ expect(firstFileName).toBe('sample_exif.jpg');+ });+ });++ test('TST5004 - Select/deselect all files [TST5004,web,minio,electron]', async () => {+ const classNotSelected = await getGridCellClass(0);++ await clickOn('[data-tid=perspectiveGridToolbar]');+ // await clickOn('[data-tid=gridPerspectiveOptionsMenu]');// todo temp fix: is not clickable- await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');+ // await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');+//SelectAllFilesawait clickOn('[data-tid=gridPerspectiveSelectAllFiles]');+ await global.client.pause(500); // TODO+ const classSelected = await getGridCellClass(0);+ expect(classNotSelected).not.toBe(classSelected);++ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ 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);+ }- const file = await global.client.$(- '//*[@data-tid="perspectiveGridFileTable"]/span/div/div'- );+ /*const file = await global.client.$(perspectiveGridTable + '/span/div/div');//expect(file).toHaveClass('selectedGridCell', { message: 'Not selected!', })const style = await file.getAttribute('class');//console.log(style);@@ -98,17 +159,70 @@ describe('TST51 - Perspective Grid', () => {const containSelectedStyle =style.includes('jss131') ||style.includes('jss124') ||- style.includes('jss111'); /*Mac Web*/ // || style.includes('jss136') //TODO fix this is not stable- // expect(containSelectedStyle).toBe(true);+ style.includes('jss111'); /!*Mac Web*!/ // || style.includes('jss136') //TODO fix this is not stable*/});// This scenario includes "Add tags" && "Remove tags" to be fulfilled- test('TST5005 - Add tags to the selected files [web,electron]', async () => {- await searchEngine(testTestFilename);+ test('TST5005 - Add tags to the selected files [TST5005,web,minio,electron]', async () => {+ await searchEngine('txt');++ // open fileProperties+ await clickOn(perspectiveGridTable + firstFile);+ //Toggle Properties+ await clickOn('[data-tid=fileContainerToggleProperties]');++ const propsTags = await getPropertiesTags();++ expect(propsTags.includes(testTagName)).toBe(false);++ await addInputKeys('PropertiesTagsSelectTID', testTagName);+ await global.client.keys('Enter');+ await global.client.pause(500);+ const propsNewTags = await getPropertiesTags();++ expect(propsNewTags.includes(testTagName)).toBe(true);+ });++ test('TST5006 - Remove tags from selected files [TST5006,web,minio,electron]', async () => {+ await searchEngine('txt');++ // open fileProperties+ await clickOn(perspectiveGridTable + firstFile);+ //Toggle Properties+ await clickOn('[data-tid=fileContainerToggleProperties]');++ const propsTags = await getPropertiesTags();++ expect(propsTags.includes(testTagName)).toBe(true);++ await clickOn('[data-tid=tagMoreButton_' + testTagName + ']');+ await global.client.pause(500);+ await clickOn('[data-tid=deleteTagMenu]');+ await clickOn('[data-tid=confirmRemoveTagFromFile]');+ await global.client.pause(500);+ const propsNewTags = await getPropertiesTags();+ expect(propsNewTags.includes(testTagName)).toBe(false);});- test('TST5006 - Remove tags from selected files [web,electron]', async () => {- await searchEngine(testTestFilename);+ test('TST5037 - Show sub folders [TST5037,web,electron]', async () => {+ //open Option menu+ await clickOn('[data-tid=gridPerspectiveOptionsMenu]');+ //click on hide directories+ await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');++ //file+ await expectElementExist(selectorFile, true);+ //folder+ await expectElementExist(selectorFolder, false);++ // show sub folder in the grid perspective+ await clickOn('[data-tid=gridPerspectiveOptionsMenu]');+ await clickOn('[data-tid=gridPerspectiveToggleShowDirectories]');++ //file+ await expectElementExist(selectorFile, true);+ //folder+ await expectElementExist(selectorFolder, true);});test('TST5038 - Return directory back [web,electron]', async () => {@@ -150,6 +264,15 @@ describe('TST51 - Perspective Grid', () => {expect(gridStyle).toContain('grid-template-columns: none;');});+ test('TST5040 - Create file [web,electron]', async () => {+ await clickOn('[data-tid=folderContainerOpenDirMenu]');+ await clickOn('[data-tid=createNewFile]');+ //await global.client.pause(1500);+ await clickOn('[data-tid=createTextFileButton]');+ await searchEngine('note');+ await expectElementExist(selectorFile, true);+ });+/*test('TST51** - Show/Hide directories in perspective view', async () => { //TODOawait global.client.waitForVisible('[data-tid=gridPerspectiveToggleShowDirectories]'@@ -159,38 +282,6 @@ describe('TST51 - Perspective Grid', () => {);// Check if the directories are displayed});*/-- // Scenarios for sorting files in grid perspective- describe('TST5003 - Testing sort files in the grid perspective', () => {- beforeEach(async () => {- await clickOn('[data-tid=gridPerspectiveSortMenu]');- });-- test('TST10** - Sort by name [web,electron]', async () => {- await clickOn('[data-tid=gridPerspectiveSortByName]');- // todo check all selected files- });-- test('TST10** - Sort by size [web,electron]', async () => {- await clickOn('[data-tid=gridPerspectiveSortBySize]');- // todo check parent directory- });-- test('TST10** - Sort by date [web,electron]', async () => {- await clickOn('[data-tid=gridPerspectiveSortByDate]');- // todo check perspective view- });-- test('TST10** - Sort by extension [web,electron]', async () => {- await clickOn('[data-tid=gridPerspectiveSortByExt]');- // todo Check if the directories are displayed- });-- test('TST10** - Sort by tags [web,electron]', async () => {- await clickOn('[data-tid=gridPerspectiveSortByFirstTag]');- // todo Check if the directories are displayed- });- });});// Test the functionality of the right button on a file on a grid perspective table@@ -242,15 +333,6 @@ describe('TST50** - Right button on a file', () => {expect(fileName).toContain(oldName);});- test('TST5040 - Create file [web,electron]', async () => {- await clickOn('[data-tid=folderContainerOpenDirMenu]');- await clickOn('[data-tid=createNewFile]');- //await global.client.pause(1500);- await clickOn('[data-tid=createTextFileButton]');- await searchEngine('note');- await expectElementExist(selectorFile, true);- });-test('TST5018 - Delete file [web,electron]', async () => {await searchEngine('note'); //select new created file - note[date_created].txtawait expectElementExist(selectorFile, true);diff --git a/tests/e2e/test-utils.spec.js b/tests/e2e/test-utils.spec.jsindex 88b8c48bf..3ed57ce7a 100644--- a/tests/e2e/test-utils.spec.js+++ b/tests/e2e/test-utils.spec.js@@ -134,6 +134,12 @@ export async function openContextEntryMenu(selector, menuOperation) {await clickOn('[data-tid=' + menuOperation + ']');}+/**+ * @deprecated use getGridFileName(fileIndex) instead+ * @param filename+ * @param selector+ * @returns {Promise<void>}+ */export async function checkFilenameForExist(filename, selector) {// selector is current selector location for element in perspectiveGridTable or perspectiveListTable (full xpath path to element)