Skip to content

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

refactoring and optimise EditEntryTagDialog (#2297)

Stanimir9d4f328be830
diff --git a/package-lock.json b/package-lock.json
index 16405917c..2775b2bcf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -96,7 +96,7 @@
"devDependencies": {
"@electron/notarize": "^2.5.0",
"@electron/rebuild": "^3.7.1",
- "@playwright/test": "1.50.1",
+ "@playwright/test": "1.52.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@svgr/webpack": "^8.1.0",
"@teamsupercell/typings-for-css-modules-loader": "^2.5.2",
@@ -169,7 +169,7 @@
"less-loader": "^11.0.0",
"mini-css-extract-plugin": "^2.7.6",
"npm": "^8.5.5",
- "playwright": "1.50.1",
+ "playwright": "1.52.0",
"prettier": "^3.2.5",
"properties-reader": "^2.2.0",
"raw-loader": "^4.0.2",
@@ -18012,13 +18012,13 @@
}
},
"node_modules/@playwright/test": {
- "version": "1.50.1",
- "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.50.1.tgz",
- "integrity": "sha512-Jii3aBg+CEDpgnuDxEp/h7BimHcUTDlpEtce89xEumlJ5ef2hqepZ+PWp1DDpYC/VO9fmWVI1IlEaoI5fK9FXQ==",
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.52.0.tgz",
+ "integrity": "sha512-uh6W7sb55hl7D6vsAeA+V2p5JnlAqzhqFyF0VcJkKZXkgnFcVG9PziERRHQfPLfNGx1C292a4JqbWzhR8L4R1g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
- "playwright": "1.50.1"
+ "playwright": "1.52.0"
},
"bin": {
"playwright": "cli.js"
@@ -42437,13 +42437,13 @@
}
},
"node_modules/playwright": {
- "version": "1.50.1",
- "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.50.1.tgz",
- "integrity": "sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==",
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.52.0.tgz",
+ "integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
- "playwright-core": "1.50.1"
+ "playwright-core": "1.52.0"
},
"bin": {
"playwright": "cli.js"
@@ -42456,9 +42456,9 @@
}
},
"node_modules/playwright-core": {
- "version": "1.50.1",
- "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.50.1.tgz",
- "integrity": "sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==",
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.52.0.tgz",
+ "integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==",
"dev": true,
"license": "Apache-2.0",
"bin": {
diff --git a/package.json b/package.json
index 841501db7..81b362424 100644
--- a/package.json
+++ b/package.json
@@ -138,14 +138,14 @@
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
"test": "jest",
"test-clone-data": "rimraf tests/testdata && git clone https://github.com/tagspaces/testdata tests/testdata",
- "test-playwright": "npm run test-refresh-data && cross-env npx playwright test --config ./playwright.config.js -g '^(?!.*\\b_pro\\b).*\\belectron\\b.*'",
- "test-playwright-pro": "npm run test-refresh-data && cross-env npx playwright test --config ./playwright.config.js -g '/\\belectron\\b/'",
- "test-playwright-s3": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider npx playwright test --config ./playwright.config.s3.js -g '/\\bminio\\b/'",
- "test-playwright-minio": "npm run test-refresh-data && cross-env npx playwright test --config ./playwright.config.minio.js -g '/\\bminio\\b/'",
- "test-playwright-web": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider npx playwright test --config ./playwright.config.web.js -g '/\\bweb\\b/'",
- "test-playwright-web-headless": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider HEADLESS_MODE=true npx playwright test --config ./playwright.config.web.js -g '/\\bweb\\b/'",
- "test-playwright-web-minio": "npm run test-refresh-data && cross-env npx playwright test --config ./playwright.config.web.minio.js -g '/\\bweb\\b/'",
- "test-playwright-web-headless-minio": "npm run test-refresh-data && cross-env HEADLESS_MODE=true npx playwright test --config ./playwright.config.web.minio.js -g '/\\bweb\\b/'",
+ "test-playwright": "npm run test-refresh-data && cross-env npx playwright test --project=electron -g '^(?!.*\\b_pro\\b).*\\belectron\\b.*'",
+ "test-playwright-pro": "npm run test-refresh-data && cross-env npx playwright test --project=electron -g '/\\belectron\\b/'",
+ "test-playwright-s3": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider npx playwright test --project=electron-s3 -g '/\\bminio\\b/'",
+ "test-playwright-minio": "npm run test-refresh-data && cross-env npx playwright test --project=electron-minio -g '/\\bminio\\b/'",
+ "test-playwright-web": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider npx playwright test --project=web-s3",
+ "test-playwright-web-headless": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider HEADLESS_MODE=true npx playwright test --project=web-s3",
+ "test-playwright-web-minio": "npm run test-refresh-data && cross-env npx playwright test --project=web-minio",
+ "test-playwright-web-headless-minio": "npm run test-refresh-data && cross-env HEADLESS_MODE=true npx playwright test --project=web-minio",
"test-pw-web-browsers": "npm run test-refresh-data && cross-env DEBUG=pw:api npx playwright test --config ./playwright.config.web.browsers.js -g '/\\bweb\\b/'",
"test-refresh-data": "rimraf tests/testdata-tmp && shx mkdir -p tests/testdata-tmp/file-structure && shx cp -rL tests/testdata/file-structure tests/testdata-tmp && npx playwright install --with-deps",
"test-unit": "npx playwright test --config ./playwright.unit.js",
@@ -250,7 +250,7 @@
"devDependencies": {
"@electron/notarize": "^2.5.0",
"@electron/rebuild": "^3.7.1",
- "@playwright/test": "1.50.1",
+ "@playwright/test": "1.52.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@svgr/webpack": "^8.1.0",
"@teamsupercell/typings-for-css-modules-loader": "^2.5.2",
@@ -323,7 +323,7 @@
"less-loader": "^11.0.0",
"mini-css-extract-plugin": "^2.7.6",
"npm": "^8.5.5",
- "playwright": "1.50.1",
+ "playwright": "1.52.0",
"prettier": "^3.2.5",
"properties-reader": "^2.2.0",
"raw-loader": "^4.0.2",
diff --git a/playwright.config.js b/playwright.config.js
index bd2ddae8d..3b8a94056 100644
--- a/playwright.config.js
+++ b/playwright.config.js
@@ -1,13 +1,75 @@
-import { defineConfig } from '@playwright/test';
+import { defineConfig, devices } from '@playwright/test';
import pwConfig from './playwright.config.common';
-global.isWeb = false;
-global.isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
-global.isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-global.isMinio = false;
-global.isElectron = true;
-global.isUnitTest = false;
+const isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
+//const isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-const config = defineConfig(pwConfig);
+function projectTagGrep(name) {
+ // \b ensures we match whole words (so “web” doesn’t match “webhook”)
+ return new RegExp(`\\[.*\\b${name}\\b.*\\]`);
+ //return new RegExp('TST5706');
+}
-export default config;
+export default defineConfig({
+ ...pwConfig,
+ projects: [
+ {
+ name: 'electron',
+ use: {
+ isElectron: true,
+ isWeb: false,
+ isUnitTest: false,
+ isMinio: false,
+ isS3: false,
+ isWin,
+ },
+ },
+ {
+ name: 'electron-s3',
+ use: {
+ isElectron: true,
+ isWeb: false,
+ isUnitTest: false,
+ isMinio: false,
+ isS3: true,
+ isWin,
+ },
+ },
+ {
+ name: 'electron-minio',
+ use: {
+ isElectron: true,
+ isWeb: false,
+ isUnitTest: false,
+ isMinio: true,
+ isS3: false,
+ isWin,
+ },
+ },
+ {
+ name: 'web-s3',
+ grep: projectTagGrep('web'),
+ use: {
+ isElectron: false,
+ isWeb: true,
+ isUnitTest: false,
+ isMinio: false,
+ isS3: true,
+ isWin,
+ ...devices['Desktop Chrome'],
+ },
+ },
+ {
+ name: 'web-minio',
+ grep: projectTagGrep('web'),
+ use: {
+ isElectron: false,
+ isWeb: true,
+ isUnitTest: false,
+ isMinio: true,
+ isS3: false,
+ isWin,
+ },
+ },
+ ],
+});
diff --git a/playwright.config.minio.js b/playwright.config.minio.js
deleted file mode 100644
index 4b51ddaa0..000000000
--- a/playwright.config.minio.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { defineConfig } from '@playwright/test';
-import pwConfig from './playwright.config.common';
-
-global.isWeb = false;
-global.isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
-global.isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-global.isMinio = true;
-global.isS3 = false;
-global.isElectron = true;
-global.isUnitTest = false;
-
-export default defineConfig({
- ...pwConfig,
- //globalSetup: './tests/global-setup-minio.js',
- //globalTeardown: './tests/global-teardown-minio.js',
-});
diff --git a/playwright.config.s3.js b/playwright.config.s3.js
deleted file mode 100644
index b02449574..000000000
--- a/playwright.config.s3.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { defineConfig } from '@playwright/test';
-import pwConfig from './playwright.config.common';
-
-global.isWeb = false;
-global.isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
-global.isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-global.isMinio = false;
-global.isS3 = true;
-global.isElectron = true;
-global.isUnitTest = false;
-
-export default defineConfig({
- ...pwConfig,
- //globalSetup: './tests/s3rver/S3rverStart.js',
- //globalTeardown: './tests/s3rver/S3rverStop.js',
-});
diff --git a/playwright.config.web.js b/playwright.config.web.js
deleted file mode 100644
index 2c4a9e4f8..000000000
--- a/playwright.config.web.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { defineConfig } from '@playwright/test';
-import pwConfig from './playwright.config.common';
-//const dotenv = require('dotenv');
-//dotenv.config({ path: path.resolve(__dirname, 'tests', 'env', 'web.env') });
-
-global.isWeb = true;
-global.isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
-global.isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-global.isMinio = false;
-global.isS3 = true;
-global.isElectron = false;
-global.isUnitTest = false;
-
-const config = defineConfig({
- ...pwConfig,
- /*global: {
- isWeb: true,
- isWin: /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform),
- isHeadlessMode: process.env.HEADLESS_MODE === 'true',
- isMinio: false,
- isS3: true,
- isElectron: false,
- isUnitTest: false
- }*/
- // globalSetup: './tests/global-setup-web.js',
- // globalTeardown: './tests/global-teardown-web.js',
-});
-export default config;
diff --git a/playwright.config.web.minio.js b/playwright.config.web.minio.js
deleted file mode 100644
index 2c5fca780..000000000
--- a/playwright.config.web.minio.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import { defineConfig } from '@playwright/test';
-import pwConfig from './playwright.config.common';
-//const dotenv = require('dotenv');
-//dotenv.config({ path: path.resolve(__dirname, 'tests', 'env', 'web.env') });
-
-global.isWeb = true;
-global.isWin = /win32|mswin(?!ce)|mingw|bccwin|cygwin/i.test(process.platform);
-global.isHeadlessMode = process.env.HEADLESS_MODE === 'true';
-global.isMinio = true;
-global.isS3 = false;
-global.isElectron = false;
-global.isUnitTest = false;
-
-const config = defineConfig({
- ...pwConfig,
- //globalSetup: './tests/global-setup-web-minio.js',
- //globalTeardown: './tests/global-teardown-web-minio.js',
-});
-export default config;
diff --git a/src/renderer/components/dialogs/AddRemoveTagsDialog.tsx b/src/renderer/components/dialogs/AddRemoveTagsDialog.tsx
index 47b43c5ec..5e477a4ba 100644
--- a/src/renderer/components/dialogs/AddRemoveTagsDialog.tsx
+++ b/src/renderer/components/dialogs/AddRemoveTagsDialog.tsx
@@ -92,9 +92,9 @@ function AddRemoveTagsDialog(props: Props) {
}, []);
}
- const onClose = () => {
+ /*const onClose = () => {
onCloseDialog();
- };
+ };*/
const onCloseDialog = (clearSelection?: boolean) => {
setNewlyAddedTags([]);
@@ -136,7 +136,7 @@ function AddRemoveTagsDialog(props: Props) {
<Dialog
open={open}
fullScreen={smallScreen}
- onClose={onClose}
+ onClose={onCloseDialog}
keepMounted
scroll="paper"
PaperComponent={smallScreen ? Paper : DraggablePaper}
@@ -145,7 +145,7 @@ function AddRemoveTagsDialog(props: Props) {
<TsDialogTitle
dialogTitle={t('core:tagOperationTitle')}
closeButtonTestId="closeAddRemoveTagsTID"
- onClose={onClose}
+ onClose={onCloseDialog}
/>
<DialogContent
style={{
diff --git a/src/renderer/components/dialogs/EditEntryTagDialog.tsx b/src/renderer/components/dialogs/EditEntryTagDialog.tsx
index 59a82a380..ec4a51e48 100644
--- a/src/renderer/components/dialogs/EditEntryTagDialog.tsx
+++ b/src/renderer/components/dialogs/EditEntryTagDialog.tsx
@@ -59,12 +59,35 @@ function EditEntryTagDialog(props: Props) {
const { onClose, open, tag, entries } = props;
const { addTagsToFsEntries, editTagForEntry } = useTaggingActionsContext();
const [showAdvancedMode, setShowAdvancedMode] = useState<boolean>(false);
- const [title, setTitle] = useState(tag && tag.title);
- const titleRef = useRef<HTMLInputElement>(null);
- const isShowDatePeriodEditor = useMemo(() => {
+ const title = useRef<string>(); //tag && tag.title);
+
+ const [editDisabled, setEditDisabled] = useState<boolean>(
+ false, //isShowDatePeriodEditor,
+ );
+ const { setError, haveError } = useValidation();
+
+ const closeDialog = () => {
+ title.current = undefined;
+ onClose();
+ };
+ function isShowDatePeriodEditor() {
+ if (isTagChanged()) {
+ return checkIsDatePeriod(title.current);
+ }
+ return checkIsDatePeriod(tag?.title);
+ }
+
+ function isTagChanged() {
+ return title.current && title.current !== tag?.title;
+ }
+
+ function checkIsDatePeriod(tagTitle) {
+ if (!DateTagEditor) {
+ return false;
+ }
let showDatePeriodEditor = false;
- if (title && title.indexOf('-') > -1) {
- const a = title.split('-');
+ if (tagTitle && tagTitle.indexOf('-') > -1) {
+ const a = tagTitle.split('-');
if (a.length === 2) {
for (let i = 0; i < a.length; i += 1) {
if (isDateTimeTag(a[i])) {
@@ -75,19 +98,9 @@ function EditEntryTagDialog(props: Props) {
}
}
}
- } else showDatePeriodEditor = isDateTimeTag(title);
- return DateTagEditor && showDatePeriodEditor;
- }, []);
- const [editDisabled, setEditDisabled] = useState<boolean>(
- isShowDatePeriodEditor,
- );
- const { setError, haveError } = useValidation();
-
- useEffect(() => {
- if (titleRef && titleRef.current) {
- titleRef.current.value = title;
- }
- }, [title]);
+ } else showDatePeriodEditor = isDateTimeTag(tagTitle);
+ return showDatePeriodEditor;
+ }
function handleValidation(tagTitle: string) {
// Tags should be at least 1 character long and should not contain: spaces, \, / #
@@ -106,16 +119,18 @@ function EditEntryTagDialog(props: Props) {
tag.functionality === 'geoTagging' ||
tag.functionality === 'dateTagging';
if (isNew) {
- addTagsToFsEntries(entries, [{ ...tag, title }]);
+ addTagsToFsEntries(entries, [{ ...tag, title: title.current }]);
} else if (entries.length === 1) {
- editTagForEntry(entries[0].path, tag, title);
+ editTagForEntry(entries[0].path, tag, title.current);
}
- props.onClose();
+ closeDialog();
}
}
+ const setTitle = (newTitle) => (title.current = newTitle);
+
function renderContent() {
- const showGeoEditor = GeoTagEditor && isGeoTag(title);
+ const showGeoEditor = GeoTagEditor && isGeoTag(tag?.title);
return (
<DialogContent
@@ -128,20 +143,19 @@ function EditEntryTagDialog(props: Props) {
<TsTextField
error={haveError('tag')}
disabled={editDisabled}
- inputRef={titleRef}
name="title"
autoFocus
updateValue={(value) => {
setTitle(value);
}}
- retrieveValue={() => title}
+ retrieveValue={() => title.current || tag?.title}
label={t('core:editTag')}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
const { target } = event;
handleValidation(target.value);
setTitle(target.value);
}}
- defaultValue={title}
+ defaultValue={tag?.title}
data-tid="editTagEntryDialog_input"
slotProps={{
input: {
@@ -157,7 +171,7 @@ function EditEntryTagDialog(props: Props) {
</FormControl>
{showGeoEditor && (
<GeoTagEditor
- geoTag={title}
+ geoTag={tag?.title}
onChange={setTitle}
// zoom={title === defaultTagLocation ? 2 : undefined} TODO defaultTagLocation can be in MGRS format
showAdvancedMode={showAdvancedMode}
@@ -165,9 +179,10 @@ function EditEntryTagDialog(props: Props) {
setError={setError}
/>
)}
- {editDisabled && isShowDatePeriodEditor && (
- <DateTagEditor datePeriodTag={tag && tag.title} onChange={setTitle} />
- )}
+ {isShowDatePeriodEditor() &&
+ tag && ( //editDisabled
+ <DateTagEditor datePeriodTag={tag?.title} onChange={setTitle} />
+ )}
</DialogContent>
);
}
@@ -178,7 +193,7 @@ function EditEntryTagDialog(props: Props) {
<Dialog
open={open}
fullScreen={smallScreen}
- onClose={onClose}
+ onClose={closeDialog}
style={{
minWidth: 400,
height: '100%',
@@ -197,7 +212,7 @@ function EditEntryTagDialog(props: Props) {
<TsDialogTitle
dialogTitle={t('core:tagProperties')}
closeButtonTestId="closeEditEntryTagTID"
- onClose={onClose}
+ onClose={closeDialog}
/>
{renderContent()}
<TsDialogActions
@@ -205,7 +220,7 @@ function EditEntryTagDialog(props: Props) {
justifyContent: 'space-between',
}}
>
- {GeoTagEditor && isGeoTag(title) ? (
+ {GeoTagEditor && isGeoTag(tag?.title) ? (
<TsButton
data-tid="switchAdvancedModeTID"
onClick={() => setShowAdvancedMode(!showAdvancedMode)}
@@ -218,11 +233,11 @@ function EditEntryTagDialog(props: Props) {
<div />
)}
<div>
- <TsButton data-tid="closeEditTagEntryDialog" onClick={props.onClose}>
+ <TsButton data-tid="closeEditTagEntryDialog" onClick={closeDialog}>
{t('core:cancel')}
</TsButton>
<TsButton
- disabled={haveError()}
+ disabled={haveError() && !isTagChanged()}
style={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}
onClick={onConfirm}
data-tid="confirmEditTagEntryDialog"
diff --git a/src/renderer/hooks/TaggingActionsContextProvider.tsx b/src/renderer/hooks/TaggingActionsContextProvider.tsx
index ed29551f6..26bf3b774 100644
--- a/src/renderer/hooks/TaggingActionsContextProvider.tsx
+++ b/src/renderer/hooks/TaggingActionsContextProvider.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { createContext, useMemo, useReducer, useRef } from 'react';
+import React, { createContext, useCallback, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import mgrs from 'mgrs';
import { Pro } from '-/pro';
@@ -165,6 +165,25 @@ const EditEntryTagDialog = React.lazy(
),
);
+const areEqual = (prevProp, nextProp) =>
+ nextProp.open === prevProp.open &&
+ JSON.stringify(nextProp.tag) === JSON.stringify(prevProp.tag) &&
+ JSON.stringify(nextProp.entries) === JSON.stringify(prevProp.entries);
+
+const EditEntryTagDialogAsync = React.memo(
+ (props: {
+ open: boolean;
+ onClose: () => void;
+ tag: TS.Tag;
+ entries: TS.FileSystemEntry[];
+ }) => (
+ <React.Suspense fallback={<LoadingLazy />}>
+ <EditEntryTagDialog {...props} />
+ </React.Suspense>
+ ),
+ areEqual,
+);
+
export const TaggingActionsContextProvider = ({
children,
}: TaggingActionsContextProviderProps) => {
@@ -186,9 +205,11 @@ export const TaggingActionsContextProvider = ({
const { reflectUpdateMeta, setReflectActions } = useEditedEntryContext();
const { showNotification } = useNotificationContext();
- const open = useRef<boolean>(false);
- const selectedTag = useRef<TS.Tag>(undefined);
- const selectedEntries = useRef<TS.FileSystemEntry[]>(undefined);
+ const [dialogState, setDialogState] = useState<{
+ open: boolean;
+ tag?: TS.Tag;
+ entries?: TS.FileSystemEntry[];
+ }>({ open: false });
const geoTaggingFormat = useSelector(getGeoTaggingFormat);
const maxCollectedTag = useSelector(getMaxCollectedTag);
@@ -200,7 +221,7 @@ export const TaggingActionsContextProvider = ({
//const locations: CommonLocation[] = useSelector(getLocations);
const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);
const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);
- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
+ //const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const currentLocation = findLocation();
function addTagsToFilePath(path: string, tags: string[]) {
@@ -1429,25 +1450,16 @@ export const TaggingActionsContextProvider = ({
saveTagLibrary(arr);
}
- function openEditEntryTagDialog(entries: TS.FileSystemEntry[], tag: TS.Tag) {
- open.current = true;
- selectedEntries.current = entries;
- selectedTag.current = tag;
- forceUpdate();
- }
-
- function closeEditEntryTagDialog() {
- open.current = false;
- forceUpdate();
- }
+ const openEditEntryTagDialog = useCallback(
+ (entries: TS.FileSystemEntry[], tag: TS.Tag) => {
+ setDialogState({ open: true, entries, tag });
+ },
+ [],
+ );
- function EditEntryTagDialogAsync(props) {
- return (
- <React.Suspense fallback={<LoadingLazy />}>
- <EditEntryTagDialog {...props} />
- </React.Suspense>
- );
- }
+ const closeEditEntryTagDialog = useCallback(() => {
+ setDialogState({ open: false });
+ }, []);
const context = useMemo(() => {
return {
@@ -1487,12 +1499,15 @@ export const TaggingActionsContextProvider = ({
return (
<TaggingActionsContext.Provider value={context}>
- <EditEntryTagDialogAsync
- open={open.current}
- onClose={closeEditEntryTagDialog}
- tag={selectedTag.current}
- entries={selectedEntries.current}
- />
+ {dialogState.open && (
+ <EditEntryTagDialogAsync
+ open={true}
+ onClose={closeEditEntryTagDialog}
+ tag={dialogState.tag}
+ entries={dialogState.entries}
+ />
+ )}
+
{children}
</TaggingActionsContext.Provider>
);
diff --git a/src/renderer/utils/useValidation.ts b/src/renderer/utils/useValidation.ts
index 8cb6dfd86..3500b8840 100644
--- a/src/renderer/utils/useValidation.ts
+++ b/src/renderer/utils/useValidation.ts
@@ -1,34 +1,35 @@
-import { useState } from 'react';
+import { useState, useCallback, useMemo } from 'react';
export default function useValidation() {
- const [errorInput, setErrorInput] = useState<Array<string>>([]);
+ // Use a Set for fast add/remove/has
+ const [errors, setErrors] = useState<Set<string>>(() => new Set());
- /**
- * @param errorKey
- * @param add; if false = remove it
- */
- const setError = (errorKey: string, add = true): void => {
- if (add) {
- if (errorInput.length === 0) {
- setErrorInput([errorKey]);
- } else if (errorInput.indexOf(errorKey) === -1) {
- setErrorInput([...errorInput, errorKey]);
+ // Stable handler to add/remove an error key
+ const setError = useCallback((errorKey: string, add: boolean = true) => {
+ setErrors((prev) => {
+ const next = new Set(prev);
+ if (add) {
+ next.add(errorKey);
+ } else {
+ next.delete(errorKey);
}
- } else if (errorInput.indexOf(errorKey) > -1) {
- setErrorInput(errorInput.filter((err) => err !== errorKey));
- }
- };
+ return next;
+ });
+ }, []);
/**
* @param errorKey - if have error for the specified key
* if not set errorKey return if its have errors at general
*/
- const haveError = (errorKey?: string): boolean => {
- if (errorKey) {
- return errorInput.some((err) => err === errorKey);
- }
- return errorInput.length > 0;
- };
+ const haveError = useCallback(
+ (errorKey?: string): boolean => {
+ if (errorKey) {
+ return errors.has(errorKey);
+ }
+ return errors.size > 0;
+ },
+ [errors],
+ );
- return { setError, haveError };
+ return useMemo(() => ({ setError, haveError }), [setError, haveError]);
}
diff --git a/tests/e2e/file.properties.helpers.js b/tests/e2e/file.properties.helpers.js
index 7192b21d1..6b6f12225 100644
--- a/tests/e2e/file.properties.helpers.js
+++ b/tests/e2e/file.properties.helpers.js
@@ -34,7 +34,7 @@ export async function getPropertiesTags() {
*/
export async function AddRemovePropertiesTags(
tagNames = ['test-props-tag'], // TODO fix camelCase tag name
- options = { add: true, remove: true },
+ options = { add: true, remove: true, expectProp: false },
) {
if (options.add) {
for (let i = 0; i < tagNames.length; i++) {
@@ -51,7 +51,7 @@ export async function AddRemovePropertiesTags(
8000,
'[data-tid=perspectiveGridFileTable]',
);
- if (!global.isWeb) {
+ if (options.expectProp) {
// todo selecting by parent PropertiesTagsSelectTID not work for web..
await expectElementExist(
'[data-tid=tagContainer_' + tagName + ']',
diff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.js
index e31164239..00db0ea7c 100644
--- a/tests/e2e/fileopener.pw.e2e.js
+++ b/tests/e2e/fileopener.pw.e2e.js
@@ -34,7 +34,13 @@ import {
getPropertiesTags,
} from './file.properties.helpers';
import { openContextEntryMenu } from './test-utils';
-import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
+import {
+ createFile,
+ createFileS3,
+ startTestingApp,
+ stopApp,
+ testDataRefresh,
+} from './hook';
import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
import { dataTidFormat } from '../../src/renderer/services/test';
import { stopServices } from '../setup-functions';
@@ -62,14 +68,15 @@ test.afterEach(async ({ page }, testInfo) => {
await stopApp();
});
-test.beforeEach(async () => {
+test.beforeEach(async ({ isMinio, isS3, isWeb }) => {
await startTestingApp(
- global.isMinio || global.isS3 ? undefined : 'extconfig.js',
+ { isWeb, isS3 },
+ isMinio || isS3 ? undefined : 'extconfig.js',
);
- if (global.isMinio) {
+ if (isMinio) {
await closeWelcomePlaywright();
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await closeWelcomePlaywright();
await createS3Location('', defaultLocationName, true);
} else {
@@ -343,7 +350,7 @@ test.describe('TST08 - File folder properties', () => {
/**
* reload file button failed on web windows only but the problem is in test only
*/
- test('TST0812 - Reload file [electron]', async () => {
+ test('TST0812 - Reload file [electron]', async ({ isS3 }) => {
// open fileProperties
await clickOn(getGridFileSelector('sample.txt'));
//Toggle Properties
@@ -352,13 +359,20 @@ test.describe('TST08 - File folder properties', () => {
await expectFileContain();
const newFileContent = 'testing_file_content';
- await createFile('sample.txt', newFileContent, '.');
+ if (isS3) {
+ await createFileS3('sample.txt', newFileContent, '.');
+ } else {
+ await createFile('sample.txt', newFileContent, '.');
+ }
await clickOn('[data-tid=propsActionsMenuTID]');
await clickOn('[data-tid=reloadPropertiesTID]');
await expectFileContain(newFileContent, 15000);
});
- test('TST0813 - Delete file and check meta and thumbnails deleted [web,minio,electron]', async () => {
+ test('TST0813 - Delete file and check meta and thumbnails deleted [web,minio,electron]', async ({
+ isMinio,
+ isS3,
+ }) => {
const fileName = 'new_file.svg';
const svg = `<svg
xmlns="http://www.w3.org/2000/svg"
@@ -370,7 +384,11 @@ test.describe('TST08 - File folder properties', () => {
><path d="M6 2 L6 30 26 30 26 10 18 2 Z M18 2 L18 10 26 10" />
</svg>`;
await setSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);
- await createFile(fileName, svg);
+ if (isS3) {
+ await createFileS3(fileName, svg);
+ } else {
+ await createFile(fileName, svg);
+ }
await openFolder('empty_folder');
await expectElementExist(getGridFileSelector(fileName));
//await clickOn(getGridFileSelector(fileName));
@@ -379,7 +397,7 @@ test.describe('TST08 - File folder properties', () => {
'showPropertiesTID', //'fileMenuOpenFile'
);
- const tags = global.isMinio ? ['test-tag1'] : ['test-tag1', 'test-tag2'];
+ const tags = isMinio ? ['test-tag1'] : ['test-tag1', 'test-tag2'];
// add meta json to file
await AddRemovePropertiesTags(tags, {
add: true,
@@ -430,8 +448,10 @@ test.describe('TST08 - File folder properties', () => {
* TODO dont work on web tests https://trello.com/c/93iEURf4/731-migrate-fullscreen-to-https-githubcom-snakesilk-react-fullscreen
* dont work on electron Mac https://github.com/microsoft/playwright/issues/1086
*/
- test('TST0814 - Open file fullscreen and exit with close button [electron]', async () => {
- if (global.isWin) {
+ test('TST0814 - Open file fullscreen and exit with close button [electron]', async ({
+ isWin,
+ }) => {
+ if (isWin) {
// open fileProperties
await clickOn(getGridFileSelector('sample.mp4'));
await clickOn('[data-tid=propsActionsMenuTID]');
diff --git a/tests/e2e/fixtures.js b/tests/e2e/fixtures.js
index 6d98c5b80..1f3374f63 100644
--- a/tests/e2e/fixtures.js
+++ b/tests/e2e/fixtures.js
@@ -5,8 +5,25 @@ import { removeExtConfig } from './hook';
// Extend base test with a fixture for the S3 server
const test = base.extend({
- webServer: async ({}, use) => {
- if (global.isWeb) {
+ isWeb: [false, { option: true }],
+ isS3: [false, { option: true }],
+ isMinio: [false, { option: true }],
+ isWin: [false, { option: true }],
+ /* TODO
+ // 1) Launch Electron once per test (or per worker if you prefer beforeAll)
+ electronApp: async ({}, use) => {
+ const app = await electron.launch({ args: ['.'] });
+ await use(app);
+ await app.close();
+ },
+
+ // 2) Override the default `page` to be the first Electron window
+ page: async ({ electronApp }, use) => {
+ const window = await electronApp.firstWindow();
+ await use(window);
+ },*/
+ webServer: async ({ isWeb }, use) => {
+ if (isWeb) {
await removeExtConfig();
const webserver = await startWebServer();
await use(webserver);
@@ -15,8 +32,8 @@ const test = base.extend({
await use(null);
}
},
- s3Server: async ({}, use, testInfo) => {
- if (global.isS3) {
+ s3Server: async ({ isS3 }, use, testInfo) => {
+ if (isS3) {
//testInfo.title.includes('web')) {
const s3Server = await runS3Server();
await uploadTestDirectory();
@@ -27,9 +44,9 @@ const test = base.extend({
await use(null);
}
},
- minioServer: async ({}, use, testInfo) => {
- if (global.isMinio) {
- const minioProcess = await startMinio();
+ minioServer: async ({ isMinio, isWin }, use, testInfo) => {
+ if (isMinio) {
+ const minioProcess = await startMinio(isWin);
await use(minioProcess);
} else {
// If the test does not require the S3 server, just use a dummy value
diff --git a/tests/e2e/folder.pw.e2e.js b/tests/e2e/folder.pw.e2e.js
index c91dab3bf..a85bef3b3 100644
--- a/tests/e2e/folder.pw.e2e.js
+++ b/tests/e2e/folder.pw.e2e.js
@@ -29,7 +29,13 @@ import {
getAttribute,
} from './general.helpers';
import { openContextEntryMenu, renameFolder } from './test-utils';
-import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
+import {
+ createFile,
+ createFileS3,
+ startTestingApp,
+ stopApp,
+ testDataRefresh,
+} from './hook';
import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
import { emptyFolderName } from './search.helpers';
import { AddRemovePropertiesTags } from './file.properties.helpers';
@@ -40,16 +46,16 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -66,10 +72,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
await closeWelcomePlaywright();
} else {
@@ -176,8 +182,12 @@ test.describe('TST01 - Folder management', () => {
test.skip('TST0107 - Show in file manager [manual]', async () => {});
- test('TST0108 - Move folder [web,electron]', async () => {
- await createFile('file_to_move.txt', 'testing file content');
+ test('TST0108 - Move folder [web,electron]', async ({ isS3 }) => {
+ if (isS3) {
+ await createFileS3('file_to_move.txt', 'testing file content');
+ } else {
+ await createFile('file_to_move.txt', 'testing file content');
+ }
await openContextEntryMenu(
'[data-tid=fsEntryName_empty_folder]',
'fileMenuMoveCopyDirectoryTID',
@@ -196,8 +206,12 @@ test.describe('TST01 - Folder management', () => {
await testDataRefresh(s3ServerInstance);
});
- test('TST0109 - Copy folder [web,electron]', async () => {
- await createFile('file_to_copy.txt', 'testing file content');
+ test('TST0109 - Copy folder [web,electron]', async ({ isS3 }) => {
+ if (isS3) {
+ await createFileS3('file_to_copy.txt', 'testing file content');
+ } else {
+ await createFile('file_to_copy.txt', 'testing file content');
+ }
await openContextEntryMenu(
'[data-tid=fsEntryName_empty_folder]',
'fileMenuMoveCopyDirectoryTID',
@@ -253,8 +267,11 @@ test.describe('TST01 - Folder management', () => {
/**
* in old minio preSigned URL for thumbnails cannot be opened SignatureDoesNotMatch error
*/
- test('TST0114 - Use as thumbnail for parent folder [web,minio,electron,_pro]', async () => {
- if (!global.isMinio || !global.isWeb) {
+ test('TST0114 - Use as thumbnail for parent folder [web,minio,electron,_pro]', async ({
+ isMinio,
+ isWeb,
+ }) => {
+ if (!isMinio || !isWeb) {
// on Windows + Minio thumbnails is not displayed -> CORS
//await global.client.waitForTimeout(10000000);
const fileName = 'sample.png';
diff --git a/tests/e2e/folderprops.pw.e2e.js b/tests/e2e/folderprops.pw.e2e.js
index f7ed61ba4..65a851b95 100644
--- a/tests/e2e/folderprops.pw.e2e.js
+++ b/tests/e2e/folderprops.pw.e2e.js
@@ -24,7 +24,13 @@ import {
waitUntilChanged,
} from './general.helpers';
import { openContextEntryMenu } from './test-utils';
-import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
+import {
+ createFile,
+ createFileS3,
+ startTestingApp,
+ stopApp,
+ testDataRefresh,
+} from './hook';
import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
import {
AddRemovePropertiesTags,
@@ -37,15 +43,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
// await clearDataStorage();
});
@@ -63,10 +69,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
@@ -81,15 +87,21 @@ test.beforeEach(async () => {
});
test.describe('TST02 - Folder properties', () => {
- test('TST0201 - Open in main area [web,electron]', async () => {
+ test('TST0201 - Open in main area [web,electron]', async ({ isS3 }) => {
const testFile = 'file_in_empty_folder.txt';
- await createFile(testFile);
+ if (isS3) {
+ await createFileS3(testFile);
+ } else {
+ await createFile(testFile);
+ }
await clickOn('[data-tid=propsActionsMenuTID]');
await clickOn('[data-tid=openInMainAreaTID]');
await expectElementExist(getGridFileSelector(testFile), true, 5000);
});
- test('TST0204 - Reload folder from toolbar [web,electron]', async () => {
+ test('TST0204 - Reload folder from toolbar [web,electron]', async ({
+ isS3,
+ }) => {
let propsTags = await getPropertiesTags();
expect(propsTags).toHaveLength(0);
const tagTitle = 'test-tag';
@@ -109,7 +121,15 @@ test.describe('TST02 - Folder properties', () => {
],
id: '73e839b38d034a4a807971e755c17091',
};
- await createFile('tsm.json', JSON.stringify(tsmJson), 'empty_folder/.ts');
+ if (isS3) {
+ await createFileS3(
+ 'tsm.json',
+ JSON.stringify(tsmJson),
+ 'empty_folder/.ts',
+ );
+ } else {
+ await createFile('tsm.json', JSON.stringify(tsmJson), 'empty_folder/.ts');
+ }
await clickOn('[data-tid=propsActionsMenuTID]');
await clickOn('[data-tid=reloadFolderTID]');
@@ -317,7 +337,9 @@ test.describe('TST02 - Folder properties', () => {
await expectElementExist('[data-tid=gridperspectiveToolbar]', true, 5000);
});
- test('TST0218 - Set and remove predefined background gradient for folder [web,electron,_pro]', async () => {
+ test('TST0218 - Set and remove predefined background gradient for folder [web,electron,_pro]', async ({
+ isWeb,
+ }) => {
await openContextEntryMenu(
getGridFileSelector('empty_folder'),
'showProperties',
@@ -334,6 +356,7 @@ test.describe('TST02 - Folder properties', () => {
'[data-tid=backgroundTID]',
'height: 100%; background: rgba(0, 0, 0, 0.267);',
'style',
+ 15000,
);
const withBgnColorScreenshot = await getElementScreenshot(
@@ -349,9 +372,10 @@ test.describe('TST02 - Folder properties', () => {
'[data-tid=backgroundTID]',
'height: 100%; background: transparent;',
'style',
+ 15000,
);
- if (!global.isWeb) {
+ if (!isWeb) {
//todo screenshots are diff in web
const bgnRemovedScreenshot = await getElementScreenshot(
'[data-tid=perspectiveGridFileTable]',
@@ -360,7 +384,10 @@ test.describe('TST02 - Folder properties', () => {
}
});
- test('TST0219 - Set and remove predefined folder thumbnail [web,electron,_pro]', async () => {
+ test('TST0219 - Set and remove predefined folder thumbnail [web,electron,_pro]', async ({
+ isWeb,
+ isWin,
+ }) => {
const screenshotSelector = '[data-tid=fsEntryName_empty_folder]'; // > div
await openContextEntryMenu(
getGridFileSelector('empty_folder'),
@@ -386,7 +413,7 @@ test.describe('TST02 - Folder properties', () => {
const thumbRemovedScreenshot =
await getElementScreenshot(screenshotSelector);
- if (!global.isWeb && !global.isWin) {
+ if (!isWeb && !isWin) {
// thumbnails are visual equal on windows but with diff base64 screenshots
expect(initScreenshot).toBe(thumbRemovedScreenshot);
}
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index e683f2937..b8ce92833 100644
--- a/tests/e2e/general.helpers.js
+++ b/tests/e2e/general.helpers.js
@@ -109,7 +109,7 @@ export async function getAttribute(selector, attribute = 'style') {
return await element.getAttribute(attribute);
}
export async function setInputValue(selector, value) {
- global.client.fill(selector, value);
+ await global.client.locator(selector).fill(value);
}
/**
@@ -142,10 +142,10 @@ export async function typeInputValue(inputSelector, value, delay = 0) {
await global.client.type(inputSelector, value, {
delay,
});
- if (global.isWin) {
+ /*if (global.isWin) {
// todo on windows not always wait for typing value
await global.client.waitForTimeout(1000);
- }
+ }*/
return oldValue;
}
@@ -788,12 +788,16 @@ export async function expectMetaFilesExist(
}
}
-export async function writeTextInIframeInput(txt) {
+export async function writeTextInIframeInput(
+ txt,
+ editorSelector = '#monaco_editor',
+) {
const fLocator = await frameLocator();
- const monacoEditor = await fLocator.locator('#monaco_editor');
- await monacoEditor.click();
- await global.client.keyboard.press('Meta+KeyA');
- await monacoEditor.type(txt);
+ const editor = await fLocator.locator(editorSelector);
+ await editor.click();
+ //await monacoEditor.fill(txt);
+ await global.client.keyboard.press('ControlOrMeta+KeyA'); //'Meta+KeyA');
+ await editor.type(txt);
}
export async function expectFileContain(
@@ -805,6 +809,7 @@ export async function expectFileContain(
async () => {
const fLocator = await frameLocator('iframe[allowfullscreen]');
const bodyTxt = await fLocator.locator('body').innerText();
+ //console.log(bodyTxt);
return toContainTID(bodyTxt, [txtToContain]);
},
{
diff --git a/tests/e2e/general.pw.e2e.js b/tests/e2e/general.pw.e2e.js
index ed8098b1e..f1307aa55 100644
--- a/tests/e2e/general.pw.e2e.js
+++ b/tests/e2e/general.pw.e2e.js
@@ -47,15 +47,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -72,11 +72,11 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await closeWelcomePlaywright();
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await closeWelcomePlaywright();
await createS3Location('', defaultLocationName, true);
} else {
@@ -177,8 +177,11 @@ test.describe('TST51 - Perspective Grid', () => {
await expectMetaFilesExist(metaFiles);
});
- test('TST0510a - Generate thumbnail from JPG w. rotation from EXIF [web,minio,electron]', async () => {
- if (!global.isWin || !global.isWeb) {
+ test('TST0510a - Generate thumbnail from JPG w. rotation from EXIF [web,minio,electron]', async ({
+ isWin,
+ isWeb,
+ }) => {
+ if (!isWin || !isWeb) {
//todo not work on web windows
const fileName = 'sample_exif[iptc].jpg';
await clickOn(getGridFileSelector(fileName));
@@ -228,8 +231,10 @@ test.describe('TST51 - Perspective Grid', () => {
}
});
- test('TST0511 - Generate thumbnail from Videos [electron]', async () => {
- if (global.isWin) {
+ test('TST0511 - Generate thumbnail from Videos [electron]', async ({
+ isWin,
+ }) => {
+ if (isWin) {
// todo in github thumbnails not generated for videos on MacOS
//todo thumbnails not generated for ogv
const metaFiles = AppConfig.ThumbGenSupportedFileTypes.video
diff --git a/tests/e2e/hook.js b/tests/e2e/hook.js
index 32b8f4a2a..757e953fc 100644
--- a/tests/e2e/hook.js
+++ b/tests/e2e/hook.js
@@ -48,13 +48,13 @@ export function checkFileExist(filePath) {
return hasPlaywright;
};*/
-export async function clearLocalStorage() {
+export async function clearLocalStorage(isWeb) {
/*if (!(await clearStorage())) {
// TODO session is not implemented https://github.com/electron-userland/spectron/issues/117
// await global.app.webContents.session.clearStorageData();
global.app.webContents.reload();
}*/
- if (global.isWeb) {
+ if (isWeb) {
const windowHandle = await global.client.evaluateHandle(() => window);
const title = await global.client.evaluateHandle(() => document.title);
windowHandle.history.pushState('', title, windowHandle.location.pathname);
@@ -69,15 +69,18 @@ export async function clearLocalStorage() {
// global.app.client.reload(false);
}
-export async function copyExtConfig(extconfig = 'extconfig-with-welcome.js') {
+export async function copyExtConfig(
+ { isWeb, isS3 },
+ extconfig = 'extconfig-with-welcome.js',
+) {
let srcDir;
- if (global.isWeb) {
+ if (isWeb) {
srcDir = pathLib.join(
__dirname,
'..',
'..',
'scripts',
- 'web' + (global.isS3 ? 's3' : '') + extconfig,
+ 'web' + (isS3 ? 's3' : '') + extconfig,
);
if (!fse.existsSync(srcDir)) {
@@ -86,7 +89,7 @@ export async function copyExtConfig(extconfig = 'extconfig-with-welcome.js') {
'..',
'..',
'scripts',
- (global.isS3 ? 's3' : '') + extconfig,
+ (isS3 ? 's3' : '') + extconfig,
);
}
if (!fse.existsSync(srcDir)) {
@@ -98,7 +101,7 @@ export async function copyExtConfig(extconfig = 'extconfig-with-welcome.js') {
'..',
'..',
'scripts',
- (global.isS3 ? 's3' : '') + extconfig,
+ (isS3 ? 's3' : '') + extconfig,
);
if (!fse.existsSync(srcDir)) {
srcDir = pathLib.join(__dirname, '..', '..', 'scripts', extconfig);
@@ -108,20 +111,20 @@ export async function copyExtConfig(extconfig = 'extconfig-with-welcome.js') {
__dirname,
'..',
'..',
- global.isWeb ? 'web' : 'release/app/dist/renderer',
+ isWeb ? 'web' : 'release/app/dist/renderer',
'extconfig.js',
);
await fse.copy(srcDir, destDir);
}
-export async function removeExtConfig() {
- if (!global.isWeb) {
+export async function removeExtConfig(isWeb) {
+ if (!isWeb) {
await fse.remove(
pathLib.join(
__dirname,
'..',
'..',
- global.isWeb ? 'web' : 'release/app/dist/renderer',
+ isWeb ? 'web' : 'release/app/dist/renderer',
'extconfig.js',
),
);
@@ -140,9 +143,9 @@ const waitForAppLoaded = async (electronApp) => {
await waitForMainMessage(electronApp, 'startup-finished');
};
-export async function startTestingApp(extconfig) {
+export async function startTestingApp({ isWeb, isS3 }, extconfig) {
if (extconfig) {
- await copyExtConfig(extconfig);
+ await copyExtConfig({ isWeb, isS3 }, extconfig);
} else {
await removeExtConfig();
}
@@ -154,14 +157,14 @@ export async function startTestingApp(extconfig) {
'--disable-extensions',
'--window-size=1920,1080',
];
- if (global.isHeadlessMode) {
+ if (process.env.HEADLESS_MODE === 'true') {
chromeDriverArgs.push('--headless');
}
- if (global.isWeb) {
+ if (isWeb) {
const { webkit, chromium } = require('playwright');
global.app = await chromium.launch({
- headless: global.isHeadlessMode,
+ headless: process.env.HEADLESS_MODE === 'true',
slowMo: 50,
}); //browser
@@ -235,8 +238,8 @@ export async function startTestingApp(extconfig) {
}
}
-export async function stopApp() {
- if (global.isWeb) {
+export async function stopApp(isWeb) {
+ if (isWeb) {
await global.context.close();
// await global.client.closeWindow();
} else if (global.app) {
@@ -245,8 +248,8 @@ export async function stopApp() {
}
}
-export async function testDataRefresh(s3ServerInstance) {
- if (global.isS3) {
+export async function testDataRefresh(isS3, s3ServerInstance) {
+ if (isS3) {
/*if(s3ServerInstance) {
s3ServerInstance.reset();
await uploadTestDirectory();
@@ -267,17 +270,38 @@ export async function testDataRefresh(s3ServerInstance) {
}
export async function deleteTestData() {
- await fse.emptyDir(
- pathLib.join(
- __dirname,
- '..',
- 'testdata-tmp',
- 'file-structure',
- 'supported-filestypes',
- ),
+ const testDataDir = pathLib.join(
+ __dirname,
+ '..',
+ 'testdata-tmp',
+ 'file-structure',
+ 'supported-filestypes',
);
+ await fse.rm(testDataDir, {
+ recursive: true,
+ force: true,
+ maxRetries: 5, // retry on EBUSY/EMFILE/ENFILE
+ retryDelay: 100, // optional back‑off in ms
+ });
+ // await fse.emptyDir(testDataDir);
}
+export async function createFileS3(
+ fileName = 'empty_file.html',
+ fileContent = undefined,
+ rootFolder = 'empty_folder',
+) {
+ const filePath = pathLib.join(
+ __dirname,
+ '..',
+ 'testdata-tmp',
+ 'file-structure',
+ 'supported-filestypes',
+ rootFolder,
+ fileName,
+ );
+ await uploadFile(filePath, fileContent || 'test content');
+}
export async function createFile(
fileName = 'empty_file.html',
fileContent = undefined,
@@ -292,18 +316,14 @@ export async function createFile(
rootFolder,
fileName,
);
- if (global.isS3) {
- await uploadFile(filePath, fileContent || 'test content');
- } else {
- try {
- if (fileContent) {
- await fse.outputFile(filePath, fileContent);
- } else {
- await fse.createFile(filePath);
- console.log('Empty file created!');
- }
- } catch (err) {
- console.error(err);
+ try {
+ if (fileContent) {
+ await fse.outputFile(filePath, fileContent);
+ } else {
+ await fse.createFile(filePath);
+ console.log('Empty file created!');
}
+ } catch (err) {
+ console.error(err);
}
}
diff --git a/tests/e2e/html.editor.pw.e2e.js b/tests/e2e/html.editor.pw.e2e.js
new file mode 100644
index 000000000..bc3fe0e0a
--- /dev/null
+++ b/tests/e2e/html.editor.pw.e2e.js
@@ -0,0 +1,86 @@
+import { test, expect } from './fixtures';
+import {
+ createPwMinioLocation,
+ createPwLocation,
+ defaultLocationName,
+ defaultLocationPath,
+ createS3Location,
+} from './location.helpers';
+import {
+ clickOn,
+ expectElementExist,
+ expectFileContain,
+ getGridFileSelector,
+ writeTextInIframeInput,
+} from './general.helpers';
+import { startTestingApp, stopApp, testDataRefresh } from './hook';
+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
+import { dataTidFormat } from '../../src/renderer/services/test';
+import { stopServices } from '../setup-functions';
+
+let s3ServerInstance;
+let webServerInstance;
+let minioServerInstance;
+
+test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+ s3ServerInstance = s3Server;
+ webServerInstance = webServer;
+ minioServerInstance = minioServer;
+});
+
+test.afterAll(async () => {
+ await stopServices(s3ServerInstance, webServerInstance, minioServerInstance);
+});
+
+test.afterEach(async ({ page }, testInfo) => {
+ /*if (testInfo.status !== testInfo.expectedStatus) {
+ await takeScreenshot(testInfo);
+ }*/
+ await testDataRefresh(s3ServerInstance);
+ await clearDataStorage();
+ await stopApp();
+});
+
+test.beforeEach(async ({ isMinio, isS3, isWeb }) => {
+ await startTestingApp(
+ { isWeb, isS3 },
+ isMinio || isS3 ? undefined : 'extconfig.js',
+ );
+ if (isMinio) {
+ await closeWelcomePlaywright();
+ await createPwMinioLocation('', defaultLocationName, true);
+ } else if (isS3) {
+ await closeWelcomePlaywright();
+ await createS3Location('', defaultLocationName, true);
+ } else {
+ await createPwLocation(defaultLocationPath, defaultLocationName, true);
+ }
+ await clickOn('[data-tid=location_' + defaultLocationName + ']');
+ await expectElementExist(getGridFileSelector('empty_folder'), true, 8000);
+ // If its have opened file
+ // await closeFileProperties();
+});
+
+test.describe('TST56 - HTML viewer/editot', () => {
+ test('TST5603 - Save html content [web,s3,electron]', async () => {
+ // open fileProperties
+ const fileName = 'sample.html';
+ const newFileContent = 'etete5435newtextsaved';
+ await clickOn(getGridFileSelector(fileName));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',
+ true,
+ 8000,
+ );
+ await clickOn('[data-tid=fileContainerEditFile]');
+ await writeTextInIframeInput(
+ newFileContent,
+ 'div[class=note-editing-area] div[contenteditable=true]',
+ );
+ await clickOn('[data-tid=fileContainerSaveFile]');
+ await clickOn('[data-tid=cancelEditingTID]');
+ await clickOn('[data-tid=propsActionsMenuTID]');
+ await clickOn('[data-tid=reloadPropertiesTID]');
+ await expectFileContain(newFileContent, 10000);
+ });
+});
diff --git a/tests/e2e/json.editor.pw.e2e.js b/tests/e2e/json.editor.pw.e2e.js
new file mode 100644
index 000000000..2b4982a5d
--- /dev/null
+++ b/tests/e2e/json.editor.pw.e2e.js
@@ -0,0 +1,86 @@
+import { test, expect } from './fixtures';
+import {
+ createPwMinioLocation,
+ createPwLocation,
+ defaultLocationName,
+ defaultLocationPath,
+ createS3Location,
+} from './location.helpers';
+import {
+ clickOn,
+ expectElementExist,
+ expectFileContain,
+ getGridFileSelector,
+ writeTextInIframeInput,
+} from './general.helpers';
+import { startTestingApp, stopApp, testDataRefresh } from './hook';
+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
+import { dataTidFormat } from '../../src/renderer/services/test';
+import { stopServices } from '../setup-functions';
+
+let s3ServerInstance;
+let webServerInstance;
+let minioServerInstance;
+
+test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+ s3ServerInstance = s3Server;
+ webServerInstance = webServer;
+ minioServerInstance = minioServer;
+});
+
+test.afterAll(async () => {
+ await stopServices(s3ServerInstance, webServerInstance, minioServerInstance);
+});
+
+test.afterEach(async ({ page }, testInfo) => {
+ /*if (testInfo.status !== testInfo.expectedStatus) {
+ await takeScreenshot(testInfo);
+ }*/
+ await testDataRefresh(s3ServerInstance);
+ await clearDataStorage();
+ await stopApp();
+});
+
+test.beforeEach(async ({ isMinio, isS3, isWeb }) => {
+ await startTestingApp(
+ { isWeb, isS3 },
+ isMinio || isS3 ? undefined : 'extconfig.js',
+ );
+ if (isMinio) {
+ await closeWelcomePlaywright();
+ await createPwMinioLocation('', defaultLocationName, true);
+ } else if (isS3) {
+ await closeWelcomePlaywright();
+ await createS3Location('', defaultLocationName, true);
+ } else {
+ await createPwLocation(defaultLocationPath, defaultLocationName, true);
+ }
+ await clickOn('[data-tid=location_' + defaultLocationName + ']');
+ await expectElementExist(getGridFileSelector('empty_folder'), true, 8000);
+ // If its have opened file
+ // await closeFileProperties();
+});
+
+test.describe('TST57 - JSON viewer/editor', () => {
+ test('TST5706 - Save file [web,s3,electron]', async () => {
+ // open fileProperties
+ const fileName = 'sample.json';
+ const newFileContent = 'etete5435newtextsaved';
+ await clickOn(getGridFileSelector(fileName));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',
+ true,
+ 8000,
+ );
+ await clickOn('[data-tid=fileContainerEditFile]');
+ await writeTextInIframeInput(
+ newFileContent,
+ '#documentContent table[class=jsoneditor-tree]',
+ );
+ await clickOn('[data-tid=fileContainerSaveFile]');
+ await clickOn('[data-tid=cancelEditingTID]');
+ await clickOn('[data-tid=propsActionsMenuTID]');
+ await clickOn('[data-tid=reloadPropertiesTID]');
+ await expectFileContain(newFileContent, 10000);
+ });
+});
diff --git a/tests/e2e/key-bindings.pw.e2e.js b/tests/e2e/key-bindings.pw.e2e.js
index 184d34728..bdf630a31 100644
--- a/tests/e2e/key-bindings.pw.e2e.js
+++ b/tests/e2e/key-bindings.pw.e2e.js
@@ -2,7 +2,13 @@
* Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.
*/
import { test, expect } from './fixtures';
-import { defaultLocationName } from './location.helpers';
+import {
+ createPwLocation,
+ createPwMinioLocation,
+ createS3Location,
+ defaultLocationName,
+ defaultLocationPath,
+} from './location.helpers';
import {
clickOn,
expectElementExist,
@@ -20,15 +26,15 @@ let minioServerInstance;
const testFileName = 'sample.pdf';
const isMac = /^darwin/.test(process.platform);
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -45,12 +51,14 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- // if (global.isMinio) {
- // await createPwMinioLocation('', defaultLocationName, true);
- // } else {
- // await createPwLocation(defaultLocationPath, defaultLocationName, true);
- // }
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
+ await createPwMinioLocation('', defaultLocationName, true);
+ } else if (isS3) {
+ await createS3Location('', defaultLocationName, true);
+ } else {
+ await createPwLocation(defaultLocationPath, defaultLocationName, true);
+ }
await clickOn('[data-tid=location_' + defaultLocationName + ']');
await expectElementExist(getGridFileSelector('empty_folder'), true, 8000);
// If its have opened file
@@ -60,11 +68,7 @@ test.beforeEach(async () => {
test.describe('TST13 - Settings Key Bindings [electron]', () => {
test('TST1311 - Test show search [electron]', async () => {
await clickOn(selectorFile);
- if (isMac) {
- await global.client.keyboard.press('Meta+KeyK');
- } else {
- await global.client.keyboard.press('Control+KeyK');
- }
+ await global.client.keyboard.press('ControlOrMeta+KeyF'); //('ControlOrMeta+KeyK');
await expectElementExist('#textQuery', true, 2000);
});
diff --git a/tests/e2e/location.pw.e2e.js b/tests/e2e/location.pw.e2e.js
index bcc3330b3..c950b2bb9 100644
--- a/tests/e2e/location.pw.e2e.js
+++ b/tests/e2e/location.pw.e2e.js
@@ -29,11 +29,11 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- await startTestingApp('extconfig-without-locations.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig-without-locations.js');
//await clearDataStorage();
});
@@ -50,10 +50,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
+test.beforeEach(async ({ isMinio, isS3 }) => {
testLocationName = '' + new Date().getTime();
- if (global.isMinio || global.isS3) {
+ if (isMinio || isS3) {
await createPwMinioLocation('', testLocationName, true);
} else {
await createPwLocation(defaultLocationPath, testLocationName, true);
@@ -123,12 +123,16 @@ test.describe('TST03 - Testing locations:', () => {
// TODO test duplication warning on creating locations
});
- test('TST0307 - Move location Up and Down [web,electron]', async () => {
- if (global.isWeb) {
+ test('TST0307 - Move location Up and Down [web,electron]', async ({
+ isWeb,
+ isMinio,
+ isS3,
+ }) => {
+ if (isWeb) {
// in web there is no other locations
- if (global.isMinio) {
+ if (isMinio) {
await createPwMinioLocation('', 'dummyLocation', false);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('empty_folder');
}
}
diff --git a/tests/e2e/markdown-editor.pw.e2e.js b/tests/e2e/markdown-editor.pw.e2e.js
index 9bbf32431..99bc19e20 100644
--- a/tests/e2e/markdown-editor.pw.e2e.js
+++ b/tests/e2e/markdown-editor.pw.e2e.js
@@ -12,25 +12,28 @@ import {
import {
clickOn,
expectElementExist,
+ expectFileContain,
frameLocator,
getGridFileSelector,
isDisplayed,
takeScreenshot,
+ writeTextInIframeInput,
} from './general.helpers';
import { startTestingApp, stopApp, testDataRefresh } from './hook';
import { openContextEntryMenu, toContainTID } from './test-utils';
import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
import { stopServices } from '../setup-functions';
+import { dataTidFormat } from '../../src/renderer/services/test';
let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- await startTestingApp();
+ await startTestingApp({ isWeb, isS3 });
// await clearDataStorage();
});
@@ -47,11 +50,11 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
+test.beforeEach(async ({ isMinio, isS3 }) => {
await closeWelcomePlaywright();
- if (global.isMinio) {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
@@ -115,4 +118,26 @@ test.describe('TST69 - Markdown editor', () => {
);
expect(settingsExists).toBeTruthy();
});
+
+ test('TST6903 - Save text [web,s3,electron]', async () => {
+ // open fileProperties
+ const fileName = 'sample.md';
+ const newFileContent = 'etete&5435_new_text_saved';
+ await clickOn(getGridFileSelector(fileName));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',
+ true,
+ 8000,
+ );
+ await clickOn('[data-tid=fileContainerEditFile]');
+ await writeTextInIframeInput(
+ newFileContent,
+ '.milkdown div[contenteditable=true]',
+ );
+ await clickOn('[data-tid=fileContainerSaveFile]');
+ await clickOn('[data-tid=cancelEditingTID]');
+ await clickOn('[data-tid=propsActionsMenuTID]');
+ await clickOn('[data-tid=reloadPropertiesTID]');
+ await expectFileContain(newFileContent, 10000);
+ });
});
diff --git a/tests/e2e/objectstore.pw.e2e.js b/tests/e2e/objectstore.pw.e2e.js
index 689a71dd1..250a7aaeb 100644
--- a/tests/e2e/objectstore.pw.e2e.js
+++ b/tests/e2e/objectstore.pw.e2e.js
@@ -28,15 +28,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig-objectstore-location.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig-objectstore-location.js');
}
//await clearDataStorage();
});
@@ -54,8 +54,8 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isS3) {
+test.beforeEach(async ({ isS3 }) => {
+ if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await closeWelcomePlaywright();
diff --git a/tests/e2e/perspective-gallery.pw.e2e.js b/tests/e2e/perspective-gallery.pw.e2e.js
index ecd3a2bd6..f7474a122 100644
--- a/tests/e2e/perspective-gallery.pw.e2e.js
+++ b/tests/e2e/perspective-gallery.pw.e2e.js
@@ -26,15 +26,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -51,10 +51,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.js
index 23c1d0c3a..1ae5e65bf 100644
--- a/tests/e2e/perspective-grid-right-button.pw.e2e.js
+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js
@@ -48,15 +48,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -73,10 +73,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
@@ -310,8 +310,8 @@ test.describe('TST50** - Right button on a file', () => {
// await expectTagsExistBySelector(selectorFile, tags, false);
});
- test('TST5026 - Open file natively [electron]', async () => {
- if (!global.isMinio) {
+ test('TST5026 - Open file natively [electron]', async ({ isMinio }) => {
+ if (!isMinio) {
// Open file natively option is missing for Minio Location
await searchEngine('txt');
await openContextEntryMenu(selectorFile, 'fileMenuOpenFileNatively');
@@ -319,8 +319,10 @@ test.describe('TST50** - Right button on a file', () => {
// check parent directory
});
- test('TST5027 - Open containing folder [web,electron]', async () => {
- if (!global.isMinio) {
+ test('TST5027 - Open containing folder [web,electron]', async ({
+ isMinio,
+ }) => {
+ if (!isMinio) {
// Show in File Manager option is missing for Minio Location
await searchEngine('txt');
await openContextEntryMenu(selectorFile, 'fileMenuOpenContainingFolder');
diff --git a/tests/e2e/perspective-grid-sort.pw.e2e.js b/tests/e2e/perspective-grid-sort.pw.e2e.js
index 851e051f8..7c70cbf18 100644
--- a/tests/e2e/perspective-grid-sort.pw.e2e.js
+++ b/tests/e2e/perspective-grid-sort.pw.e2e.js
@@ -26,15 +26,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -50,10 +50,10 @@ test.afterAll(async () => {
}
});*/
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/perspective-grid.helpers.js b/tests/e2e/perspective-grid.helpers.js
index 92ffdd5f4..f75b8351d 100644
--- a/tests/e2e/perspective-grid.helpers.js
+++ b/tests/e2e/perspective-grid.helpers.js
@@ -1,4 +1,9 @@
-import { clickOn, typeInputValue } from './general.helpers';
+import {
+ clickOn,
+ expectElementExist,
+ setInputValue,
+ typeInputValue,
+} from './general.helpers';
import {
cleanFileName,
extractFileExtension,
@@ -24,10 +29,12 @@ export async function AddRemoveTagsToSelectedFiles(
addTag = true,
) {
await clickOn('[data-tid=' + perspective + 'PerspectiveAddRemoveTags]');
-
+ await expectElementExist('[data-tid=AddRemoveTagsSelectTID]', true, 5000);
for (let i = 0; i < tagNames.length; i++) {
const tagName = tagNames[i];
- await typeInputValue('[data-tid=AddRemoveTagsSelectTID] input', tagName, 0);
+ // if (isWin) {
+ await setInputValue('[data-tid=AddRemoveTagsSelectTID] input', tagName);
+ //await typeInputValue('[data-tid=AddRemoveTagsSelectTID] input', tagName, 0);
//await setInputKeys('AddRemoveTagsSelectTID', tagName);
await global.client.keyboard.press('Enter');
}
diff --git a/tests/e2e/perspective-grid.pw.e2e.js b/tests/e2e/perspective-grid.pw.e2e.js
index 46f79b242..0467db385 100644
--- a/tests/e2e/perspective-grid.pw.e2e.js
+++ b/tests/e2e/perspective-grid.pw.e2e.js
@@ -43,15 +43,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -68,10 +68,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/perspective-kanban.pw.e2e.js b/tests/e2e/perspective-kanban.pw.e2e.js
index 1b773be6e..afddaa3b8 100644
--- a/tests/e2e/perspective-kanban.pw.e2e.js
+++ b/tests/e2e/perspective-kanban.pw.e2e.js
@@ -27,15 +27,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -52,10 +52,10 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/quick-access.pw.e2e.js b/tests/e2e/quick-access.pw.e2e.js
index 0db6d1a76..5bace7ec7 100644
--- a/tests/e2e/quick-access.pw.e2e.js
+++ b/tests/e2e/quick-access.pw.e2e.js
@@ -30,11 +30,11 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- await startTestingApp();
+ await startTestingApp({ isWeb, isS3 });
//await clearDataStorage();
});
@@ -51,12 +51,12 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
+test.beforeEach(async ({ isMinio, isS3 }) => {
await closeWelcomePlaywright();
await clickOn('[data-tid=locationManager]');
- if (global.isMinio) {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/search.pw.e2e.js b/tests/e2e/search.pw.e2e.js
index 2a1f19156..1d03574f1 100644
--- a/tests/e2e/search.pw.e2e.js
+++ b/tests/e2e/search.pw.e2e.js
@@ -9,7 +9,13 @@ import {
selectorFile,
setSettings,
} from './general.helpers';
-import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
+import {
+ createFile,
+ createFileS3,
+ startTestingApp,
+ stopApp,
+ testDataRefresh,
+} from './hook';
import {
closeFileProperties,
closeLocation,
@@ -38,14 +44,18 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- await startTestingApp('extconfig-two-locations.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig-two-locations.js');
// await startTestingApp('extconfig-without-locations.js');
// await clearDataStorage();
- await createFile();
+ if (isS3) {
+ await createFileS3();
+ } else {
+ await createFile();
+ }
});
test.afterAll(async () => {
@@ -68,11 +78,11 @@ test.afterEach(async ({ page }, testInfo) => {
await clearDataStorage();
});
-test.beforeEach(async () => {
+test.beforeEach(async ({ isMinio, isS3 }) => {
// await closeWelcomePlaywright();
- if (global.isMinio) {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
@@ -141,8 +151,11 @@ test.describe('TST06 - Test Search in file structure:', () => {
// expected to reset all search engine
});*/
- test('TST0609 - Show thumbnails of image files in the search results [web,minio,electron]', async () => {
- if (!global.isWin || !global.isWeb) {
+ test('TST0609 - Show thumbnails of image files in the search results [web,minio,electron]', async ({
+ isWin,
+ isWeb,
+ }) => {
+ if (!isWin || !isWeb) {
//todo on web windows only test not work
await global.client.waitForSelector('img[alt="thumbnail image"]', {
visible: true,
@@ -245,6 +258,11 @@ test.describe('TST06 - Test Search in file structure:', () => {
const tags2 = ['test-tag1', 'test-tag2'];
const tags3 = ['test-tag2', 'test-tag3'];
await clickOn(getGridFileSelector('sample.' + file1));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat('sample.' + file1) + ']',
+ true,
+ 5000,
+ );
await AddRemoveTagsToSelectedFiles('grid', tags1, true);
await expectElementSelected(
@@ -255,6 +273,11 @@ test.describe('TST06 - Test Search in file structure:', () => {
const file2 = 'jpg';
await clickOn(getGridFileSelector('sample.' + file2));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat('sample.' + file2) + ']',
+ true,
+ 5000,
+ );
await AddRemoveTagsToSelectedFiles('grid', tags2, true);
await expectElementSelected(
@@ -264,6 +287,11 @@ test.describe('TST06 - Test Search in file structure:', () => {
const file3 = 'gif';
await clickOn(getGridFileSelector('sample.' + file3));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat('sample.' + file3) + ']',
+ true,
+ 5000,
+ );
await AddRemoveTagsToSelectedFiles('grid', tags3, true);
await expectElementSelected(
@@ -342,9 +370,16 @@ test.describe('TST06 - Test Search in file structure:', () => {
await expectElementExist(getGridFileSelector('sample.pdf'), true, 5000);
});
- test('TST0632 - Search q. comp - accuracy (fuzzy, semi strict, strict) [web,electron]', async () => {
- await createFile('n1ote.txt');
- await createFile('note.txt');
+ test('TST0632 - Search q. comp - accuracy (fuzzy, semi strict, strict) [web,electron]', async ({
+ isS3,
+ }) => {
+ if (isS3) {
+ await createFileS3('n1ote.txt');
+ await createFileS3('note.txt');
+ } else {
+ await createFile('n1ote.txt');
+ await createFile('note.txt');
+ }
// fuzzy
await addSearchCommand('a:', false);
await clickOn('#textQuery-option-0');
@@ -412,8 +447,14 @@ test.describe('TST06 - Test Search in file structure:', () => {
/**
* for web fulltext index is not created in tsi.json
*/
- test('TST0636 - Search q. fulltext in content [electron,_pro]', async () => {
- await createFile('fulltext.txt', 'testing fulltext');
+ test('TST0636 - Search q. fulltext in content [electron,_pro]', async ({
+ isS3,
+ }) => {
+ if (isS3) {
+ await createFileS3('fulltext.txt', 'testing fulltext');
+ } else {
+ await createFile('fulltext.txt', 'testing fulltext');
+ }
await addSearchCommand('sc:', false);
await clickOn('#textQuery-option-2');
@@ -430,11 +471,20 @@ test.describe('TST06 - Test Search in file structure:', () => {
await addRemoveTagsInSearchResults(['filename-tag5', 'filename-tag6']);
});
- test('TST0646 - Open directory from search results [web,electron]', async () => {
- await createFile(
- 'text_file.txt',
- 'testing open subfolder from search results',
- );
+ test('TST0646 - Open directory from search results [web,electron]', async ({
+ isS3,
+ }) => {
+ if (isS3) {
+ await createFileS3(
+ 'text_file.txt',
+ 'testing open subfolder from search results',
+ );
+ } else {
+ await createFile(
+ 'text_file.txt',
+ 'testing open subfolder from search results',
+ );
+ }
await addSearchCommand('empty_folder', true);
await expectElementExist(getGridFileSelector('empty_folder'), true, 5000);
await openContextEntryMenu(
diff --git a/tests/e2e/tag.pw.e2e.js b/tests/e2e/tag.pw.e2e.js
index 7482d4e29..776da517b 100644
--- a/tests/e2e/tag.pw.e2e.js
+++ b/tests/e2e/tag.pw.e2e.js
@@ -11,7 +11,13 @@ import {
setInputValue,
takeScreenshot,
} from './general.helpers';
-import { createFile, startTestingApp, stopApp, testDataRefresh } from './hook';
+import {
+ createFile,
+ createFileS3,
+ startTestingApp,
+ stopApp,
+ testDataRefresh,
+} from './hook';
import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
import {
createPwLocation,
@@ -38,15 +44,15 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- if (global.isS3) {
- await startTestingApp();
+ if (isS3) {
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
} else {
- await startTestingApp('extconfig.js');
+ await startTestingApp({ isWeb, isS3 }, 'extconfig.js');
}
});
@@ -285,19 +291,26 @@ test.describe('TST04 - Testing the tag library:', () => {
await deleteTagGroup(testGroup);
});
- test('TST0420 - Load tag groups from location [web,electron, _pro]', async () => {
+ test('TST0420 - Load tag groups from location [web,electron, _pro]', async ({
+ isS3,
+ isMinio,
+ }) => {
const tslContent =
'{"appName":"TagSpaces","appVersion":"5.3.6","description":"","lastUpdated":"2023-06-08T16:51:23.926Z","tagGroups":[{"uuid":"collected_tag_group_id","title":"Collected Tags","color":"#61DD61","textcolor":"white","children":[{"title":"Stanimir","color":"#61DD61","textcolor":"white","type":"sidecar"}],"created_date":1686119562860,"modified_date":1686243083871,"expanded":true,"locationId":"dc1ffaaeeb5747e39dd171c7e551afd6"}]}';
- await createFile('tsl.json', tslContent, '.ts');
+ if (isS3) {
+ await createFileS3('tsl.json', tslContent, '.ts');
+ } else {
+ await createFile('tsl.json', tslContent, '.ts');
+ }
await checkSettings(
'[data-tid=saveTagInLocationTID]',
true,
'[data-tid=advancedSettingsDialogTID]',
);
await clickOn('[data-tid=locationManager]');
- if (global.isMinio) {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
diff --git a/tests/e2e/test-utils.js b/tests/e2e/test-utils.js
index cc1b7262f..6ee6136d1 100644
--- a/tests/e2e/test-utils.js
+++ b/tests/e2e/test-utils.js
@@ -32,11 +32,7 @@ export async function checkFilenameForExist(filename, selector) {
}
export function toContainTID(text, tids = ['etete&5435']) {
- let pass = false;
- tids.forEach((tid) => {
- pass = text.indexOf(tid) !== -1;
- });
- return pass;
+ return tids.every((tid) => text.indexOf(tid) !== -1);
}
export async function renameFolder() {
diff --git a/tests/e2e/text.editor.pw.e2e.js b/tests/e2e/text.editor.pw.e2e.js
new file mode 100644
index 000000000..b6d0441d8
--- /dev/null
+++ b/tests/e2e/text.editor.pw.e2e.js
@@ -0,0 +1,83 @@
+import { test, expect } from './fixtures';
+import {
+ createPwMinioLocation,
+ createPwLocation,
+ defaultLocationName,
+ defaultLocationPath,
+ createS3Location,
+} from './location.helpers';
+import {
+ clickOn,
+ expectElementExist,
+ expectFileContain,
+ getGridFileSelector,
+ writeTextInIframeInput,
+} from './general.helpers';
+import { startTestingApp, stopApp, testDataRefresh } from './hook';
+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';
+import { dataTidFormat } from '../../src/renderer/services/test';
+import { stopServices } from '../setup-functions';
+
+let s3ServerInstance;
+let webServerInstance;
+let minioServerInstance;
+
+test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+ s3ServerInstance = s3Server;
+ webServerInstance = webServer;
+ minioServerInstance = minioServer;
+});
+
+test.afterAll(async () => {
+ await stopServices(s3ServerInstance, webServerInstance, minioServerInstance);
+});
+
+test.afterEach(async ({ page }, testInfo) => {
+ /*if (testInfo.status !== testInfo.expectedStatus) {
+ await takeScreenshot(testInfo);
+ }*/
+ await testDataRefresh(s3ServerInstance);
+ await clearDataStorage();
+ await stopApp();
+});
+
+test.beforeEach(async ({ isMinio, isS3, isWeb }) => {
+ await startTestingApp(
+ { isWeb, isS3 },
+ isMinio || isS3 ? undefined : 'extconfig.js',
+ );
+ if (isMinio) {
+ await closeWelcomePlaywright();
+ await createPwMinioLocation('', defaultLocationName, true);
+ } else if (isS3) {
+ await closeWelcomePlaywright();
+ await createS3Location('', defaultLocationName, true);
+ } else {
+ await createPwLocation(defaultLocationPath, defaultLocationName, true);
+ }
+ await clickOn('[data-tid=location_' + defaultLocationName + ']');
+ await expectElementExist(getGridFileSelector('empty_folder'), true, 8000);
+ // If its have opened file
+ // await closeFileProperties();
+});
+
+test.describe('TST55 - Text viewer/editor', () => {
+ test('TST5505 - Save text [web,s3,electron]', async () => {
+ // open fileProperties
+ const fileName = 'sample.txt';
+ const newFileContent = 'etete5435newtextsaved';
+ await clickOn(getGridFileSelector(fileName));
+ await expectElementExist(
+ '[data-tid=OpenedTID' + dataTidFormat(fileName) + ']',
+ true,
+ 8000,
+ );
+ await clickOn('[data-tid=fileContainerEditFile]');
+ await writeTextInIframeInput(newFileContent);
+ await clickOn('[data-tid=fileContainerSaveFile]');
+ await clickOn('[data-tid=cancelEditingTID]');
+ await clickOn('[data-tid=propsActionsMenuTID]');
+ await clickOn('[data-tid=reloadPropertiesTID]');
+ await expectFileContain(newFileContent, 10000);
+ });
+});
diff --git a/tests/e2e/viewer-audiovideo.pw.e2e.js b/tests/e2e/viewer-audiovideo.pw.e2e.js
index 1c74b85e1..6db88d410 100644
--- a/tests/e2e/viewer-audiovideo.pw.e2e.js
+++ b/tests/e2e/viewer-audiovideo.pw.e2e.js
@@ -26,12 +26,12 @@ let s3ServerInstance;
let webServerInstance;
let minioServerInstance;
-test.beforeAll(async ({ s3Server, webServer, minioServer }) => {
+test.beforeAll(async ({ isWeb, isS3, s3Server, webServer, minioServer }) => {
s3ServerInstance = s3Server;
webServerInstance = webServer;
minioServerInstance = minioServer;
- await startTestingApp();
+ await startTestingApp({ isWeb, isS3 });
await closeWelcomePlaywright();
});
@@ -46,10 +46,10 @@ test.afterAll(async () => {
await takeScreenshot(testInfo);
}
});*/
-test.beforeEach(async () => {
- if (global.isMinio) {
+test.beforeEach(async ({ isMinio, isS3 }) => {
+ if (isMinio) {
await createPwMinioLocation('', defaultLocationName, true);
- } else if (global.isS3) {
+ } else if (isS3) {
await createS3Location('', defaultLocationName, true);
} else {
await createPwLocation(defaultLocationPath, defaultLocationName, true);
@@ -72,8 +72,8 @@ test.describe('TST59 - Media player', () => {
/**
* http://localhost:63342/test-artifacts/playwright-report/trace/manifest.webmanifest?_ijt=eojod6f91jej1donf3vd1jp8ju
*/
- test('TST5902 - Play ogv file [web,minio,electron]', async () => {
- if (!global.isWin) {
+ test('TST5902 - Play ogv file [web,minio,electron]', async ({ isWin }) => {
+ if (!isWin) {
await openContextEntryMenu(
getGridFileSelector('sample.ogv'),
'fileMenuOpenFile',
diff --git a/tests/e2e/welcome.helpers.js b/tests/e2e/welcome.helpers.js
index 82918436e..a569386aa 100644
--- a/tests/e2e/welcome.helpers.js
+++ b/tests/e2e/welcome.helpers.js
@@ -1,7 +1,7 @@
import { clearStorage } from './clearstorage.helpers';
-export async function clearDataStorage() {
- if (global.isWeb) {
+export async function clearDataStorage(isWeb) {
+ if (isWeb) {
//await global.context.clearCookies();
//await global.context.clearStorageState();
await global.client.evaluate(() => {
diff --git a/tests/setup-functions.js b/tests/setup-functions.js
index 2a5b56462..67ff75c24 100644
--- a/tests/setup-functions.js
+++ b/tests/setup-functions.js
@@ -16,11 +16,11 @@ export async function globalSetup() {
sh.cd(extensionDir);
}
-export async function startMinio() {
+export async function startMinio(isWin) {
const winMinio = pathLib.resolve(__dirname, './bin/minio.exe');
const unixMinio = pathLib.resolve(__dirname, './bin/minio');
- const command = global.isWin ? winMinio : unixMinio;
+ const command = isWin ? winMinio : unixMinio;
const minioProcess = await require('child_process').spawn(command, [
'server',
pathLib.resolve(__dirname, './testdata-tmp/file-structure'),
@@ -88,10 +88,10 @@ export async function startWebServer() {
index: ['index.html'],
}),
);
- if (global.isMac) {
- //todo copyfiles do not work for MacOS
- // await app.use(serveStatic('../app'));
- }
+ //if (isMac) {
+ //todo copyfiles do not work for MacOS
+ // await app.use(serveStatic('../app'));
+ //}
app.server = app.listen(port);
console.log('Webserver listining on http://127.0.0.1:' + port);
return app;