TagSpaces is an offline, open source, document manager with tagging support
Execute E2E tests in a single electron/webdriver run (#1276)
Stanimir87a369c10693
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.ymlindex be64f3a4d..5c5c78aee 100644--- a/.github/workflows/pull_request.yml+++ b/.github/workflows/pull_request.yml@@ -37,6 +37,11 @@ jobs:uses: actions/checkout@v2with:submodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -49,31 +54,31 @@ jobs:run: yarn test-unit- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-electron- # gitHubActionForNpmMac:- # name: Validating MacOS- # runs-on: macos-latest- # steps:- # - name: Checking out default branch- # uses: actions/checkout@v2- # with:- # submodules: true- # - uses: actions/setup-node@v2-beta- # with:- # node-version: '10.x'- # - name: Running yarn install, prettier and type checks- # run: |- # yarn install --check-files --cache-folder .ycache- # yarn prettier-check- # yarn type-check- # - name: Run Unit tests- # run: yarn test-unit- # - name: Run Electron tests- # run: |- # yarn setup-ext- # yarn build-main- # yarn build-e2e- # yarn test-e2e-electron+ # gitHubActionForNpmMac:+ # name: Validating MacOS+ # runs-on: macos-latest+ # steps:+ # - name: Checking out default branch+ # uses: actions/checkout@v2+ # with:+ # submodules: true+ # - uses: actions/setup-node@v2-beta+ # with:+ # node-version: '10.x'+ # - name: Running yarn install, prettier and type checks+ # run: |+ # yarn install --check-files --cache-folder .ycache+ # yarn prettier-check+ # yarn type-check+ # - name: Run Unit tests+ # run: yarn test-unit+ # - name: Run Electron tests+ # run: |+ # yarn install-ext+ # yarn build-main+ # yarn build-e2e+ # yarn test-e2e-electrondiff --git a/.github/workflows/workflow_dispatch.yml b/.github/workflows/workflow_dispatch.ymlindex dea4bb32e..67b973afe 100644--- a/.github/workflows/workflow_dispatch.yml+++ b/.github/workflows/workflow_dispatch.yml@@ -3,18 +3,29 @@ on:workflow_dispatch:inputs:command:- description: 'Command to execute e2e tests default: yarn test-e2e-electron'+ description: 'Command to execute e2e tests default: yarn test-e2e-electron-minio'required: true- default: 'test-one'+ default: 'test-e2e-electron-minio'jobs:e2eTests:- runs-on: macos-latest+ runs-on: windows-lateststeps:- name: Checking out default branchuses: actions/checkout@v2with:submodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata+ - name: Checkout TagspacesPro+ uses: actions/checkout@v2+ with:+ repository: tagspaces/tagspacespro+ token: ${{ secrets.CHECKOUT_TSPRO }}+ path: extensions/tagspacespro- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -25,9 +36,15 @@ jobs:yarn type-check- name: Run Unit testsrun: yarn test-unit+ - uses: suisei-cn/actions-download-file@v1+ id: minio+ name: Download the Minio.exe+ with:+ url: 'https://dl.min.io/server/minio/release/windows-amd64/minio.exe'+ target: tests/bin/- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn ${{ github.event.inputs.command }}diff --git a/.github/workflows/workflow_scheduled.yml b/.github/workflows/workflow_scheduled.ymlindex e53c976f2..6956c36e8 100644--- a/.github/workflows/workflow_scheduled.yml+++ b/.github/workflows/workflow_scheduled.yml@@ -14,6 +14,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -26,7 +31,7 @@ jobs:run: yarn test-unit- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-electron@@ -41,6 +46,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -59,7 +69,7 @@ jobs:target: tests/bin/- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-electron-minio@@ -74,6 +84,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -92,7 +107,7 @@ jobs:target: tests/bin/- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-web@@ -106,6 +121,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -118,7 +138,7 @@ jobs:run: yarn test-unit- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-electron@@ -132,6 +152,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -144,7 +169,7 @@ jobs:run: yarn test-unit- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-electron-minio@@ -158,6 +183,11 @@ jobs:with:ref: developsubmodules: true+ - name: Checkout TestData+ uses: actions/checkout@v2+ with:+ repository: tagspaces/testdata+ path: tests/testdata- uses: actions/setup-node@v2-betawith:node-version: '10.x'@@ -170,7 +200,7 @@ jobs:run: yarn test-unit- name: Run Electron testsrun: |- yarn setup-ext+ yarn install-extyarn build-mainyarn build-e2eyarn test-e2e-webdiff --git a/.gitignore b/.gitignoreindex 05d73dd48..4dc1042b1 100644--- a/.gitignore+++ b/.gitignore@@ -91,6 +91,11 @@ tests/*!tests/e2e/!tests/minioEnv.js!tests/webEnv.js+!tests/global-setup.js+!tests/global-setup-minio.js+!tests/global-teardown.js+!tests/global-teardown-minio.js+!tests/setup-after-env.jsbuilds/*web/sw-condiff --git a/.prettierignore b/.prettierignoreindex 1b682d51b..4e8ddee0a 100755--- a/.prettierignore+++ b/.prettierignore@@ -13,5 +13,6 @@ dllapp/utils/js-webdav-client.jscoveragetests/testdata+tests/testdata-tmptests/file-structure.ycachediff --git a/app/components/dialogs/settings/SettingsDialog.tsx b/app/components/dialogs/settings/SettingsDialog.tsxindex a4fbf6a46..8d3a001ae 100644--- a/app/components/dialogs/settings/SettingsDialog.tsx+++ b/app/components/dialogs/settings/SettingsDialog.tsx@@ -64,6 +64,10 @@ const SettingsDialog = (props: Props) => {const [isConfirmDialogOpened, setIsConfirmDialogOpened] = useState<boolean>(false);+ const [+ isResetSettingsDialogOpened,+ setIsResetSettingsDialogOpened+ ] = useState<boolean>(false);const settingsFileTypeRef = useRef<HTMLDivElement>(null);useEffect(() => {@@ -227,12 +231,40 @@ const SettingsDialog = (props: Props) => {/>)}+ {isResetSettingsDialogOpened && (+ <ConfirmDialog+ open={isResetSettingsDialogOpened}+ onClose={() => {+ setIsResetSettingsDialogOpened(false);+ }}+ title="Confirm"+ content={i18n.t('core:confirmResetSettings')}+ confirmCallback={result => {+ if (result) {+ localStorage.clear();+ // eslint-disable-next-line no-restricted-globals+ location.reload();++ /* const electron = window.require('electron');+ const webContents = electron.remote.getCurrentWebContents();+ webContents.session.clearStorageData();+ webContents.reload(); */+ }+ }}+ cancelDialogTID="cancelResetSettingsDialogTID"+ confirmDialogTID="confirmResetSettingsDialogTID"+ confirmDialogContentTID="confirmResetSettingsDialogContentTID"+ />+ )}+<divdata-tid="settingsDialog"className={props.classes.mainContent}ref={settingsFileTypeRef}>- {currentTab === 0 && <SettingsGeneral />}+ {currentTab === 0 && (+ <SettingsGeneral showResetSettings={setIsResetSettingsDialogOpened} />+ )}{currentTab === 1 && (<SettingsFileTypesitems={items}@@ -262,6 +294,7 @@ const SettingsDialog = (props: Props) => {data-tid="addNewFileTypeTID"onClick={() => onAddFileType()}color="secondary"+ style={{ float: 'left' }}>{i18n.t('core:addNewFileType')}</Button>diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsxindex 4650bb8a3..ee9284d99 100644--- a/app/components/dialogs/settings/SettingsGeneral.tsx+++ b/app/components/dialogs/settings/SettingsGeneral.tsx@@ -33,7 +33,8 @@ import { actions as SettingsActions, getSettings } from '-/reducers/settings';import ColorPickerDialog from '../ColorPickerDialog';import TransparentBackground from '../../TransparentBackground';-const styles = theme => ({+const styles: any = (theme: any) => ({+ // const styles = theme => ({root: {overflowX: 'hidden'},@@ -66,6 +67,7 @@ interface Props {setTagDelimiter: (tagDelimiter: string) => void;setMaxSearchResult: (maxResult: string) => void;setDesktopMode: (desktopMode: boolean) => void;+ showResetSettings: (showDialog: boolean) => void;}interface State {@@ -315,6 +317,16 @@ class SettingsGeneral extends React.Component<Props, State> {checked={this.props.settings.loadsLocationMetaData}/></ListItem> */}+ <ListItem className={classes.listItem}>+ <Button+ data-tid="resetSettingsTID"+ onClick={() => this.props.showResetSettings(true)}+ color="secondary"+ style={{ marginLeft: -7 }}+ >+ {i18n.t('core:resetSettings')}+ </Button>+ </ListItem></List>);}@@ -355,4 +367,4 @@ export default connect(mapStateToProps,mapActionCreatorsToProps// @ts-ignore-)(withStyles(styles)(SettingsGeneral));+)(withStyles(styles, { withTheme: true })(SettingsGeneral));diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex fa3fdbd9a..05c89b7f4 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -278,6 +278,8 @@"moveDown": "Move Down","chooseSearchQuery": "Choose a search query","closeButton": "Close",+ "resetSettings": "Restore Default Settings",+ "confirmResetSettings": "Attention!!! Confirming this dailog will irreversible remove all connected locations, all the tags from the tag library and will restore the default settings of the app. Do you want to proceed?","minimize": "Minimize","closeAndClear": "Close & Clear","addNewFileType": "Add new file type",diff --git a/app/pro/index.ts b/app/pro/index.tsindex dbf67d160..81db6ed46 100644--- a/app/pro/index.ts+++ b/app/pro/index.ts@@ -19,7 +19,7 @@let tsPro;try {- tsPro = require('../../extensions/pro');+ tsPro = require('../../extensions/tagspacespro');} catch (e) {if (e && e.code && e.code === 'MODULE_NOT_FOUND') {console.log('PRO functionality not available');diff --git a/jest.config.js b/jest.config.jsindex 18a83ec52..1dbfaa9bf 100644--- a/jest.config.js+++ b/jest.config.js@@ -35,7 +35,29 @@ module.exports = async () => {return {rootDir: './tests',verbose: true,- setupFiles: ['../scripts/setup-tests.js'],+ /**+ * setupFiles: ran once per test file before all tests+ * https://jestjs.io/docs/en/configuration#setupfiles-array+ */+ // setupFiles: ['../scripts/setup-tests.js'],+ /**+ * setupFilesAfterEnv: ran before each test+ *+ * https://jestjs.io/docs/en/configuration#setupfilesafterenv-array+ */+ setupFilesAfterEnv: ['./setup-after-env.js'],+ /**+ * globalSetup: ran once before all tests+ *+ * https://jestjs.io/docs/en/configuration#globalsetup-string+ */+ globalSetup: './global-setup.js',+ /**+ * globalTeardown: ran once after all tests+ *+ * https://jestjs.io/docs/en/configuration#globalteardown-string+ */+ globalTeardown: './global-teardown.js',moduleNameMapper: {'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':'<rootDir>/internals/mocks/fileMock.js',diff --git a/jest.config.minio.js b/jest.config.minio.jsnew file mode 100644index 000000000..a2e8daed5--- /dev/null+++ b/jest.config.minio.js@@ -0,0 +1,86 @@+// const sh = require('shelljs');+const branchName = require('current-git-branch');++const isWin = /^win/.test(process.platform);+const isMac = /^darwin/.test(process.platform);+const isLinux = /^linux/.test(process.platform);+let os = '';+if (isWin) {+ os = '_win';+} else if (isMac) {+ os = '_macos';+} else if (isLinux) {+ os = '_linux';+}+const web = process.env.NODE_JEST === 'test_web' ? '_web' : '';+const minio = process.env.NODE_JEST === 'test_minio' ? '_minio' : '';++module.exports = async () => {+ /* const BRANCH_NAME = await new Promise((resolve, reject) => {+ sh.exec(+ 'git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3',+ (code, stdout, stderr) => {+ if (code !== 0) {+ const e = new Error();+ e.message = stderr;+ e.name = String(code);+ reject(e);+ } else {+ resolve(stdout);+ }+ }+ );+ }); */+ const BRANCH_NAME = branchName();+ return {+ rootDir: './tests',+ verbose: true,+ /**+ * setupFiles: ran once per test file before all tests+ * https://jestjs.io/docs/en/configuration#setupfiles-array+ */+ // setupFiles: ['../scripts/setup-tests.js'],+ /**+ * setupFilesAfterEnv: ran before each test+ *+ * https://jestjs.io/docs/en/configuration#setupfilesafterenv-array+ */+ setupFilesAfterEnv: ['./setup-after-env.js'],+ /**+ * globalSetup: ran once before all tests+ *+ * https://jestjs.io/docs/en/configuration#globalsetup-string+ */+ globalSetup: './global-setup-minio.js',+ /**+ * globalTeardown: ran once after all tests+ *+ * https://jestjs.io/docs/en/configuration#globalteardown-string+ */+ globalTeardown: './global-teardown-minio.js',+ moduleNameMapper: {+ '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':+ '<rootDir>/internals/mocks/fileMock.js',+ '\\.(css|less|sass|scss)$': 'identity-obj-proxy'+ },+ moduleFileExtensions: ['js', 'ts', 'tsx'],+ moduleDirectories: ['node_modules', 'app/node_modules'],+ testMatch: [+ '**/{unit,e2e,app,test,integration}/**/*.{test,e2e}.{js,tsx,ts,tsx}'+ ],+ testPathIgnorePatterns: ['<rootDir>/extensions'],+ reporters: [+ 'default',+ [+ '../node_modules/jest-html-reporter',+ {+ pageTitle: BRANCH_NAME + ' Test Report',+ outputPath:+ './test-reports/' + BRANCH_NAME + os + web + minio + '.html'+ }+ ]+ ],+ collectCoverage: true,+ maxWorkers: 1+ };+};diff --git a/package.json b/package.jsonindex 1001d81a6..c7f0b88a4 100644--- a/package.json+++ b/package.json@@ -79,13 +79,13 @@"test-watch": "yarn test --watch","test-e2e-old": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./tests/runTests.js e2e","test-e2e-dev": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./tests/runTests.js e2e-dev",- "test-unit": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 jest --verbose ./tests/unit/",+ "test-unit": "cross-env NODE_JEST=unit_test BABEL_DISABLE_CACHE=1 jest --config=jest.config.js --verbose ./tests/unit/","test-all": "yarn build && yarn test-unit && yarn build-e2e && yarn test-e2e",- "test-one": "jest --config=jest.config.js -t 'TST5037' --verbose ./tests/e2e/",- "test-e2e-electron": "node -r @babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_ENV=test jest --config=jest.config.js -t 'electron' --verbose ./tests/e2e/",- "test-e2e-electron-minio": "node -r @babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_JEST=test_minio jest --verbose ./tests/e2e/",- "test-e2e-web": "yarn prepare-web && cross-env NODE_JEST=test_web jest -t 'web' --verbose ./tests/e2e/",- "test-e2e-web-all": "yarn prepare-web && cross-env NODE_JEST=test_web jest --verbose ./tests/e2e/",+ "test-one": "cross-env NODE_JEST=test_minio jest --config=jest.config.minio.js -t 'TST5037' --runInBand --verbose ./tests/e2e/",+ "test-e2e-electron": "node -r @babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_ENV=test jest --config=jest.config.js -t 'electron' --runInBand --verbose ./tests/e2e/",+ "test-e2e-electron-minio": "node -r @babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_JEST=test_minio jest --config=jest.config.minio.js -t 'minio' --runInBand --verbose ./tests/e2e/",+ "test-e2e-web": "yarn prepare-web && cross-env NODE_JEST=test_web jest --config=jest.config.web.js -t 'web' --runInBand --verbose ./tests/e2e/",+ "test-e2e-web-all": "yarn prepare-web && cross-env NODE_JEST=test_web jest --config=jest.config.js --verbose ./tests/e2e/","minio-start": "./tests/bin/minio server ./tests/testdata/file-structure","minio-start-windows": "./tests/bin/minio.exe server ./tests/testdata/file-structure","start-chrome-driver": "./node_modules/.bin/chromedriver --url-base=/ --port=9515 --no-sandbox --disable-dev-shm-usage",diff --git a/scripts/extconfig.js b/scripts/extconfig.jsindex fb27a310a..da49f04dc 100644--- a/scripts/extconfig.js+++ b/scripts/extconfig.js@@ -12,7 +12,7 @@ window.ExtLocations = [uuid: '30565f09-c7fd-2333-fc67-a75db27rt5ba', // an inique id of the locationtype: '0', // 1 defines the locations a cloud basedname: 'supported-filestypes', // the name of the location- paths: ['./testdata/file-structure/supported-filestypes'], // the path to sub folder in the location+ paths: ['./testdata-tmp/file-structure/supported-filestypes'], // the path to sub folder in the location// accessKeyId: 'your_access_key', // the access key of the user// secretAccessKey: 'your_secret_key', // the secret case of the user// bucketName: 'demo-bucket', // the name of the S3 bucketdiff --git a/scripts/setup-tests.js b/scripts/setup-tests.jsindex 02f52e276..c6e5a54c4 100644--- a/scripts/setup-tests.js+++ b/scripts/setup-tests.js@@ -1,6 +1,6 @@const sh = require('shelljs');const path = require('path');-const fs = require('fs-extra');+// const fs = require('fs-extra');if (!sh.which('git')) {sh.echo('Sorry, this script requires git');@@ -13,8 +13,17 @@ if (!sh.which('yarn')) {}const extensionDir = path.resolve(__dirname, '../tests');-const extensionBranch = 'master';+if (!sh.test('-d', extensionDir)) {+ sh.mkdir(extensionDir);+}+sh.cd(extensionDir);++/**+ * @Deprecated use github action script for setup instead+ */+/*+const extensionBranch = 'master';const extensionList = [{path: 'testdata',@@ -22,12 +31,6 @@ const extensionList = [}];-if (!sh.test('-d', extensionDir)) {- sh.mkdir(extensionDir);-}--sh.cd(extensionDir);-extensionList.forEach(extension => {if (sh.test('-d', extension.path)) {sh.cd(extension.path);@@ -58,6 +61,7 @@ if (!sh.test('-d', outDir)) {sh.exec('chmod -R +x .');}}+*//* const outFile = path.join(outDir, 'minio.exe');if (!fs.existsSync(outFile)) {//! sh.test('-d', 'bin') ||diff --git a/tests/e2e/clearstorage.helpers.js b/tests/e2e/clearstorage.helpers.jsnew file mode 100644index 000000000..d4a90adc1--- /dev/null+++ b/tests/e2e/clearstorage.helpers.js@@ -0,0 +1,16 @@+import { clickOn } from './general.helpers';++export async function clearStorage() {+ if (!global.isWeb) {+ await global.client.pause(500);+ await clickOn('[data-tid=settings]');+ // const settingsDialog = await global.client.$('[data-tid=settingsDialog]');+ // await settingsDialog.waitForDisplayed();+ // await settingsDialog.click();+ await global.client.pause(500);+ await clickOn('[data-tid=resetSettingsTID]');+ await clickOn('[data-tid=confirmResetSettingsDialogTID]');+ return true;+ }+ return false;+}diff --git a/tests/e2e/file.properties.helpers.js b/tests/e2e/file.properties.helpers.jsindex bd156d5bb..373bc277f 100644--- a/tests/e2e/file.properties.helpers.js+++ b/tests/e2e/file.properties.helpers.js@@ -31,7 +31,7 @@ export async function AddRemovePropertiesTags(for (let i = 0; i < tagNames.length; i++) {const tagName = tagNames[i];await removeTagFromTagMenu(tagName);- await global.client.pause(500);+ await global.client.pause(800);const propsNewTags = await getPropertiesTags();expect(propsNewTags.includes(tagName)).toBe(false);}diff --git a/tests/e2e/fileopener.e2e.js b/tests/e2e/fileopener.e2e.jsindex 333c94990..dd84d3cec 100644--- a/tests/e2e/fileopener.e2e.js+++ b/tests/e2e/fileopener.e2e.js@@ -133,7 +133,7 @@ describe('TST08 - File / folder properties', () => {expect(propsOldFileName).toBe(propsFileName);});- it('TST0807 - Rename opened folder [TST0807,web,minio,electron]', async () => {+ it('TST0807 - Rename opened folder [TST0807, electron]', async () => {const newTile = 'folderRenamed';// open folderPropertiesawait openContextEntryMenu(diff --git a/tests/e2e/folder.e2e.js b/tests/e2e/folder.e2e.jsindex 380808de1..cf6e09764 100644--- a/tests/e2e/folder.e2e.js+++ b/tests/e2e/folder.e2e.js@@ -25,8 +25,6 @@ import { renameFolder } from './test-utils.spec';describe('TST01 - Folder management [electron]', () => {beforeEach(async () => {- // await clearLocalStorage();-if (global.isMinio) {await createMinioLocation('', defaultLocationName, true);} else {@@ -36,7 +34,8 @@ describe('TST01 - Folder management [electron]', () => {await closeFileProperties();});- it('TST0101 - Create subfolder [TST0101,web,minio,electron]', async () => {+ // TODO minio+ it('TST0101 - Create subfolder [TST0101,electron]', async () => {const testFolder = await createNewDirectory();await expectElementExist('[data-tid=fsEntryName_' + testFolder + ']');await openEntry(testFolder);@@ -47,7 +46,8 @@ describe('TST01 - Folder management [electron]', () => {);});- it('TST0102 - Reload folder [TST0102,web,minio,electron]', async () => {+ // TODO minio+ it('TST0102 - Reload folder [TST0102,electron]', async () => {const testFolder = await createNewDirectory();await openEntry(testFolder);await reloadDirectory();@@ -74,7 +74,7 @@ describe('TST01 - Folder management [electron]', () => {);*/});- it('TST0104 - Delete empty folder [TST0104,electron]', async () => {+ it('TST0104 - Delete empty folder [TST0104, electron]', async () => {await setSettings('[data-tid=settingsSetUseTrashCan]');await global.client.pause(500);const testFolder = await createNewDirectory();diff --git a/tests/e2e/folder.spec.js b/tests/e2e/folder.spec.jsindex fec30d541..08912f4d0 100644--- a/tests/e2e/folder.spec.js+++ b/tests/e2e/folder.spec.js@@ -1,5 +1,5 @@/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */-import { delay, clearLocalStorage } from './hook';+import { delay } from './hook';import {openFile,checkFilenameForExist,@@ -26,7 +26,6 @@ const lastSubFolder = 'search';describe('TST01+TST02 - Folder tests', () => {beforeEach(async () => {- await clearLocalStorage();await delay(1000);await createLocation(defaultLocationPath, defaultLocationName, true);await delay(1000);diff --git a/tests/e2e/general.e2e.js b/tests/e2e/general.e2e.jsindex 923717e61..041d5666c 100644--- a/tests/e2e/general.e2e.js+++ b/tests/e2e/general.e2e.js@@ -1,7 +1,6 @@/** Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.*/-import { delay, clearLocalStorage } from './hook';import {createLocation,defaultLocationPath,@@ -38,8 +37,6 @@ const testFolder = 'testFolder';describe('TST51 - Perspective Grid [general]', () => {beforeEach(async () => {- // await clearLocalStorage();- // await delay(500);//await closeWelcome();//await delay(500);if (global.isMinio) {diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex f6b723f1b..94b4015b0 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -3,7 +3,7 @@ import { delay } from './hook';import { firstFile } from './test-utils.spec';export const defaultLocationPath =- './testdata/file-structure/supported-filestypes';+ './testdata-tmp/file-structure/supported-filestypes';export const defaultLocationName = 'supported-filestypes';export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';export const newLocationName = 'Location Name Changed';@@ -325,6 +325,7 @@ export async function showFilesWithTag(tagName) {await clickOn('[data-tid=tagMoreButton_' + tagName + ']');await global.client.pause(500);await clickOn('[data-tid=showFilesWithThisTag]');+ await global.client.pause(1500); // minio}export async function expectTagsExist(gridElement, arrTagNames, exist = true) {@@ -384,7 +385,7 @@ export async function openEntry(entryName) {export async function createNewDirectory(dirName = testFolder) {await clickOn('[data-tid=folderContainerOpenDirMenu]');- await global.client.pause(100); // TODO the Menu is always in HTML+ await global.client.pause(500); // TODO the Menu is always in HTMLawait clickOn('[data-tid=newSubDirectory]');await global.client.pause(500);// set new dir name@@ -401,6 +402,7 @@ export async function createNewDirectory(dirName = testFolder) {await delay(1500);await confirmCreateNewDirectory.waitForDisplayed();await confirmCreateNewDirectory.click();*/+ await global.client.pause(500); // minioreturn dirName;}diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex f45305079..f01d6ba61 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -1,16 +1,10 @@/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */import { Application } from 'spectron';import electronPath from 'electron';-import path from 'path';-import { closeWelcome } from './welcome.helpers';-import {- startChromeDriver,- startMinio,- startWebServer,- stopChromeDriver,- stopMinio,- stopWebServer-} from './test-utils.spec';+import pathLib from 'path';++const winMinio = pathLib.resolve(__dirname, '../bin/minio.exe');+const unixMinio = 'minio';// Spectron API https://github.com/electron/spectron// Webdriver.io http://webdriver.io/api.html@@ -24,25 +18,79 @@ export const delay = time => new Promise(resolve => setTimeout(resolve, time));export const getRandomInt = (min, max) =>Math.floor(Math.random() * (max - min + 1)) + min;-// the default timeout before starting every test-jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;-// use this pause only for visual debuging on places where you want to see the result after a given operation// global.msDebugPause = 0;// the default timeout before starting every test// global.msPause = 3000;-global.isWin = /^win/.test(process.platform);-global.isMac = /^darwin/.test(process.platform);-global.isWeb = process.env.NODE_JEST === 'test_web';-global.isMinio = global.isWeb || process.env.NODE_JEST === 'test_minio';--export function clearLocalStorage() {+export async function clearLocalStorage() {+ /*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();+ }*/+ await global.app.webContents.executeJavaScript('localStorage.clear()');+ global.app.webContents.reload();+ // browser.clearLocalStorage();// global.app.client.localStorage('DELETE');// global.app.client.reload(false);}+export async function startSpectronApp() {+ if (global.isWeb) {+ const webdriverio = await require('webdriverio');+ const options = {+ host: 'localhost', // Use localhost as chrome driver server+ port: 9515, // "9515" is the port opened by chrome driver.+ capabilities: {+ browserName: 'chrome'+ /*'goog:chromeOptions': {+ binary: electronPath, // Path to your Electron binary.+ args: [ /!* cli arguments *!/] // Optional, perhaps 'app=' + /path/to/your/app/+ }*/+ },+ logLevel: 'silent'+ };+ global.client = await webdriverio.remote(options);+ await global.client.url('http://localhost:8000');+ } else {+ global.app = new Application({+ path: electronPath,+ args: [pathLib.join(__dirname, '..', '..', 'app')],+ // startTimeout: 500,+ waitTimeout: 1000,+ waitforInterval: 50+ });+ await global.app.start();+ global.client = global.app.client;+ await global.client.waitUntilWindowLoaded();+ }+}++export async function stopSpectronApp() {+ if (global.app && global.app.isRunning()) {+ // await clearLocalStorage();+ return global.app.stop();+ }+}++export function testDataRefresh() {+ const fse = require('fs-extra');+ const src = pathLib.join(+ __dirname,+ '..',+ 'testdata',+ 'file-structure',+ 'supported-filestypes'+ );+ const dst = pathLib.join(__dirname, '..', 'testdata-tmp', 'file-structure');++ let newPath = pathLib.join(dst, pathLib.basename(src));+ fse.emptyDirSync(newPath);+ fse.copySync(src, newPath, { overwrite: true });+}+// the path the electron app, that will be tested/* let testPath = '../tsn/app'; // '../repo/app';if (global.isWin) {@@ -56,7 +104,7 @@ for (var index in process.argv) {}} */-beforeAll(async () => {+/*beforeAll(async () => {if (global.isWeb) {global.webserver = await startWebServer();global.chromeDriver = await startChromeDriver();@@ -73,6 +121,8 @@ beforeAll(async () => {fse.copySync(srcDir, destDir);}++ await startSpectronApp();});afterAll(async () => {@@ -88,43 +138,5 @@ afterAll(async () => {const path = require('path');fse.removeSync(path.join(__dirname, '..', '..', 'app', 'extconfig.js'));}-});--beforeEach(async () => {- if (global.isWeb) {- const webdriverio = await require('webdriverio');- const options = {- host: 'localhost', // Use localhost as chrome driver server- port: 9515, // "9515" is the port opened by chrome driver.- capabilities: {- browserName: 'chrome'- /*'goog:chromeOptions': {- binary: electronPath, // Path to your Electron binary.- args: [ /!* cli arguments *!/] // Optional, perhaps 'app=' + /path/to/your/app/- }*/- },- logLevel: 'silent'- };- global.client = await webdriverio.remote(options);- await global.client.url('http://localhost:8000');- } else {- global.app = new Application({- path: electronPath,- args: [path.join(__dirname, '..', '..', 'app')],- // startTimeout: 500,- waitTimeout: 500,- waitforInterval: 50- });- await global.app.start();- global.client = global.app.client;- await global.client.waitUntilWindowLoaded();- }- await closeWelcome();-});--afterEach(() => {- if (global.app && global.app.isRunning()) {- clearLocalStorage();- return global.app.stop();- }-});+ await stopSpectronApp();+});*/diff --git a/tests/e2e/keybindings.spec.js b/tests/e2e/keybindings.spec.jsindex 22f639841..90e513d5e 100644--- a/tests/e2e/keybindings.spec.js+++ b/tests/e2e/keybindings.spec.js@@ -1,5 +1,5 @@/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */-import { clearLocalStorage, delay } from './hook';+import { delay } from './hook';import {createLocation,checkForIdExist,@@ -19,7 +19,6 @@ const testLocationName = '' + new Date().getTime();describe('TST13 - Settings Key Bindings:', async () => {beforeEach(async () => {- await clearLocalStorage();await delay(500);await createLocation(defaultLocationPath, testLocationName);await delay(2000);diff --git a/tests/e2e/location.e2e.js b/tests/e2e/location.e2e.jsindex e3efb7970..0c577fdf2 100644--- a/tests/e2e/location.e2e.js+++ b/tests/e2e/location.e2e.js@@ -9,6 +9,7 @@ import {getLocationTid} from './location.helpers';import { clickOn, expectElementExist, setInputKeys } from './general.helpers';+import { startSpectronApp, stopSpectronApp } from './hook';export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';export const newLocationName = 'Location_Name_Changed';@@ -30,6 +31,9 @@ describe('TST03 - Testing locations:', () => {const destDir = path.join(__dirname, '..', '..', 'app', 'extconfig.js');fse.copySync(srcDir, destDir);++ await stopSpectronApp();+ await startSpectronApp();});afterAll(async () => {@@ -40,6 +44,9 @@ describe('TST03 - Testing locations:', () => {const destDir = path.join(__dirname, '..', '..', 'app', 'extconfig.js');fse.copySync(srcDir, destDir);++ await stopSpectronApp();+ await startSpectronApp();});beforeEach(async () => {diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.jsindex a2a7cbc18..82fcd5d03 100644--- a/tests/e2e/location.helpers.js+++ b/tests/e2e/location.helpers.js@@ -10,7 +10,7 @@ import {} from './general.helpers';export const defaultLocationPath =- './testdata/file-structure/supported-filestypes';+ './testdata-tmp/file-structure/supported-filestypes';export const defaultLocationName = 'supported-filestypes';export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';export const newLocationName = 'Location Name Changed';diff --git a/tests/e2e/perspective-grid.e2e.js b/tests/e2e/perspective-grid.e2e.jsindex aca53529e..93d9a96bb 100644--- a/tests/e2e/perspective-grid.e2e.js+++ b/tests/e2e/perspective-grid.e2e.js@@ -53,8 +53,6 @@ const newFileName = 'newFileName.txt';describe('TST50 - Perspective Grid', () => {beforeEach(async () => {- // await clearLocalStorage();- // await closeWelcome();if (global.isMinio) {await createMinioLocation('', defaultLocationName, true);} else {@@ -157,7 +155,7 @@ describe('TST50 - Perspective Grid', () => {});// This scenario includes "Add tags" && "Remove tags" to be fulfilled- test('TST5005 - Add tags to the selected files [TST5005,web,minio,electron]', async () => {+ test('TST5005 - Add tags to the selected files [TST5005,electron]', async () => {const classNotSelected = await getGridCellClass(0);const classSelected = await selectAllFiles(classNotSelected);expect(classNotSelected).not.toBe(classSelected);@@ -189,7 +187,7 @@ describe('TST50 - Perspective Grid', () => {}*/});- test('TST5006 - Remove tags from selected files [TST5006,web,minio,electron]', async () => {+ test('TST5006 - Remove tags from selected files [TST5006, electron]', async () => {const classNotSelected = await getGridCellClass(0);const classSelected = await selectAllFiles(classNotSelected);expect(classNotSelected).not.toBe(classSelected);@@ -217,7 +215,7 @@ describe('TST50 - Perspective Grid', () => {}*/});- test('TST5007 - Remove all tags from selected files [TST5007,web,minio,electron]', async () => {+ test('TST5007 - Remove all tags from selected files [TST5007, electron]', async () => {const classNotSelected = await getGridCellClass(0);const classSelected = await selectAllFiles(classNotSelected);expect(classNotSelected).not.toBe(classSelected);@@ -234,7 +232,10 @@ describe('TST50 - Perspective Grid', () => {}});- test('TST5008 - Copy file [TST5008,web,minio,electron]', async () => {+ /**+ * TODO copy file on minio failed with path: ./testdata-tmp/file-structure/supported-filestypes/empty_folder+ */+ test('TST5008 - Copy file [TST5008,electron]', async () => {await searchEngine('bmp');// select file@@ -252,6 +253,9 @@ describe('TST50 - Perspective Grid', () => {await doubleClickOn(perspectiveGridTable + firstFolder);const firstFileName = await getGridFileName(0);expect(firstFileName).toBe('sample.bmp');+ // cleanup+ await deleteFirstFile();+ await expectElementExist(selectorFile, false);});test('TST5010 - Move file [TST5010,web,minio,electron]', async () => {@@ -273,10 +277,16 @@ describe('TST50 - Perspective Grid', () => {await searchEngine('epub', { reindexing: true }); // TODO temp fix: https://trello.com/c/ZfcGGvOM/527-moved-files-is-not-indexing-not-found-in-searchconst firstFileName = await getGridFileName(0);expect(firstFileName).toBe('sample.epub');+ // cleanup+ await deleteFirstFile();+ await expectElementExist(selectorFile, false);});test('TST5013 - Delete files from selection (many files) [TST5013,web,minio,electron]', async () => {await doubleClickOn(perspectiveGridTable + firstFolder);+ await createTxtFile();+ await searchEngine('note');+ await expectElementExist(selectorFile, true);const classNotSelected = await getGridCellClass(0);const classSelected = await selectAllFiles(classNotSelected);@@ -285,7 +295,7 @@ describe('TST50 - Perspective Grid', () => {await clickOn('[data-tid=gridPerspectiveDeleteMultipleFiles]');await clickOn('[data-tid=confirmDeleteFileDialog]');await waitForNotification();- await expectElementExist(perspectiveGridTable + firstFile, false);+ await expectElementExist(selectorFile, false);});/*test('TST51** - Show/Hide directories in perspective view', async () => { //TODOawait global.client.waitForVisible(@@ -316,7 +326,6 @@ describe('TST50** - Right button on a file', () => {test('TST5016 - Open file [TST5016,web,minio,electron]', async () => {//await searchEngine('bmp');await searchEngine('txt');- // await delay(5000);await openContextEntryMenu(perspectiveGridTable + firstFile,'fileMenuOpenFile'@@ -338,7 +347,7 @@ describe('TST50** - Right button on a file', () => {expect(toContainTID(bodyTxt)).toBe(true);});- test('TST5017 - Rename file [web,electron]', async () => {+ test('TST5017 - Rename file [web,web,minio,electron]', async () => {await searchEngine('txt');const oldName = await getFirstFileName();await renameFirstFile(newFileName);@@ -479,7 +488,10 @@ describe('TST50** - Right button on a file', () => {await cancelButton.click();});*/- test('TST5028 - Move / Copy file (file menu) [TST5028,web,minio,electron]', async () => {+ /**+ * TODO github minio (expected selector to exist=false after 5s)+ */+ test('TST5028 - Move / Copy file (file menu) [TST5028,electron]', async () => {// Move file in child folderawait searchEngine('eml');await openContextEntryMenu(@@ -514,18 +526,26 @@ describe('TST50** - Right button on a file', () => {await searchEngine('eml');firstFileName = await getGridFileName(0);expect(firstFileName).toBe('sample.eml');++ // cleanup+ await deleteFirstFile();+ await expectElementExist(selectorFile, false);});test('TST5033 - Open directory (directory menu) [TST5033,web,minio,electron]', async () => {+ // open empty_folderawait openContextEntryMenu(perspectiveGridTable + firstFolder,'openDirectory');const firstFileName = await getGridFileName(0);- expect(firstFileName).toBe('sample.eml');+ expect(firstFileName).toBe(undefined); //'sample.eml');});- test('TST5034 - Rename directory (directory menu) [TST5034,web,minio,electron]', async () => {+ /**+ * minio not support rename folder+ */+ test('TST5034 - Rename directory (directory menu) [TST5034,electron]', async () => {const newDirName = 'new_dir_name';await openContextEntryMenu(perspectiveGridTable + firstFolder,@@ -552,7 +572,10 @@ describe('TST50** - Right button on a file', () => {expect(renamedDir).toBe(newDirName);});- test('TST5035 - Delete directory (directory menu) [TST5035,web,minio,electron]', async () => {+ /**+ * delete dir is not supported on minio+ */+ test('TST5035 - Delete directory (directory menu) [TST5035,electron]', async () => {await setSettings('[data-tid=settingsSetUseTrashCan]');await global.client.pause(500);const testFolder = await createNewDirectory('aaa');diff --git a/tests/e2e/search.spec.js b/tests/e2e/search.spec.jsindex feebc691f..348bf0581 100644--- a/tests/e2e/search.spec.js+++ b/tests/e2e/search.spec.js@@ -45,6 +45,7 @@ export async function searchEngine(filename, options = {}) {await clickOn('#searchButton');}await waitForNotification('TIDSearching');+ await global.client.pause(1500); //todo: for minio search is slow}/*describe('TST06 - Test Search in file structure:', () => {diff --git a/tests/e2e/test-utils.spec.js b/tests/e2e/test-utils.spec.jsindex 988eef0c7..6709cad15 100644--- a/tests/e2e/test-utils.spec.js+++ b/tests/e2e/test-utils.spec.js@@ -3,8 +3,6 @@import pathLib from 'path';import { clickOn, setInputKeys } from './general.helpers';-const winMinio = pathLib.resolve(__dirname, '../bin/minio.exe');-const unixMinio = 'minio';const newDirectoryName = 'newDirectory';export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';export const firstFile = '/span';@@ -16,87 +14,6 @@ export const firstFileName = '/span/div/div/div/p';// const perspectiveGrid = 'perspectiveGrid';// const select = '//*[@id="perspectiveList"]/div[5]/div/select';-export async function startMinio() {- const command = global.isWin ? pathLib.resolve(winMinio) : unixMinio;- const minioProcess = await require('child_process').spawn(command, [- 'server',- pathLib.resolve('./testdata/file-structure')- ]);-- minioProcess.on('exit', function(code) {- // console.log('exit here with code: ', code);- });- minioProcess.on('close', (code, signal) => {- // console.log(`child process terminated due to receipt of signal ${signal}`);- });-- minioProcess.stdout.on('data', function(data) {- // console.log('stdout: ' + data);- });-- minioProcess.stderr.on('data', function(data) {- console.log('stderr: ' + data);- });- return minioProcess;-}--export async function startChromeDriver() {- //const childProcess = await require('child_process');- const chromeDriver = await require('chromedriver');- //const binPath = chromedriver.path;-- const args = ['--url-base=/', '--port=9515'];-- await chromeDriver.start(args);- /*const process = await childProcess.execFile(binPath, args, function (err, stdout, stderr) {- // handle results- console.log('err: ' + err);- console.log('stdout: ' + stdout);- console.log('stderr: ' + stderr);- });*/- return chromeDriver;-}--export async function startWebServer() {- const express = await require('express');- const serveStatic = await require('serve-static');-- const port = 8000;- const app = await express();-- await app.use(- serveStatic(pathLib.resolve(__dirname, '../../web'), {- index: ['index.html']- })- );- if (global.isMac) {- //todo copyfiles do not work for MacOS- await app.use(serveStatic('../app'));- }- await app.listen(port);- console.log('Webserver listining on http://127.0.0.1:' + port);- return app;-}--export async function stopWebServer(app) {- await app.close();-}--export async function stopMinio(process) {- // Send SIGHUP to process.- console.log('stopMinio');- process.stdin.pause();- process.kill(); //'SIGHUP');-}--export async function stopChromeDriver(chromeDriver) {- chromeDriver.stop();- // Send SIGHUP to process.- /*console.log('stopChromeDriver');- process.stdin.pause();- process.kill(); //'SIGHUP');*/-}-/*** @deprecated use: clickOn();* @param perspectiveSelectordiff --git a/tests/e2e/viewer-html.e2e.js b/tests/e2e/viewer-html.e2e.jsindex 5bbf1a975..c81b4cad9 100644--- a/tests/e2e/viewer-html.e2e.js+++ b/tests/e2e/viewer-html.e2e.js@@ -1,7 +1,7 @@/** Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.*/-import { delay, clearLocalStorage } from './hook';+import { delay } from './hook';import {createLocation,openLocation,@@ -20,7 +20,6 @@ export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';describe('TST65 - HTML viewer [electron]', () => {beforeEach(async () => {- await clearLocalStorage();if (global.isMinio) {await createMinioLocation('', defaultLocationName, true);} else {diff --git a/tests/e2e/viewer-image.e2e.js b/tests/e2e/viewer-image.e2e.jsindex a4cf7c47d..3e0b792cd 100644--- a/tests/e2e/viewer-image.e2e.js+++ b/tests/e2e/viewer-image.e2e.js@@ -1,10 +1,9 @@/** Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.*/-import { delay, clearLocalStorage } from './hook';+import { delay } from './hook';import {createLocation,- openLocation,defaultLocationPath,defaultLocationName,closeFileProperties,@@ -42,7 +41,6 @@ export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';describe('TST53 - Image viewer [web,minio,electron]', () => {beforeEach(async () => {- // await clearLocalStorage();if (global.isMinio) {await createMinioLocation('', defaultLocationName, true);} else {diff --git a/tests/e2e/viewer-markdown.e2e.js b/tests/e2e/viewer-markdown.e2e.jsindex c91ca69c4..d95140595 100644--- a/tests/e2e/viewer-markdown.e2e.js+++ b/tests/e2e/viewer-markdown.e2e.js@@ -1,7 +1,7 @@/** Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved.*/-import { delay, clearLocalStorage } from './hook';+import { delay } from './hook';import {createLocation,openLocation,@@ -42,7 +42,6 @@ export const perspectiveGridTable = '//*[@data-tid="perspectiveGridFileTable"]';describe('TST54 - Markdown viewer [electron]', () => {beforeEach(async () => {- await clearLocalStorage();if (global.isMinio) {await createMinioLocation('', defaultLocationName, true);} else {diff --git a/tests/global-setup-minio.js b/tests/global-setup-minio.jsnew file mode 100644index 000000000..e0de59863--- /dev/null+++ b/tests/global-setup-minio.js@@ -0,0 +1,46 @@+import pathLib from 'path';+import sh from 'shelljs';+import { testDataRefresh } from './e2e/hook';++module.exports = async function() {+ const winMinio = pathLib.resolve(__dirname, './bin/minio.exe');+ const unixMinio = 'minio';++ global.isWin = /^win/.test(process.platform);+ global.isMac = /^darwin/.test(process.platform);++ async function startMinio() {+ const command = global.isWin ? pathLib.resolve(winMinio) : unixMinio;+ const minioProcess = await require('child_process').spawn(command, [+ 'server',+ pathLib.resolve('./testdata-tmp/file-structure')+ ]);++ minioProcess.on('exit', function(code) {+ // console.log('exit here with code: ', code);+ });+ minioProcess.on('close', (code, signal) => {+ // console.log(`child process terminated due to receipt of signal ${signal}`);+ });++ minioProcess.stdout.on('data', function(data) {+ // console.log('stdout: ' + data);+ });++ minioProcess.stderr.on('data', function(data) {+ console.log('stderr: ' + data);+ });+ return minioProcess;+ }++ const extensionDir = pathLib.resolve(__dirname); //,'../tests');+ if (!sh.test('-d', extensionDir)) {+ sh.mkdir(extensionDir);+ }++ sh.cd(extensionDir);+ // testDataRefresh();+ const fse = require('fs-extra');+ fse.removeSync(pathLib.join(__dirname, '..', 'app', 'extconfig.js'));+ global.minio = await startMinio();+};diff --git a/tests/global-setup.js b/tests/global-setup.jsnew file mode 100644index 000000000..8380d21f5--- /dev/null+++ b/tests/global-setup.js@@ -0,0 +1,100 @@+import pathLib from 'path';+import sh from 'shelljs';+import { testDataRefresh } from './e2e/hook';++module.exports = async function() {+ // const winMinio = pathLib.resolve(__dirname, './bin/minio.exe');+ // const unixMinio = 'minio';++ global.isWin = /^win/.test(process.platform);+ global.isMac = /^darwin/.test(process.platform);+ // global.isWeb = process.env.NODE_JEST === 'test_web';+ // global.isMinio = global.isWeb || process.env.NODE_JEST === 'test_minio';++ async function startMinio() {+ const command = global.isWin ? pathLib.resolve(winMinio) : unixMinio;+ const minioProcess = await require('child_process').spawn(command, [+ 'server',+ pathLib.resolve('./testdata/file-structure')+ ]);++ minioProcess.on('exit', function(code) {+ // console.log('exit here with code: ', code);+ });+ minioProcess.on('close', (code, signal) => {+ // console.log(`child process terminated due to receipt of signal ${signal}`);+ });++ minioProcess.stdout.on('data', function(data) {+ // console.log('stdout: ' + data);+ });++ minioProcess.stderr.on('data', function(data) {+ console.log('stderr: ' + data);+ });+ return minioProcess;+ }++ async function startChromeDriver() {+ //const childProcess = await require('child_process');+ const chromeDriver = await require('chromedriver');+ //const binPath = chromedriver.path;++ const args = ['--url-base=/', '--port=9515'];++ await chromeDriver.start(args);+ /*const process = await childProcess.execFile(binPath, args, function (err, stdout, stderr) {+ // handle results+ console.log('err: ' + err);+ console.log('stdout: ' + stdout);+ console.log('stderr: ' + stderr);+ });*/+ return chromeDriver;+ }++ async function startWebServer() {+ const express = await require('express');+ const serveStatic = await require('serve-static');++ const port = 8000;+ const app = await express();++ await app.use(+ serveStatic(pathLib.resolve(__dirname, '../web'), {+ index: ['index.html']+ })+ );+ if (global.isMac) {+ //todo copyfiles do not work for MacOS+ await app.use(serveStatic('../app'));+ }+ await app.listen(port);+ console.log('Webserver listining on http://127.0.0.1:' + port);+ return app;+ }++ const extensionDir = pathLib.resolve(__dirname); //,'../tests');+ if (!sh.test('-d', extensionDir)) {+ sh.mkdir(extensionDir);+ }++ sh.cd(extensionDir);++ /*if (global.isWeb) {+ global.webserver = await startWebServer();+ global.chromeDriver = await startChromeDriver();+ }+ if (global.isMinio) {+ global.minio = await startMinio();+ } else {*/+ // copy extconfig+ const fse = require('fs-extra');+ const path = require('path');++ let srcDir = path.join(__dirname, '..', 'scripts', 'extconfig.js');+ let destDir = path.join(__dirname, '..', 'app', 'extconfig.js');++ fse.copySync(srcDir, destDir);+ // testDataRefresh();+ // }+};diff --git a/tests/global-teardown-minio.js b/tests/global-teardown-minio.jsnew file mode 100644index 000000000..3804fc845--- /dev/null+++ b/tests/global-teardown-minio.js@@ -0,0 +1,7 @@+module.exports = function() {+ // Send SIGHUP to process.+ console.log('stopMinio');+ const process = global.minio;+ process.stdin.pause();+ process.kill(); //'SIGHUP');+};diff --git a/tests/global-teardown.js b/tests/global-teardown.jsnew file mode 100644index 000000000..7d5ab6b9c--- /dev/null+++ b/tests/global-teardown.js@@ -0,0 +1,33 @@+module.exports = async function() {+ async function stopWebServer(app) {+ await app.close();+ }++ async function stopMinio(process) {+ // Send SIGHUP to process.+ console.log('stopMinio');+ process.stdin.pause();+ process.kill(); //'SIGHUP');+ }++ async function stopChromeDriver(chromeDriver) {+ chromeDriver.stop();+ // Send SIGHUP to process.+ /*console.log('stopChromeDriver');+ process.stdin.pause();+ process.kill(); //'SIGHUP');*/+ }++ /*if (global.isWeb) {+ // await stopWebServer(global.webserver); TODO stop webserver+ await stopChromeDriver(global.chromeDriver);+ }+ if (global.isMinio) {+ await stopMinio(global.minio);+ } else {*/+ // cleanup extconfig+ const fse = require('fs-extra');+ const path = require('path');+ fse.removeSync(path.join(__dirname, '..', 'app', 'extconfig.js'));+ // }+};diff --git a/tests/setup-after-env.js b/tests/setup-after-env.jsnew file mode 100644index 000000000..08e079597--- /dev/null+++ b/tests/setup-after-env.js@@ -0,0 +1,75 @@+import {+ clearLocalStorage,+ startSpectronApp,+ stopSpectronApp,+ testDataRefresh+} from './e2e/hook';+import { closeWelcome } from './e2e/welcome.helpers';++// the default timeout before starting every test+jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;++global.isWin = /^win/.test(process.platform);+global.isMac = /^darwin/.test(process.platform);+global.isWeb = process.env.NODE_JEST === 'test_web';+global.isMinio = global.isWeb || process.env.NODE_JEST === 'test_minio';+global.isUnitTest = process.env.NODE_JEST === 'unit_test';++/*jasmine.getEnv().addReporter({+ specStarted: function(result) {+ console.log(`Spec name: ${result.fullName}, description: ${result.description}`);+ }+});*/++beforeAll(async () => {+ /*if (global.isWeb) {+ global.webserver = await startWebServer();+ global.chromeDriver = await startChromeDriver();+ }+ if (global.isMinio) {+ global.minio = await startMinio();+ } else {+ // copy extconfig+ const fse = require('fs-extra');+ const path = require('path');++ let srcDir = path.join(__dirname, '..', 'scripts', 'extconfig.js');+ let destDir = path.join(__dirname, '..', 'app', 'extconfig.js');++ fse.copySync(srcDir, destDir);+ }*/+ if (!global.isUnitTest) {+ testDataRefresh();+ await startSpectronApp();+ }+});++afterAll(async () => {+ /*if (global.isWeb) {+ // await stopWebServer(global.webserver); TODO stop webserver+ await stopChromeDriver(global.chromeDriver);+ }+ if (global.isMinio) {+ await stopMinio(global.minio);+ } else {+ // cleanup extconfig+ const fse = require('fs-extra');+ const path = require('path');+ fse.removeSync(path.join(__dirname, '..', 'app', 'extconfig.js'));+ }*/+ if (!global.isUnitTest) {+ await stopSpectronApp();+ }+});++beforeEach(async () => {+ if (!global.isUnitTest) {+ await closeWelcome();+ }+});++afterEach(async () => {+ if (!global.isUnitTest) {+ await clearLocalStorage();+ }+});