TagSpaces is an offline, open source, document manager with tagging support
fix e2e and fix reflect description edit in web
sytolk6757bf33e8a3
diff --git a/src/renderer/perspectives/grid/components/GridCell.tsx b/src/renderer/perspectives/grid/components/GridCell.tsxindex 2cf5c3828..3b1ffd18e 100644--- a/src/renderer/perspectives/grid/components/GridCell.tsx+++ b/src/renderer/perspectives/grid/components/GridCell.tsx@@ -17,6 +17,13 @@*/import AppConfig from '-/AppConfig';+import {+ extractTagsAsObjects,+ extractTitle,+ getThumbFileLocationForFile,+ cleanTrailingDirSeparator,+ cleanFrontDirSeparator,+} from '@tagspaces/tagspaces-common/paths';import {FolderOutlineIcon,MoreMenuIcon,@@ -56,11 +63,6 @@ import {formatDateTime,formatFileSize,} from '@tagspaces/tagspaces-common/misc';-import {- extractTagsAsObjects,- extractTitle,- getThumbFileLocationForFile,-} from '@tagspaces/tagspaces-common/paths';import { useEffect, useReducer, useRef } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';@@ -207,18 +209,24 @@ function GridCell(props: Props) {useEffect(() => {if (!firstRender && metaActions && metaActions.length > 0) {for (const action of metaActions) {- if (action.entry && fsEntry.path === action.entry.path) {- if (- action.action === 'thumbChange' ||- action.action === 'bgdColorChange' ||- action.action === 'descriptionChange'- ) {+ if (+ action.entry &&+ cleanTrailingDirSeparator(cleanFrontDirSeparator(fsEntry.path)) ===+ cleanTrailingDirSeparator(cleanFrontDirSeparator(action.entry.path))+ ) {+ if (action.action === 'thumbChange') {fsEntry.meta = { ...action.entry.meta };setThumbPath().then((success) => {if (success) {forceUpdate();}});+ } else if (+ action.action === 'bgdColorChange' ||+ action.action === 'descriptionChange'+ ) {+ fsEntry.meta = { ...action.entry.meta };+ forceUpdate();}}}diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 1e4138b47..9e1f0e3de 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -5,6 +5,8 @@ import AppConfig from '../../src/renderer/AppConfig';import { dataTidFormat } from '../../src/renderer/services/test';import { createFileS3, createLocalFile, delay } from './hook';import { firstFile, openContextEntryMenu, toContainTID } from './test-utils';+import { getS3File } from '../s3rver/S3DataRefresh';+import {createPwLocation,createPwMinioLocation,@@ -489,9 +491,19 @@ export async function createLocation() {await clickOn('[data-tid=locationManager]');if (isMinio) {- await createPwMinioLocation(locationPath, locationName, isDefault);+ await createPwMinioLocation(+ locationPath,+ locationName,+ isDefault,+ fullTextIndexing,+ );} else if (isS3) {- await createS3Location(locationPath, locationName, isDefault);+ await createS3Location(+ locationPath,+ locationName,+ isDefault,+ fullTextIndexing,+ );} else {await createPwLocation(pathLib.join(testDataDir, locationPath),@@ -782,7 +794,7 @@ export async function setFileTypeExtension(}export async function expectMetaFileContain(- { testDataDir },+ { testDataDir, isWeb },metaFile,rootFolder,contain,@@ -796,12 +808,16 @@ export async function expectMetaFileContain(await expectElementExist(getGridFileSelector(metaFile), true, timeout);await openFile(metaFile, 'showPropertiesTID');- await expectLocalFileContain(- { testDataDir },- metaFile,- rootFolder,- contain,- );+ if (isWeb) {+ await expectS3FileContain({ testDataDir }, metaFile, rootFolder, contain);+ } else {+ await expectLocalFileContain(+ { testDataDir },+ metaFile,+ rootFolder,+ contain,+ );+ }//await expectFileContain(contain, timeout);await clickOn('[data-tid=gridPerspectiveOnBackButton]');@@ -909,6 +925,26 @@ export async function expectLocalFileContain(expect(contentN).toContain(txtToContainN);}+export async function expectS3FileContain(+ { testDataDir },+ fileName,+ rootFolder,+ txtToContain = 'etete&5435',+) {+ const filePath = pathLib.join(testDataDir, rootFolder, fileName);++ const content = await getS3File(filePath);+ const contentN = normalized(content);+ const txtToContainN = normalized(txtToContain);++ /* if (!contentN.includes(txtToContainN)) {+ throw new Error(+ `Expected file ${filePath} to contain ${txtToContainN}, but it did not: ${contentN}`+ );+ }*/+ expect(contentN).toContain(txtToContainN);+}+export async function expectFileContain(txtToContain = 'etete&5435',timeout = 10000,diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.jsindex afd6b20f1..c25c32273 100644--- a/tests/e2e/location.helpers.js+++ b/tests/e2e/location.helpers.js@@ -24,6 +24,7 @@ export async function createPwMinioLocation(locationPath,locationName,isDefault = false,+ fullTextIndexing = false,) {const lastLocationTID = await getPwLocationTid(-1);// Check if location not exist (from extconfig.js)@@ -56,7 +57,7 @@ export async function createPwMinioLocation('[data-tid=secretAccessKey] input',minioSecretAccessKey,);*/- await setInputKeys('bucketName', locationName, 20);+ await setInputKeys('bucketName', 'supported-filestypes', 20);//await global.client.fill('[data-tid=bucketName] input', locationName);await setInputKeys('endpointURL', minioEndpointURL, 20);//await global.client.fill('[data-tid=endpointURL] input', minioEndpointURL);@@ -65,6 +66,10 @@ export async function createPwMinioLocation(await clickOn('[data-tid=switchAdvancedModeTID]');await global.client.check('[data-tid=locationIsDefault] input');}++ if (fullTextIndexing) {+ await global.client.check('[data-tid=changeFullTextIndex] input');+ }await clickOn('[data-tid=confirmLocationCreation]');}}@@ -73,6 +78,7 @@ export async function createS3Location(locationPath,locationName,isDefault = false,+ fullTextIndexing = false,) {const lastLocationTID = await getPwLocationTid(-1);// Check if location not exist (from extconfig.js)@@ -98,6 +104,9 @@ export async function createS3Location(await clickOn('[data-tid=switchAdvancedModeTID]');await global.client.check('[data-tid=locationIsDefault] input');}+ if (fullTextIndexing) {+ await global.client.check('[data-tid=changeFullTextIndex] input');+ }await clickOn('[data-tid=confirmLocationCreation]');}}diff --git a/tests/e2e/location.pw.e2e.js b/tests/e2e/location.pw.e2e.jsindex 4cbb58d8a..1f9f41ebc 100644--- a/tests/e2e/location.pw.e2e.js+++ b/tests/e2e/location.pw.e2e.js@@ -7,6 +7,7 @@ import {createPwMinioLocation,createPwLocation,createS3Location,+ defaultLocationName,} from './location.helpers';import AppConfig from '../../src/renderer/AppConfig';import {@@ -24,7 +25,7 @@ import {setInputKeys,} from './general.helpers';import { startTestingApp, stopApp } from './hook';-import { clearDataStorage } from './welcome.helpers';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';export const newLocationName = 'Location_Name_Changed';@@ -53,11 +54,14 @@ test.afterEach(async ({ page }, testInfo) => {test.beforeEach(async ({ isMinio, isS3, testDataDir }) => {testLocationName = '' + new Date().getTime();- if (isMinio || isS3) {+ if (isMinio) {await createPwMinioLocation('', testLocationName, true);+ } else if (isS3) {+ await createS3Location('', testLocationName, true);} else {await createPwLocation(testDataDir, testLocationName, true);}+await clickOn('[data-tid=location_' + testLocationName + ']');// await delay(500);// await closeFileProperties();@@ -149,9 +153,10 @@ test.describe('TST03 - Testing locations:', () => {expect(lastLocation).toBe(testLocationName);});- test('TST0328 - Creating location index WS [electron]', async ({+ test('TST0328 - Creating location index [electron]', async ({isS3,isMinio,+ isWeb,testDataDir,}) => {test.setTimeout(520000);@@ -176,6 +181,8 @@ test.describe('TST03 - Testing locations:', () => {await openFolderProp(testFolder);await addDescription(folderDesc);++ //await global.client.waitForTimeout(880000);await expectElementExist('[data-tid=gridCellDescription]',true,@@ -201,9 +208,9 @@ test.describe('TST03 - Testing locations:', () => {'[{"name":"testFolder","path":"testFolder","meta":{},"isFile":false},{"name":"test_file1[tag1 tag2].md","path":"test_file1[tag1 tag2].md","meta":{},"isFile":true,"textContent":"test md file 1","extension":"md"},{"name":"test_file2[tag3 tag4].txt","path":"test_file2[tag3 tag4].txt","meta":{},"isFile":true,"textContent":"test txt file 2","extension":"txt"}]';//await setFileTypeExtension('json');const rootFolder = locationFolderName + '/' + AppConfig.metaFolder;- //await global.client.waitForTimeout(180000);+ // await global.client.waitForTimeout(180000);await expectMetaFileContain(- { testDataDir },+ { testDataDir, isWeb },'tsi.json',rootFolder,indexFileContent,diff --git a/tests/s3rver/S3DataRefresh.js b/tests/s3rver/S3DataRefresh.jsindex 5dfdf314f..4ae8832c0 100644--- a/tests/s3rver/S3DataRefresh.js+++ b/tests/s3rver/S3DataRefresh.js@@ -2,6 +2,7 @@ const fs = require('fs');const path = require('path');const {S3Client,+ GetObjectCommand,PutObjectCommand,DeleteObjectsCommand,ListObjectsV2Command,@@ -89,6 +90,30 @@ async function deleteAllObjects(bucketName) {}}+function getS3File(filePath) {+ const key = path.relative(directoryPath, filePath).replace(/\\/g, '/'); // Normalize path separators++ const params = {+ Bucket: bucketName,+ Key: key,+ ResponseCacheControl: 'no-cache',+ };+ const s3Client = getS3Client();+ return s3Client+ .send(new GetObjectCommand(params))+ .then((data) => {+ if (data.Body) {+ return data.Body.transformToString('utf-8');+ } else {+ return '';+ }+ })+ .catch((e) => {+ console.log('getFile ' + filePath, e);+ return Promise.reject(e);+ });+}+function uploadFile(filePath, content = undefined) {const fileContent =content !== undefined ? content : fs.readFileSync(filePath);@@ -130,4 +155,5 @@ module.exports = {uploadTestDirectory,refreshS3testData,uploadFile,+ getS3File,};