TagSpaces is an offline, open source, document manager with tagging support
add search e2e tests
sytolkf6d85406c202
diff --git a/app/main.dev.ts b/app/main.dev.tsindex 2ffc96c01..3f214350a 100644--- a/app/main.dev.ts+++ b/app/main.dev.ts@@ -524,6 +524,11 @@ app.on('window-all-closed', () => {app.quit();});+app.on('quit', () => {+ pm2.stopAll();+ globalShortcut.unregisterAll();+});+startWS();app.on('ready', async () => {@@ -685,6 +690,14 @@ app.on('ready', async () => {}reloadApp();});++ /*process.on('SIGINT SIGTERM', () => {+ console.log('Detected SIGINT/SIGTERM');+ });++ process.on('SIGTERM', () => {+ console.log('Detected SIGTERM');+ });*/});// i18n.on('languageChanged', lng => {diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 9bdfa2258..de91e7ca4 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -177,6 +177,21 @@ export async function setInputKeys(tid, value, delay = 50) {return await setSelectorKeys('[data-tid=' + tid + ']', value);}+/**+ * Playwright only+ * @param inputSelector+ * @param value+ * @param delay+ * @returns {Promise<*>} oldValue+ */+export async function typeInputValue(inputSelector, value, delay = 50) {+ const oldValue = await global.client.inputValue(inputSelector);+ await global.client.type(inputSelector, value, {+ delay+ });+ return oldValue;+}+export async function setSelectorKeys(selector, value) {const element = await global.client.$(selector);await element.waitUntil(@@ -307,6 +322,7 @@ export async function isDisplayed(selector, displayed = true, timeout = 500) {try {const el = await global.client.waitForSelector(selector, {timeout,+ strict: true,state: displayed ? 'visible' : 'detached'});if (!displayed) {diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex 44b60c455..0fbc2ef01 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -2,6 +2,7 @@import electronPath from 'electron';import pathLib from 'path';import fse from 'fs-extra';+// import { execSync } from 'child_process';// Spectron API https://github.com/electron/spectron// Webdriver.io http://webdriver.io/api.html@@ -21,6 +22,26 @@ export const getRandomInt = (min, max) =>// the default timeout before starting every test// global.msPause = 3000;+/**+ * https://github.com/microsoft/playwright/issues/18041+ * lsof -i :49352+ * pid: number+ * Returns: boolean true if the process was started by playwright.+ */+/*export const wasProcessStartedByPlaywright = (pid) => {+ // get parent tree+ const tree = execSync(`pstree -s -h -p -t -c -p ${pid}`)+ .toString()+ .trim();++ // check if any of the parents has a command that contains the string "playwright"+ const hasPlaywright = tree.includes('playwright');++ console.log(`Process ${pid} was started by Playwright: ${hasPlaywright}`);++ return hasPlaywright;+};*/+export async function clearLocalStorage() {/*if (!(await clearStorage())) {// TODO session is not implemented https://github.com/electron-userland/spectron/issues/117diff --git a/tests/e2e/search.helpers.js b/tests/e2e/search.helpers.jsindex c88b2619f..a56d70905 100644--- a/tests/e2e/search.helpers.js+++ b/tests/e2e/search.helpers.js@@ -1,8 +1,8 @@import {clickOn,- expectElementExist,isDisplayed,setInputValue,+ typeInputValue,waitForNotification} from './general.helpers';@@ -12,6 +12,7 @@ export const searchTagDate = '201612';export const searchSubFolder = '/search';export const testFileInSubDirectory = 'sample_exif';export const testFilename = 'sample.desktop';+export const emptyFolderName = 'empty_folder';export const firstTagButton = '/tbody/tr[1]/td[3]/button[1]';/**@@ -28,7 +29,7 @@ export async function searchEngine(filename, options = {}) {if (!(await isDisplayed('#textQuery'))) {await clickOn('[data-tid=toggleSearch]');}- await setInputValue('#textQuery', filename);+ await typeInputValue('#textQuery', filename);if (!(await isDisplayed('[data-tid=searchAdvancedTID]'))) {await clickOn('[data-tid=advancedSearch]');}diff --git a/tests/e2e/search.pw.e2e.js b/tests/e2e/search.pw.e2e.jsnew file mode 100644index 000000000..b83858351--- /dev/null+++ b/tests/e2e/search.pw.e2e.js@@ -0,0 +1,133 @@+import {+ clickOn,+ expectElementExist,+ expectTagsExistBySelector,+ getGridFileSelector,+ selectorFile,+ selectRowFiles+} from './general.helpers';+import { startTestingApp, stopSpectronApp, testDataRefresh } from './hook';+import {+ createPwLocation,+ createPwMinioLocation,+ defaultLocationName,+ defaultLocationPath+} from './location.helpers';+import { emptyFolderName, searchEngine, testFilename } from './search.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';++describe('TST06 - Test Search in file structure:', () => {+ 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('TST0601 - Simple Search / filter the current folder [electron]', async () => {+ await global.client.dblclick(+ '[data-tid=fsEntryName_' + emptyFolderName + ']'+ );++ await searchEngine(testFilename); //, { reindexing: true });+ // expected current filename+ await expectElementExist(getGridFileSelector(testFilename), true, 5000);+ // await checkFilenameForExist(testFilename);+ });++ /*+ it('TST0602 - Search in sub folder: word with "?" in front of the query', async () => {+ await searchEngine('? ' + testFileInSubDirectory);+ // expected current filename+ await checkFilenameForExist(testFileInSubDirectory);+ });++ it('TST0602 - Advanced Search: word with "?" in front of the query', async () => {+ await searchEngine('? ' + testFileInSubDirectory);+ // expected current filename+ await checkFilenameForExist(testFileInSubDirectory);+ });++ it('TST0603 - Advanced Search: word with "!" symbol in front of the query', async () => {+ await searchEngine('! ' + testFileInSubDirectory);+ // expected current filename+ await checkFilenameForExist(testFileInSubDirectory);+ });++ it('TST0604 - Search for tag', async () => {+ await searchEngine('! ' + testFileInSubDirectory, searchTag);+ // expected current filename and tag+ await checkFilenameForExist(testFileInSubDirectory);+ });++ it('TST0604 - Advanced Search: word with "+" symbol in front of the query', async () => {+ await searchEngine('+ ' + testFileInSubDirectory);+ });++ it('TST0604 - Advanced Search: word and tag', async () => {+ await searchEngine('+ ' + testFileInSubDirectory);+ // expected current filename and tag+ await checkFilenameForExist(testFilename, searchTag);+ });++ it('Advanced Search: test with regex query', async () => {+ await searchEngine(regexQuery);+ // expected current filename+ await checkFilenameForExist(testFileInSubDirectory);+ });++ it('Advanced Search: reset button', async () => {+ await searchEngine(testFileInSubDirectory, searchTag, true);+ // expected to reset all search engine+ });*/++ it('TST0624 - Add/Remove sidecar tags in search results [electron]', async () => {+ await global.client.dblclick(+ '[data-tid=fsEntryName_' + emptyFolderName + ']'+ );+ await searchEngine(testFilename); //, { reindexing: true });+ // expected current filename+ await expectElementExist(getGridFileSelector(testFilename), true, 5000);++ let selectedIds = await selectRowFiles([0]);++ const tags = ['test-tag3', 'test-tag4'];+ await AddRemoveTagsToSelectedFiles(tags);++ for (let i = 0; i < selectedIds.length; i++) {+ await expectElementExist(+ // selectorFile + '[' + (i + 1) + ']//div[@id="gridCellTags"]//button[1]',+ '[data-tid=tagContainer_' + tags[0] + ']',+ true+ );+ }++ selectedIds = await selectRowFiles([0]);+ await AddRemoveTagsToSelectedFiles(tags, false);++ for (let i = 0; i < selectedIds.length; i++) {+ await expectElementExist(+ selectorFile + '[' + (i + 1) + ']//div[@id="gridCellTags"]//button[1]',+ false,+ 1500+ );+ await expectTagsExistBySelector(+ '[data-entry-id="' + selectedIds[i] + '"]',+ tags,+ false+ );+ }+ });+});