Skip to content

TagSpaces is an offline, open source, document manager with tagging support

improving e2e text with extconfigs (#1266)

Stanimirba34dc02afc5
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index 947dd6696..b7769f7c3 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';
@@ -64,30 +64,30 @@ export async function setInputValue(selector, 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'
- }
+ 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'
- }
+ 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);
diff --git a/tests/e2e/hook.js b/tests/e2e/hook.js
index 80cba3011..f45305079 100644
--- a/tests/e2e/hook.js
+++ b/tests/e2e/hook.js
@@ -66,9 +66,10 @@ beforeAll(async () => {
} else {
// copy extconfig
const fse = require('fs-extra');
+ const path = require('path');
- let srcDir = '../scripts/extconfig.js';
- let destDir = '../app/extconfig.js';
+ let srcDir = path.join(__dirname, '..', '..', 'scripts', 'extconfig.js');
+ let destDir = path.join(__dirname, '..', '..', 'app', 'extconfig.js');
fse.copySync(srcDir, destDir);
}
@@ -84,7 +85,8 @@ afterAll(async () => {
} else {
// cleanup extconfig
const fse = require('fs-extra');
- fse.removeSync('../app/extconfig.js');
+ const path = require('path');
+ fse.removeSync(path.join(__dirname, '..', '..', 'app', 'extconfig.js'));
}
});
diff --git a/tests/e2e/location.e2e.js b/tests/e2e/location.e2e.js
index 22caecacf..e3efb7970 100644
--- a/tests/e2e/location.e2e.js
+++ b/tests/e2e/location.e2e.js
@@ -18,18 +18,26 @@ let testLocationName;
describe('TST03 - Testing locations:', () => {
beforeAll(async () => {
const fse = require('fs-extra');
-
- let srcDir = '../scripts/extconfig-without-locations.js';
- let destDir = '../app/extconfig.js';
+ const path = require('path');
+
+ const srcDir = path.join(
+ __dirname,
+ '..',
+ '..',
+ 'scripts',
+ 'extconfig-without-locations.js'
+ );
+ const destDir = path.join(__dirname, '..', '..', 'app', 'extconfig.js');
fse.copySync(srcDir, destDir);
});
afterAll(async () => {
const fse = require('fs-extra');
+ const path = require('path');
- let srcDir = '../scripts/extconfig.js';
- let destDir = '../app/extconfig.js';
+ const srcDir = path.join(__dirname, '..', '..', 'scripts', 'extconfig.js');
+ const destDir = path.join(__dirname, '..', '..', 'app', 'extconfig.js');
fse.copySync(srcDir, destDir);
});
@@ -111,20 +119,19 @@ describe('TST03 - Testing locations:', () => {
// TODO test duplication warning on creating locations
});
- // TODO adjust delays
it('TST0307 - Move location Up and Down [web]', async () => {
await openLocationMenu(testLocationName);
await clickOn('[data-tid=moveLocationUp]');
const prevLocation = await getLocationTid(-2);
- expect(prevLocation).toBe('location_' + testLocationName);
+ expect(prevLocation).toBe(testLocationName);
await global.client.pause(500);
await openLocationMenu(testLocationName);
await clickOn('[data-tid=moveLocationDown]');
const lastLocation = await getLocationTid(-1);
- expect(lastLocation).toBe('location_' + testLocationName);
+ expect(lastLocation).toBe(testLocationName);
});
});
/*
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.js
index ce32dfe3e..d378ae313 100644
--- a/tests/e2e/location.helpers.js
+++ b/tests/e2e/location.helpers.js
@@ -19,7 +19,7 @@ export async function createLocation(
) {
const lastLocationTID = await getLocationTid(-1);
// Check if location not exist (from extconfig.js)
- if ('location_' + locationName !== lastLocationTID) {
+ if (locationName !== lastLocationTID) {
await clickOn('[data-tid=createNewLocation]');
await clickOn('[data-tid=locationPath]');
await setInputKeys('locationPath', locationPath || defaultLocationPath);
@@ -243,14 +243,18 @@ export async function startupLocation() {
* @returns {Promise<string|null>} Location Tid ('location_' + name); example usage: getLocationName(-1) will return the last one
*/
export async function getLocationTid(locationIndex) {
+ /*const locationList = await global.client.$$(
+ '//!*[@data-tid="locationList"]/div'
+ );*/
const locationList = await global.client.$$(
- '//*[@data-tid="locationList"]/div'
+ '[data-tid=locationTitleElement]'
);
- let location =
+ const location =
locationIndex < 0
? locationList[locationList.length + locationIndex]
: locationList[locationIndex];
- location = await location.$('li');
- location = await location.$('div');
- return location.getAttribute('data-tid');
+ // location = await location.$('li');
+ // location = await location.$('div');
+ // return location.getAttribute('data-tid');
+ return location.getText();
}
diff --git a/tests/e2e/perspective-grid.e2e.js b/tests/e2e/perspective-grid.e2e.js
index 6e8dab5c3..7a2c48f73 100644
--- a/tests/e2e/perspective-grid.e2e.js
+++ b/tests/e2e/perspective-grid.e2e.js
@@ -198,6 +198,7 @@ describe('TST50 - Perspective Grid', () => {
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);
const propsNewTags = await getPropertiesTags();