Skip to content

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

add search tests

sytolkbb71c2063311
diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsx
index 65f86ed67..b22d19d45 100644
--- a/app/components/WelcomePanel.tsx
+++ b/app/components/WelcomePanel.tsx
@@ -373,6 +373,7 @@ function WelcomePanel(props: Props) {
return (
<div
+ data-tid="WelcomePanelTID"
style={{
overflow: 'hidden',
position: 'relative',
diff --git a/playwright.config.common.js b/playwright.config.common.js
index cf6aa542a..0dd5a1c4e 100644
--- a/playwright.config.common.js
+++ b/playwright.config.common.js
@@ -11,7 +11,7 @@ const pwConfig = {
// (3 hours) Maximum time in milliseconds the whole test suite can run. Useful on CI to prevent broken setup from running too long and wasting resources.
globalTimeout: process.env.CI ? 3 * 60 * 60 * 1000 : undefined,
ignoreSnapshots: !process.env.CI,
- retries: process.env.CI ? 3 : 1,
+ retries: process.env.CI ? 3 : 0,
// The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error
maxFailures: process.env.CI ? 8 : 0,
globalSetup: './tests/global-setup.js',
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.js
index 331a3e98c..52bc001c2 100644
--- a/tests/e2e/location.helpers.js
+++ b/tests/e2e/location.helpers.js
@@ -99,11 +99,12 @@ export async function openLocationMenu(locationName) {
export async function closeLocation(locationName) {
const locationSelector = '[data-tid=locationMoreButton_' + locationName + ']';
- const element = await global.client.$(locationSelector);
- if (!(await element.isDisplayed())) {
- await clickOn('[data-tid=locationManagerPanel]');
+ //const element = await global.client.$(locationSelector);
+ // if (!(await element.isDisplayed())) {
+ if (!(await isDisplayed(locationSelector))) {
+ await clickOn('[data-tid=mobileMenuButton]');
}
- await global.client.pause(500);
+ // await global.client.pause(500);
await clickOn(locationSelector);
await clickOn('[data-tid=closeLocationTID]');
}
diff --git a/tests/e2e/search.helpers.js b/tests/e2e/search.helpers.js
index 0de64cd7a..2bbcb982d 100644
--- a/tests/e2e/search.helpers.js
+++ b/tests/e2e/search.helpers.js
@@ -1,11 +1,12 @@
import {
- clickOn,
- isDisplayed,
+ clickOn, expectElementExist, expectTagsExistBySelector, getGridFileSelector, isDisabled,
+ isDisplayed, selectorFile, selectRowFiles,
setInputKeys,
setInputValue,
typeInputValue,
waitForNotification
-} from './general.helpers';
+} from "./general.helpers";
+import { AddRemoveTagsToSelectedFiles } from "./perspective-grid.helpers";
export const regexQuery = '!"#$%&\'()*+,-./@:;<=>[\\]^_`{|}~';
export const searchTag = 'tag1';
@@ -79,64 +80,44 @@ export async function createSavedSearch(searchQuery) {
await clickOn('[data-tid=closeSearchTID]');
}
-/*describe('TST06 - Test Search in file structure:', () => {
- beforeEach(async () => {
- await clearLocalStorage();
- await delay(500);
- await createLocation(defaultLocationPath, defaultLocationName, false);
- await delay(500);
- await openLocation(defaultLocationName);
- await delay(500);
- });
-
- it('TST0601 - Simple Search / filter the current folder', async () => {
- await searchEngine(testFilename);
- // expected current filename
- 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);
- });
+export async function addRemoveTagsInSearchResults(
+ tags = ['test-tag3', 'test-tag4']
+) {
+ await global.client.dblclick(
+ '[data-tid=fsEntryName_' + emptyFolderName + ']'
+ );
+ await searchEngine(testFilename); //, { reindexing: true });
+ // expected current filename
+ await expectElementExist(getGridFileSelector(testFilename), true, 5000);
- it('TST0604 - Advanced Search: word with "+" symbol in front of the query', async () => {
- await searchEngine('+ ' + testFileInSubDirectory);
- });
+ let selectedIds = await selectRowFiles([0]);
- it('TST0604 - Advanced Search: word and tag', async () => {
- await searchEngine('+ ' + testFileInSubDirectory);
- // expected current filename and tag
- await checkFilenameForExist(testFilename, searchTag);
- });
+ await AddRemoveTagsToSelectedFiles(tags);
- it('Advanced Search: test with regex query', async () => {
- await searchEngine(regexQuery);
- // expected current filename
- await checkFilenameForExist(testFileInSubDirectory);
- });
+ for (let i = 0; i < selectedIds.length; i++) {
+ await expectElementExist(
+ // selectorFile + '[' + (i + 1) + ']//div[@id="gridCellTags"]//button[1]',
+ '[data-tid=tagContainer_' + tags[0] + ']',
+ true,
+ 5000
+ );
+ }
+ if (await isDisabled('[data-tid=gridPerspectiveAddRemoveTags]')) {
+ //select rows to enable button
+ selectedIds = await selectRowFiles([0]);
+ }
+ await AddRemoveTagsToSelectedFiles(tags, false);
- it('Advanced Search: reset button', async () => {
- await searchEngine(testFileInSubDirectory, searchTag, true);
- // expected to reset all search engine
- });
-});*/
+ 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
+ );
+ }
+}
diff --git a/tests/e2e/search.pw.e2e.js b/tests/e2e/search.pw.e2e.js
index 1317b4221..d1c6d52d5 100644
--- a/tests/e2e/search.pw.e2e.js
+++ b/tests/e2e/search.pw.e2e.js
@@ -2,24 +2,30 @@ import { expect, test } from '@playwright/test';
import {
clickOn,
expectElementExist,
- expectTagsExistBySelector,
+ getGridFileName,
getGridFileSelector,
- isDisabled,
- selectorFile,
- selectRowFiles,
setSettings,
takeScreenshot
} from './general.helpers';
import { startTestingApp, stopApp, testDataRefresh } from './hook';
import {
+ closeFileProperties,
+ closeLocation,
createPwLocation,
createPwMinioLocation,
defaultLocationName,
- defaultLocationPath
+ defaultLocationPath,
+ getPwLocationTid
} from './location.helpers';
-import { emptyFolderName, searchEngine, testFilename } from './search.helpers';
-import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';
+import {
+ emptyFolderName,
+ searchEngine,
+ testFilename,
+ addRemoveTagsInSearchResults
+} from './search.helpers';
import { init } from './welcome.helpers';
+import { openContextEntryMenu } from './test-utils';
+import { dataTidFormat } from '../../app/services/test';
test.beforeAll(async () => {
await startTestingApp('extconfig-with-welcome.js');
@@ -50,7 +56,7 @@ test.beforeEach(async () => {
});
test.describe('TST06 - Test Search in file structure:', () => {
- test('TST0601 - Simple Search / filter the current folder [electron]', async () => {
+ test('TST0601 - Search in current location [web,electron]', async () => {
await global.client.dblclick(
'[data-tid=fsEntryName_' + emptyFolderName + ']'
);
@@ -107,54 +113,49 @@ test.describe('TST06 - Test Search in file structure:', () => {
// expected to reset all search engine
});*/
- async function addRemoveTagsInSearchResults(
- tags = ['test-tag3', 'test-tag4']
- ) {
- await global.client.dblclick(
- '[data-tid=fsEntryName_' + emptyFolderName + ']'
+ test('TST0621 - Search actions - open location [web,electron]', async () => {
+ const lastLocationTID = await getPwLocationTid(-1);
+ await closeLocation(lastLocationTID);
+ await expectElementExist('[data-tid=WelcomePanelTID]', true);
+ await searchEngine('l:', {}, false);
+ await clickOn('#textQuery-option-0');
+ await clickOn('[data-tid=folderContainerOpenDirMenu]');
+ await clickOn('[data-tid=showProperties]');
+ await expectElementExist(
+ '[data-tid=OpenedTID' + lastLocationTID + ']',
+ true
);
- await searchEngine(testFilename); //, { reindexing: true });
- // expected current filename
- await expectElementExist(getGridFileSelector(testFilename), true, 5000);
+ });
- let selectedIds = await selectRowFiles([0]);
-
- 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,
- 5000
- );
- }
- if (await isDisabled('[data-tid=gridPerspectiveAddRemoveTags]')) {
- //select rows to enable button
- 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
- );
- }
- }
+ test('TST0622 - Search actions - filter [web,electron]', async () => {
+ await searchEngine('f:txt', {}, false);
+ const file = await getGridFileName(0);
+ expect(file).toContain('txt');
+ });
+
+ test('TST0623 - Search actions - history [web,electron]', async () => {
+ const file = 'sample.txt';
+ // add file to history
+ await openContextEntryMenu(
+ '[data-tid="fsEntryName_' + file + '"]',
+ 'fileMenuOpenFile'
+ );
+ await closeFileProperties();
+
+ await searchEngine('h:', {}, false);
+ await clickOn('#textQuery-option-0');
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat(file) + ']',
+ true
+ );
+ });
- test('TST0624 - Add/Remove sidecar tags in search results [electron]', async () => {
+ test('TST0639 - Add/Remove sidecar tags in search results [web,electron]', async () => {
await setSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);
await addRemoveTagsInSearchResults(['sidecar-tag5', 'sidecar-tag6']);
});
- test('TST0625 - Add/Remove filename tags in search results [electron]', async () => {
+ test('TST0640 - Add/Remove filename tags in search results [web,electron]', async () => {
await addRemoveTagsInSearchResults(['filename-tag5', 'filename-tag6']);
});
});