Skip to content

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

Extedning e2e tests (#1271)

Stanimir7c38798afbe0
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 62b1f5865..d451eb576 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -54,22 +54,28 @@ jobs:
yarn build-e2e
yarn test-e2e-electron
-# gitHubActionForNpmMac:
-# name: Validating MacOS
-# runs-on: macos-latest
+ 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
+ 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
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index afc76c569..574e94587 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -679,12 +679,7 @@ class MainPage extends Component<Props, State> {
onClose={toggleSettingsDialog}
/>
<Snackbar
- data-tid={
- 'TID' +
- (this.props.notificationStatus.text
- ? this.props.notificationStatus.text.replace(/\./g, '')
- : 'default')
- }
+ data-tid={this.props.notificationStatus.tid}
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={this.props.notificationStatus.visible}
onClose={this.props.hideNotifications}
@@ -694,6 +689,7 @@ class MainPage extends Component<Props, State> {
message={this.props.notificationStatus.text}
action={[
<IconButton
+ data-tid={'close' + this.props.notificationStatus.tid}
key="close"
aria-label={i18n.t('core:closeButton')}
color="inherit"
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 28f2dace7..665409734 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -922,14 +922,16 @@ class GridPerspective extends React.Component<Props, State> {
removeTags={this.props.removeTags}
isReadOnlyMode={this.props.isReadOnlyMode}
/>
- <SortingMenu
- open={this.state.sortingContextMenuOpened}
- onClose={this.closeSortingMenu}
- anchorEl={this.state.sortingContextMenuAnchorEl}
- sortBy={this.state.sortBy}
- orderBy={this.state.orderBy}
- handleSortBy={this.handleSortBy}
- />
+ {this.state.sortingContextMenuOpened && (
+ <SortingMenu
+ open={this.state.sortingContextMenuOpened}
+ onClose={this.closeSortingMenu}
+ anchorEl={this.state.sortingContextMenuAnchorEl}
+ sortBy={this.state.sortBy}
+ orderBy={this.state.orderBy}
+ handleSortBy={this.handleSortBy}
+ />
+ )}
<GridOptionsMenu
open={this.state.optionsContextMenuOpened}
onClose={this.closeOptionsMenu}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index aba694b7f..605f9ce11 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -396,6 +396,7 @@ export default (state: any = initialState, action: any) => {
notificationStatus: {
visible: action.visible,
text: action.text,
+ tid: action.tid,
notificationType: action.notificationType,
autohide: action.autohide
}
@@ -1376,13 +1377,15 @@ export const actions = {
showNotification: (
text: string,
notificationType: string = 'default',
- autohide: boolean = true
+ autohide: boolean = true,
+ tid: string = 'notificationTID'
) => ({
type: types.SET_NOTIFICATION,
visible: true,
text,
notificationType,
- autohide
+ autohide,
+ tid
}),
hideNotifications: () => ({
type: types.SET_NOTIFICATION,
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 65e10377c..c2889317e 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -304,7 +304,12 @@ export const actions = {
}
const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
dispatch(
- AppActions.showNotification(i18n.t('core:searching'), 'default', false)
+ AppActions.showNotification(
+ i18n.t('core:searching'),
+ 'default',
+ false,
+ 'TIDSearching'
+ )
);
dispatch(actions.setSearchQuery(searchQuery));
setTimeout(async () => {
@@ -383,7 +388,12 @@ export const actions = {
);
console.time('globalSearch');
dispatch(
- AppActions.showNotification(i18n.t('core:searching'), 'default', false)
+ AppActions.showNotification(
+ i18n.t('core:searching'),
+ 'default',
+ false,
+ 'TIDSearching'
+ )
);
// Preparing for global search
@@ -414,7 +424,8 @@ export const actions = {
AppActions.showNotification(
i18n.t('core:searching') + ' ' + location.name,
'default',
- true
+ true,
+ 'TIDSearching'
)
);
if (isCloudLocation) {
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index a85f515ab..04b0e57a9 100644
--- a/tests/e2e/general.helpers.js
+++ b/tests/e2e/general.helpers.js
@@ -177,20 +177,23 @@ export async function clearInputValue(inputElement) {
*/
export async function getGridFileName(fileIndex) {
const filesList = await global.client.$$(perspectiveGridTable + firstFile);
- let file =
- fileIndex < 0
- ? filesList[filesList.length + fileIndex]
- : filesList[fileIndex];
- file = await file.$('div');
- file = await file.$('div');
- file = await file.$('div');
- const fileNameElem = await file.$('p');
- const fileName = await fileNameElem.getText();
- const divs = await file.$$('div');
- const lastDiv = await divs[divs.length - 1];
- const fileExtElem = await lastDiv.$('span');
- const fileExt = await fileExtElem.getText();
- return fileName + '.' + fileExt.toLowerCase();
+ if (filesList.length > 0) {
+ let file =
+ fileIndex < 0
+ ? filesList[filesList.length + fileIndex]
+ : filesList[fileIndex];
+ file = await file.$('div');
+ file = await file.$('div');
+ file = await file.$('div');
+ const fileNameElem = await file.$('p');
+ const fileName = await fileNameElem.getText();
+ const divs = await file.$$('div');
+ const lastDiv = await divs[divs.length - 1];
+ const fileExtElem = await lastDiv.$('span');
+ const fileExt = await fileExtElem.getText();
+ return fileName + '.' + fileExt.toLowerCase();
+ }
+ return undefined;
}
export async function getGridCellClass(fileIndex = 0) {
@@ -205,7 +208,11 @@ export async function getGridCellClass(fileIndex = 0) {
return await file.getAttribute('class');
}
-export async function expectElementExist(selector, exist = true) {
+export async function expectElementExist(
+ selector,
+ exist = true,
+ timeout = 5000
+) {
const element = await global.client.$(selector);
await element.waitUntil(
async function() {
@@ -213,8 +220,9 @@ export async function expectElementExist(selector, exist = true) {
return displayed === exist;
},
{
- timeout: 5000,
- timeoutMsg: 'expected selector to exist=' + exist + ' after 5s'
+ timeout: timeout,
+ timeoutMsg:
+ 'expected selector to exist=' + exist + ' after ' + timeout / 1000 + 's'
}
);
expect(await element.isDisplayedInViewport()).toBe(exist);
@@ -262,6 +270,29 @@ export async function createLocation(
await confirmLocationCreation.click();
}
+export async function createTxtFile() {
+ await clickOn('[data-tid=folderContainerOpenDirMenu]');
+ await global.client.pause(500);
+ await clickOn('[data-tid=createNewFile]');
+ //await global.client.pause(1500);
+ await clickOn('[data-tid=createTextFileButton]');
+ await waitForNotification();
+}
+
+export async function waitForNotification(tid = 'notificationTID') {
+ // await expectElementExist('[data-tid=' + tid + ']', true, 8000);
+ const notificationTID = await global.client.$('[data-tid=' + tid + ']');
+ if (await notificationTID.isDisplayed()) {
+ const closeButton = await global.client.$('[data-tid=close' + tid + ']');
+ if (await closeButton.isDisplayed()) {
+ await closeButton.click();
+ } else {
+ // autohide Notification
+ await expectElementExist('[data-tid=' + tid + ']', false, 10000);
+ }
+ }
+}
+
export async function settingsSetShowUnixHiddenEntries() {
await clickOn('[data-tid=settings]');
await global.client.pause(500);
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.js
index d378ae313..ecc20ae88 100644
--- a/tests/e2e/location.helpers.js
+++ b/tests/e2e/location.helpers.js
@@ -1,7 +1,13 @@
/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */
import { delay } from './hook';
import { firstFile, openContextEntryMenu } from './test-utils.spec';
-import { clickOn, setInputKeys, setInputValue } from './general.helpers';
+import {
+ clickOn,
+ expectElementExist,
+ setInputKeys,
+ setInputValue,
+ waitForNotification
+} from './general.helpers';
export const defaultLocationPath =
'./testdata/file-structure/supported-filestypes';
@@ -159,6 +165,7 @@ export async function deleteFirstFile() {
'fileMenuDeleteFile'
);
await clickOn('[data-tid=confirmDeleteFileDialog]');
+ await waitForNotification();
}
export async function getFirstFileName() {
@@ -180,7 +187,7 @@ export async function getPropertiesFileName() {
const propsFileNameInput = await global.client.$(
'[data-tid=fileNameProperties] input'
);
- await propsFileNameInput.waitForDisplayed({ timeout: 5000 });
+ await propsFileNameInput.waitForDisplayed({ timeout: 10000 });
return await propsFileNameInput.getValue();
}
diff --git a/tests/e2e/perspective-grid.e2e.js b/tests/e2e/perspective-grid.e2e.js
index fa166c70d..ab46525b6 100644
--- a/tests/e2e/perspective-grid.e2e.js
+++ b/tests/e2e/perspective-grid.e2e.js
@@ -23,13 +23,13 @@ import {
import {
addInputKeys,
clickOn,
+ createTxtFile,
doubleClickOn,
expectElementExist,
getGridCellClass,
getGridFileName,
selectorFile,
selectorFolder,
- setInputKeys,
waitUntilClassChanged
} from './general.helpers';
@@ -110,14 +110,21 @@ describe('TST50 - Perspective Grid', () => {
test('TST10** - Sort by date [web,minio,electron]', async () => {
await clickOn('[data-tid=gridPerspectiveSortByDate]');
- await global.client.pause(500); // TODO
- const firstFileName = await getGridFileName(0);
- expect(firstFileName).toBe('sample.txt');
+ await global.client.pause(500);
+
+ await createTxtFile();
+
+ let firstFileName = await getGridFileName(0);
+ expect(firstFileName).toBe('note.txt');
+ //cleanup
+ await deleteFirstFile();
+ firstFileName = await getGridFileName(0);
+ expect(firstFileName).not.toBe('note.txt');
});
test('TST10** - Sort by extension [web,minio,electron]', async () => {
await clickOn('[data-tid=gridPerspectiveSortByExt]');
- await global.client.pause(500); // TODO
+ await global.client.pause(1000); // TODO
const firstFileName = await getGridFileName(0);
expect(firstFileName).toBe('sample.zip');
});
@@ -272,12 +279,14 @@ describe('TST50 - Perspective Grid', () => {
});
test('TST5040 - Create file [web,electron]', async () => {
- await clickOn('[data-tid=folderContainerOpenDirMenu]');
- await clickOn('[data-tid=createNewFile]');
- //await global.client.pause(1500);
- await clickOn('[data-tid=createTextFileButton]');
+ await createTxtFile();
await searchEngine('note');
await expectElementExist(selectorFile, true);
+
+ //cleanup
+ await deleteFirstFile();
+ const firstFileName = await getGridFileName(0);
+ expect(firstFileName).toBe(undefined);
});
/*test('TST51** - Show/Hide directories in perspective view', async () => { //TODO
@@ -344,10 +353,17 @@ describe('TST50** - Right button on a file', () => {
});
test('TST5018 - Delete file [web,electron]', async () => {
+ await createTxtFile();
await searchEngine('note'); //select new created file - note[date_created].txt
+ /*let firstFileName = await getGridFileName(0);
+ expect(firstFileName).toBe('note.txt');*/
+
await expectElementExist(selectorFile, true);
+
await deleteFirstFile();
await expectElementExist(selectorFile, false);
+ /*firstFileName = await getGridFileName(0);
+ expect(firstFileName).toBe(undefined);*/
});
test('TST5026 - Open file natively [electron]', async () => {
diff --git a/tests/e2e/search.spec.js b/tests/e2e/search.spec.js
index b309bd6f3..531806dd0 100644
--- a/tests/e2e/search.spec.js
+++ b/tests/e2e/search.spec.js
@@ -1,12 +1,9 @@
-import { delay, clearLocalStorage } from './hook';
-import { checkFilenameForExist } from './test-utils.spec';
import {
- createLocation,
- openLocation,
- defaultLocationPath,
- defaultLocationName
-} from './location.helpers';
-import { clickOn, expectElementExist, setInputValue } from './general.helpers';
+ clickOn,
+ expectElementExist,
+ setInputValue,
+ waitForNotification
+} from './general.helpers';
export const regexQuery = '!"#$%&\'()*+,-./@:;<=>[\\]^_`{|}~';
export const searchTag = 'tag1';
@@ -30,9 +27,7 @@ export async function searchEngine(filename, tagName, resetSearchButton) {
} else {
await clickOn('#searchButton');
}
- await expectElementExist('[data-tid=TIDSearching]', true);
- await expectElementExist('[data-tid=TIDSearching]', false);
- // await global.client.pause(1000); // TODO wait for search results
+ await waitForNotification('TIDSearching');
}
/*describe('TST06 - Test Search in file structure:', () => {