diff --git a/.eslintrc.json b/.eslintrc.json index fe599fea..4c59f5c6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -39,7 +39,8 @@ }, { "files": [ - "test/**/*" + "e2e/**/*", + "src/**/*.test.js" ], "env": { "jest": true @@ -57,14 +58,14 @@ { "files": [ "webpack.config.renderer.js", - "test/specs/spellchecker_test.js", - "test/specs/app_test.js", - "test/specs/security_test.js", - "test/specs/permisson_test.js", - "test/specs/browser/index_test.js", - "test/specs/browser/settings_test.js", - "test/modules/utils.js", - "test/modules/environment.js", + "e2e/specs/spellchecker_test.js", + "e2e/specs/app_test.js", + "e2e/specs/security_test.js", + "e2e/specs/permisson_test.js", + "e2e/specs/browser/index_test.js", + "e2e/specs/browser/settings_test.js", + "e2e/modules/utils.js", + "e2e/modules/environment.js", "CHANGELOG.md", "webpack.config.base.js", "babel.config.js", diff --git a/.vscode/launch.json b/.vscode/launch.json index 2a80a801..9a4a2486 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,61 +1,61 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Debug Main Process", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", - "runtimeArgs": [ - "src", - "--disable-dev-mode" - ], - "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" - }, - "program": "${workspaceRoot}/src/main.js", - "outFiles": [ - "${workspaceRoot}/src/main_bundle.js" - ], - "sourceMaps": true, - "preLaunchTask": "Build sources" - }, - /* - { - "name": "Debug Renderer Process", - "type": "chrome", - "request": "launch", - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", - "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" - }, - "runtimeArgs": [ - "${workspaceRoot}/src", - "--disable-dev-mode", - "--remote-debugging-port=9222" - ], - "webRoot": "${workspaceRoot}/src/browser", - "sourceMaps": true, - "preLaunchTask": "Build sources" - }, - */ - { - "type": "node", - "request": "launch", - "name": "Mocha Tests", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "args": [ - "-r", - "@babel/register", - "--recursive", - "--timeout", - "999999", - "--colors", - "${workspaceRoot}/test/specs" - ], - "internalConsoleOptions": "openOnSessionStart", - "preLaunchTask": "Build sources" - } - ] -} +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug Main Process", + "cwd": "${workspaceRoot}", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "runtimeArgs": [ + "src", + "--disable-dev-mode" + ], + "windows": { + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" + }, + "program": "${workspaceRoot}/src/main.js", + "outFiles": [ + "${workspaceRoot}/src/main_bundle.js" + ], + "sourceMaps": true, + "preLaunchTask": "Build sources" + }, + /* + { + "name": "Debug Renderer Process", + "type": "chrome", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" + }, + "runtimeArgs": [ + "${workspaceRoot}/src", + "--disable-dev-mode", + "--remote-debugging-port=9222" + ], + "webRoot": "${workspaceRoot}/src/browser", + "sourceMaps": true, + "preLaunchTask": "Build sources" + }, + */ + { + "type": "node", + "request": "launch", + "name": "Mocha Tests", + "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", + "args": [ + "-r", + "@babel/register", + "--recursive", + "--timeout", + "999999", + "--colors", + "${workspaceRoot}/e2e/specs" + ], + "internalConsoleOptions": "openOnSessionStart", + "preLaunchTask": "Build sources" + } + ] +} diff --git a/docs/development.md b/docs/development.md index 9b70e002..2f0d968c 100644 --- a/docs/development.md +++ b/docs/development.md @@ -98,7 +98,7 @@ Mattermost Desktop │   ├── common/ - Common JavaScript modules for both Electron's processes. │   └── main/ - Implementation of Electron's main process. │      └── menus/ - Application menu. -└── test/ - Automated tests. +└── e2e/ - Automated tests.    ├── modules/ - Scripts which are commonly used in tests.    └── specs/ - Test scripts. ``` diff --git a/test/.eslintrc.json b/e2e/.eslintrc.json similarity index 100% rename from test/.eslintrc.json rename to e2e/.eslintrc.json diff --git a/test/modules/environment.js b/e2e/modules/environment.js similarity index 98% rename from test/modules/environment.js rename to e2e/modules/environment.js index 538a0bfc..0a812611 100644 --- a/test/modules/environment.js +++ b/e2e/modules/environment.js @@ -24,7 +24,7 @@ const electronBinaryPath = (() => { const exeExtension = (process.platform === 'win32') ? '.exe' : ''; return path.join(sourceRootDir, 'node_modules/electron/dist/electron' + exeExtension); })(); -const userDataDir = path.join(sourceRootDir, 'test/testUserData/'); +const userDataDir = path.join(sourceRootDir, 'e2e/testUserData/'); const configFilePath = path.join(userDataDir, 'config.json'); const boundsInfoPath = path.join(userDataDir, 'bounds-info.json'); const mattermostURL = 'http://example.com/'; diff --git a/test/modules/test.html b/e2e/modules/test.html similarity index 100% rename from test/modules/test.html rename to e2e/modules/test.html diff --git a/test/modules/utils.js b/e2e/modules/utils.js similarity index 100% rename from test/modules/utils.js rename to e2e/modules/utils.js diff --git a/test/specs/app_test.js b/e2e/specs/app_test.js similarity index 100% rename from test/specs/app_test.js rename to e2e/specs/app_test.js diff --git a/test/specs/browser/index_test.js b/e2e/specs/browser/index_test.js similarity index 100% rename from test/specs/browser/index_test.js rename to e2e/specs/browser/index_test.js diff --git a/test/specs/browser/modal_test.js b/e2e/specs/browser/modal_test.js similarity index 100% rename from test/specs/browser/modal_test.js rename to e2e/specs/browser/modal_test.js diff --git a/test/specs/browser/settings_test.js b/e2e/specs/browser/settings_test.js similarity index 100% rename from test/specs/browser/settings_test.js rename to e2e/specs/browser/settings_test.js diff --git a/test/specs/config_test.js b/e2e/specs/config_test.js similarity index 100% rename from test/specs/config_test.js rename to e2e/specs/config_test.js diff --git a/test/specs/deeplink_test.js b/e2e/specs/deeplink_test.js similarity index 100% rename from test/specs/deeplink_test.js rename to e2e/specs/deeplink_test.js diff --git a/test/specs/index.js b/e2e/specs/index.js similarity index 100% rename from test/specs/index.js rename to e2e/specs/index.js diff --git a/test/specs/main/user_activity_monitor_test.js b/e2e/specs/main/user_activity_monitor_test.js similarity index 100% rename from test/specs/main/user_activity_monitor_test.js rename to e2e/specs/main/user_activity_monitor_test.js diff --git a/test/specs/mattermost_test.js b/e2e/specs/mattermost_test.js similarity index 100% rename from test/specs/mattermost_test.js rename to e2e/specs/mattermost_test.js diff --git a/test/specs/menu_test.js b/e2e/specs/menu_test.js similarity index 100% rename from test/specs/menu_test.js rename to e2e/specs/menu_test.js diff --git a/test/specs/utils/util_test.js b/e2e/specs/utils/util_test.js similarity index 100% rename from test/specs/utils/util_test.js rename to e2e/specs/utils/util_test.js diff --git a/test/specs/window_test.js b/e2e/specs/window_test.js similarity index 100% rename from test/specs/window_test.js rename to e2e/specs/window_test.js diff --git a/test/unit/url_test.js b/src/common/utils/url.test.js similarity index 100% rename from test/unit/url_test.js rename to src/common/utils/url.test.js diff --git a/test/unit/trusted_origins_test.js b/src/main/trustedOrigins.test.js similarity index 98% rename from test/unit/trusted_origins_test.js rename to src/main/trustedOrigins.test.js index 3699cd0e..15123570 100644 --- a/test/unit/trusted_origins_test.js +++ b/src/main/trustedOrigins.test.js @@ -3,7 +3,6 @@ 'use strict'; import assert from 'assert'; -import 'airbnb-js-shims/target/es2015'; import TrustedOriginsStore from 'main/trustedOrigins.ts'; import {BASIC_AUTH_PERMISSION} from 'common/permissions.ts'; diff --git a/test/unit/index.js b/test/unit/index.js deleted file mode 100644 index 7d28e564..00000000 --- a/test/unit/index.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import './trusted_origins_test'; -import './url_test'; diff --git a/webpack.config.test.js b/webpack.config.test.js index 4c27843a..d72f1269 100644 --- a/webpack.config.test.js +++ b/webpack.config.test.js @@ -7,6 +7,7 @@ const path = require('path'); +const glob = require('glob'); const merge = require('webpack-merge'); const base = require('./webpack.config.base'); @@ -15,8 +16,8 @@ const WEBSERVER_PORT = 9001; module.exports = merge(base, { entry: { - test: './test/unit/index.js', - e2e: './test/specs/index.js', + test: glob.sync('./src/**/*.test.js'), + e2e: './e2e/specs/index.js', }, output: { path: path.resolve(__dirname, 'dist/tests'), @@ -29,7 +30,6 @@ module.exports = merge(base, { }], }, externals: { - puppeteer: 'require("puppeteer")', fs: 'require("fs")', ws: 'require("ws")', child_process: 'require("child_process")',