TagSpaces is an offline, open source, document manager with tagging support
Add/Remove tags testing (#1273)
Stanimira36baf700e69
diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsxindex 9ab9a7e1b..446f5febe 100644--- a/app/components/dialogs/AddRemoveTagsDialog.tsx+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx@@ -147,6 +147,7 @@ class AddRemoveTagsDialog extends React.Component<Props, State> {<DialogTitle>{i18n.t('core:tagOperationTitle')}</DialogTitle><DialogContent style={{ minHeight: 330 }}><TagsSelect+ dataTid="AddRemoveTagsSelectTID"placeholderText={i18n.t('core:selectTags')}tags={newlyAddedTags}handleChange={this.handleChange}diff --git a/tests/e2e/fileopener.e2e.js b/tests/e2e/fileopener.e2e.jsnew file mode 100644index 000000000..c6ff073a7--- /dev/null+++ b/tests/e2e/fileopener.e2e.js@@ -0,0 +1,56 @@+import {+ closeFileProperties,+ createLocation,+ createMinioLocation,+ defaultLocationName,+ defaultLocationPath,+ getPropertiesTags+} from './location.helpers';+import { addInputKeys, clickOn } from './general.helpers';+import { searchEngine } from './search.spec';+import { firstFile, perspectiveGridTable } from './test-utils.spec';++const testTagName = 'test-tag'; // TODO fix camelCase tag name++describe('TST08 - File / folder properties', () => {+ beforeEach(async () => {+ if (global.isMinio) {+ await createMinioLocation('', defaultLocationName, true);+ } else {+ await createLocation(defaultLocationPath, defaultLocationName, true);+ }+ // openLocation+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ // If its have opened file+ await closeFileProperties();+ });++ it('TST0808 - Add and remove tags to a file (file names) [TST0808,web,minio,electron]', async () => {+ await searchEngine('bmp');++ // 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);+ let propsNewTags = await getPropertiesTags();++ expect(propsNewTags.includes(testTagName)).toBe(true);++ await clickOn('[data-tid=tagMoreButton_' + testTagName + ']');+ await global.client.pause(500);+ await clickOn('[data-tid=deleteTagMenu]');+ await global.client.pause(500);+ await clickOn('[data-tid=confirmRemoveTagFromFile]');+ await global.client.pause(500);+ propsNewTags = await getPropertiesTags();+ expect(propsNewTags.includes(testTagName)).toBe(false);+ });+});diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 66b733648..a78cc53c0 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -279,6 +279,38 @@ export async function createTxtFile() {await waitForNotification();}+/**+ *+ * @param classNotSelected+ * @returns {Promise<void>} classSelected+ */+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);++ //SelectAllFiles+ await clickOn('[data-tid=gridPerspectiveSelectAllFiles]');++ return await waitUntilClassChanged(+ perspectiveGridTable + firstFile + '/div/div',+ classNotSelected+ );+}++export async function extractTags(selectorElement) {+ const arrTags = [];+ const tags = await selectorElement.$('#gridCellTags');+ if (tags) {+ const tagsList = await tags.$$('button');+ for (let i = 0; i < tagsList.length; i++) {+ arrTags.push(await tagsList[i].getAttribute('title'));+ }+ }+ return arrTags;+}+export async function waitForNotification(tid = 'notificationTID') {await global.client.pause(500);// await expectElementExist('[data-tid=' + tid + ']', true, 8000);diff --git a/tests/e2e/perspective-grid.e2e.js b/tests/e2e/perspective-grid.e2e.jsindex dca977ef3..d439ec755 100644--- a/tests/e2e/perspective-grid.e2e.js+++ b/tests/e2e/perspective-grid.e2e.js@@ -27,10 +27,13 @@ import {disableTrashBin,doubleClickOn,expectElementExist,+ extractTags,getGridCellClass,getGridFileName,+ selectAllFiles,selectorFile,selectorFolder,+ waitForNotification,waitUntilClassChanged} from './general.helpers';@@ -145,21 +148,8 @@ describe('TST50 - Perspective Grid', () => {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 global.client.pause(500);-- //SelectAllFiles- await clickOn('[data-tid=gridPerspectiveSelectAllFiles]');+ const classSelected = await selectAllFiles(classNotSelected);- const classSelected = await waitUntilClassChanged(- perspectiveGridTable + firstFile + '/div/div',- classNotSelected- );- // await global.client.pause(1000); // TODO- // const classSelected = await getGridCellClass(0);expect(classNotSelected).not.toBe(classSelected);const filesList = await global.client.$$(perspectiveGridTable + firstFile);@@ -183,45 +173,47 @@ describe('TST50 - Perspective Grid', () => {// This scenario includes "Add tags" && "Remove tags" to be fulfilledtest('TST5005 - Add tags to the selected files [TST5005,web,minio,electron]', async () => {- await searchEngine('bmp');-- // open fileProperties- await clickOn(perspectiveGridTable + firstFile);- //Toggle Properties- await clickOn('[data-tid=fileContainerToggleProperties]');-- const propsTags = await getPropertiesTags();+ const classNotSelected = await getGridCellClass(0);+ const classSelected = await selectAllFiles(classNotSelected);+ expect(classNotSelected).not.toBe(classSelected);- expect(propsTags.includes(testTagName)).toBe(false);+ /*await openContextEntryMenu( TODO Right button deselect files+ perspectiveGridTable + firstFile,+ 'fileMenuAddRemoveTags'+ );*/+ await clickOn('[data-tid=gridPerspectiveAddRemoveTags]');- await addInputKeys('PropertiesTagsSelectTID', testTagName);+ await addInputKeys('AddRemoveTagsSelectTID', testTagName);await global.client.keys('Enter');await global.client.pause(500);- const propsNewTags = await getPropertiesTags();-- expect(propsNewTags.includes(testTagName)).toBe(true);+ await clickOn('[data-tid=addTagsMultipleEntries]');+ // await global.client.pause(500);+ await waitForNotification();+ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ for (let i = 0; i < filesList.length; i++) {+ const tags = await extractTags(filesList[i]);+ expect(tags.includes(testTagName)).toBe(true);+ }});test('TST5006 - Remove tags from selected files [TST5006,web,minio,electron]', async () => {- await searchEngine('bmp');-- // open fileProperties- await clickOn(perspectiveGridTable + firstFile);- //Toggle Properties- await clickOn('[data-tid=fileContainerToggleProperties]');-- const propsTags = await getPropertiesTags();+ const classNotSelected = await getGridCellClass(0);+ const classSelected = await selectAllFiles(classNotSelected);+ expect(classNotSelected).not.toBe(classSelected);- expect(propsTags.includes(testTagName)).toBe(true);+ await clickOn('[data-tid=gridPerspectiveAddRemoveTags]');- await clickOn('[data-tid=tagMoreButton_' + testTagName + ']');- await global.client.pause(500);- await clickOn('[data-tid=deleteTagMenu]');- await global.client.pause(500);- await clickOn('[data-tid=confirmRemoveTagFromFile]');+ await addInputKeys('AddRemoveTagsSelectTID', testTagName);+ await global.client.keys('Enter');await global.client.pause(500);- const propsNewTags = await getPropertiesTags();- expect(propsNewTags.includes(testTagName)).toBe(false);+ await clickOn('[data-tid=removeTagsMultipleEntries]');+ // await global.client.pause(500);+ await waitForNotification();+ const filesList = await global.client.$$(perspectiveGridTable + firstFile);+ for (let i = 0; i < filesList.length; i++) {+ const tags = await extractTags(filesList[i]);+ expect(tags.includes(testTagName)).toBe(false);+ }});/*test('TST51** - Show/Hide directories in perspective view', async () => { //TODO