TagSpaces is an offline, open source, document manager with tagging support
add e2e tests
sytolkb27a90d475d7
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 5581f8a98..eee90d412 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -38,9 +38,18 @@ export async function getElementScreenshot(},) {try {- const buffer = await global.client- .locator(selector)- .screenshot({ ...options });+ /*const el = await global.client.$(selector);+ await el.waitForElementState('visible');+ const boundingBox = await el.boundingBox();*/+ const buffer = await global.client.locator(selector).screenshot({+ ...options,+ /*clip: {+ x: boundingBox.x + 5,+ y: boundingBox.y + 5,+ width: boundingBox.width - 10,+ height: boundingBox.height -10+ }*/+ });//const buffer = await el.screenshot({ ...options/*, clip: boundingBox*/ });return buffer.toString('base64');} catch (e) {diff --git a/tests/e2e/perspective-gallery.pw.e2e.js b/tests/e2e/perspective-gallery.pw.e2e.jsnew file mode 100644index 000000000..b51585c29--- /dev/null+++ b/tests/e2e/perspective-gallery.pw.e2e.js@@ -0,0 +1,71 @@+/*+ * Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.+ */+import { test } from '@playwright/test';+import {+ defaultLocationPath,+ defaultLocationName,+ createPwMinioLocation,+ createPwLocation,+} from './location.helpers';+import {+ clickOn,+ expectElementExist,+ expectElementSelected,+ getGridFileSelector,+ takeScreenshot,+} from './general.helpers';+import { startTestingApp, stopApp, testDataRefresh } from './hook';+import { clearDataStorage } from './welcome.helpers';+import { openContextEntryMenu } from './test-utils';+import { dataTidFormat } from '../../src/renderer/services/test';++test.beforeAll(async () => {+ await startTestingApp('extconfig.js');+ //await clearDataStorage();+});++test.afterAll(async () => {+ await stopApp();+});++test.afterEach(async ({ page }, testInfo) => {+ if (testInfo.status !== testInfo.expectedStatus) {+ await takeScreenshot(testInfo);+ }+ await clearDataStorage();+ await testDataRefresh();+});++test.beforeEach(async () => {+ if (global.isMinio) {+ await createPwMinioLocation('', defaultLocationName, true);+ } else {+ await createPwLocation(defaultLocationPath, defaultLocationName, true);+ }+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await clickOn('[data-tid=openGalleryPerspective]');+});++test.describe('TST51 - Perspective openGalleryPerspective', () => {+ test('TST5120 - prev/next button [web,minio,electron,_pro]', async () => {+ const fileName = 'sample.svg';+ const nextFileName = 'sample.tga';+ await clickOn(getGridFileSelector(fileName));+ await clickOn('[data-tid=perspectiveGalleryOpenFileButton]');+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',+ true,+ );+ await clickOn('[data-tid=fileContainerNextFile]');+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(nextFileName) + ']',+ true,+ );+ await clickOn('[data-tid=fileContainerPrevFile]');+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',+ true,+ );+ });+});diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.jsindex fff7afcdc..6b839b1b4 100644--- a/tests/e2e/perspective-grid-right-button.pw.e2e.js+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js@@ -30,10 +30,14 @@ import {showFilesWithTag,frameLocator,takeScreenshot,+ expectMetaFilesExist,+ getElementScreenshot,} from './general.helpers';import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';import { startTestingApp, stopApp, testDataRefresh } from './hook';import { clearDataStorage } from './welcome.helpers';+import AppConfig from '../../src/renderer/AppConfig';+import { dataTidFormat } from '../../src/renderer/services/test';const testTagName = 'testTag'; // TODO fix camelCase tag name@@ -114,29 +118,36 @@ test.describe('TST50** - Right button on a file', () => {expect(containTID).toBe(true);*/});- test('TST5017 - Rename file [web,minio,electron]', async () => {+ test('TST5017 - Rename file and check thumbnail exist [web,minio,electron]', async () => {const newFileName = 'newFileName';const fileExtension = '.txt';// await searchEngine('txt');- const sampleFileName = 'sample.txt';+ const sampleFileName = 'sample';+const oldName = await renameFileFromMenu(newFileName,- getGridFileSelector(sampleFileName),+ getGridFileSelector(sampleFileName + fileExtension),);- expect(oldName).toBe(sampleFileName);+ expect(oldName).toBe(sampleFileName + fileExtension);await expectElementExist(getGridFileSelector(newFileName + fileExtension));await expectElementExist(getGridFileSelector(oldName), false);- // const fileNameTxt = await getFirstFileName();- // expect(fileNameTxt).toContain(newFileName);+ /*const fileRenamedScreenshot = await getElementScreenshot(+ '[data-tid=fsEntryName_'+dataTidFormat(newFileName + fileExtension)+'] img',+ );*/// rename back to oldNameconst fileName = await renameFileFromMenu(- oldName,+ sampleFileName,getGridFileSelector(newFileName + fileExtension),);expect(fileName).toBe(newFileName + fileExtension);+ /*const initScreenshot = await getElementScreenshot(+ '[data-tid=fsEntryName_'+dataTidFormat(oldName)+'] img',+ );+ expect(initScreenshot).toBe(fileRenamedScreenshot);*/+ await expectMetaFilesExist([oldName + '.jpg']);});test('TST5018 - Delete file [web,minio,electron]', async () => {diff --git a/tests/e2e/perspective-grid.pw.e2e.js b/tests/e2e/perspective-grid.pw.e2e.jsindex 8a8ce7862..3a48d44a0 100644--- a/tests/e2e/perspective-grid.pw.e2e.js+++ b/tests/e2e/perspective-grid.pw.e2e.js@@ -244,6 +244,16 @@ test.describe('TST50 - Perspective Grid', () => {test.skip('TST5015 - Tag file drag&drop in perspective [manual]', async () => {});+ test('TST5048 - prev/next button [web,minio,electron]', async () => {+ const fileName = 'sample.svg';+ const nextFileName = 'sample.tga';+ await clickOn(getGridFileSelector(fileName));+ //await expectElementExist('[data-tid=fileContainerNextFile]', true, 5000);+ await clickOn('[data-tid=fileContainerNextFile]');+ await expectElementSelected(nextFileName, true);+ await clickOn('[data-tid=fileContainerPrevFile]');+ await expectElementSelected(fileName, true);+ });/* test('TST51** - Show/Hide directories in perspective view', async () => { //TODOawait global.client.waitForVisible('[data-tid=gridPerspectiveToggleShowDirectories]'diff --git a/tests/e2e/perspective-kanban.pw.e2e.js b/tests/e2e/perspective-kanban.pw.e2e.jsindex 0c018216b..21fadc359 100644--- a/tests/e2e/perspective-kanban.pw.e2e.js+++ b/tests/e2e/perspective-kanban.pw.e2e.js@@ -17,6 +17,7 @@ import {import { startTestingApp, stopApp, testDataRefresh } from './hook';import { clearDataStorage } from './welcome.helpers';import { openContextEntryMenu } from './test-utils';+import { dataTidFormat } from '../../src/renderer/services/test';test.beforeAll(async () => {await startTestingApp('extconfig.js');@@ -62,4 +63,24 @@ test.describe('TST49 - Perspective KanBan', () => {);await expectElementExist(getGridFileSelector(fileName), true);});++ test('TST4910 - prev/next button [web,minio,electron,_pro]', async () => {+ const fileName = 'sample.3gp';+ const nextFileName = 'sample.avif';+ await clickOn(getGridFileSelector(fileName));+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',+ true,+ );+ await clickOn('[data-tid=fileContainerNextFile]');+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(nextFileName) + ']',+ true,+ );+ await clickOn('[data-tid=fileContainerPrevFile]');+ await expectElementExist(+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',+ true,+ );+ });});