[MM-39839] Changes for writing unit tests, some re-org (#1849)
* Move tests to individual folders * Moved e2e tests to e2e folder, fixed lint issues * Lint fix
This commit is contained in:
parent
ba974dbf75
commit
0bd5a54c76
|
@ -39,7 +39,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
"test/**/*"
|
"e2e/**/*",
|
||||||
|
"src/**/*.test.js"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"jest": true
|
"jest": true
|
||||||
|
@ -57,14 +58,14 @@
|
||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
"webpack.config.renderer.js",
|
"webpack.config.renderer.js",
|
||||||
"test/specs/spellchecker_test.js",
|
"e2e/specs/spellchecker_test.js",
|
||||||
"test/specs/app_test.js",
|
"e2e/specs/app_test.js",
|
||||||
"test/specs/security_test.js",
|
"e2e/specs/security_test.js",
|
||||||
"test/specs/permisson_test.js",
|
"e2e/specs/permisson_test.js",
|
||||||
"test/specs/browser/index_test.js",
|
"e2e/specs/browser/index_test.js",
|
||||||
"test/specs/browser/settings_test.js",
|
"e2e/specs/browser/settings_test.js",
|
||||||
"test/modules/utils.js",
|
"e2e/modules/utils.js",
|
||||||
"test/modules/environment.js",
|
"e2e/modules/environment.js",
|
||||||
"CHANGELOG.md",
|
"CHANGELOG.md",
|
||||||
"webpack.config.base.js",
|
"webpack.config.base.js",
|
||||||
"babel.config.js",
|
"babel.config.js",
|
||||||
|
|
122
.vscode/launch.json
vendored
122
.vscode/launch.json
vendored
|
@ -1,61 +1,61 @@
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Debug Main Process",
|
"name": "Debug Main Process",
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"src",
|
"src",
|
||||||
"--disable-dev-mode"
|
"--disable-dev-mode"
|
||||||
],
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
||||||
},
|
},
|
||||||
"program": "${workspaceRoot}/src/main.js",
|
"program": "${workspaceRoot}/src/main.js",
|
||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceRoot}/src/main_bundle.js"
|
"${workspaceRoot}/src/main_bundle.js"
|
||||||
],
|
],
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"preLaunchTask": "Build sources"
|
"preLaunchTask": "Build sources"
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"name": "Debug Renderer Process",
|
"name": "Debug Renderer Process",
|
||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
||||||
"windows": {
|
"windows": {
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
||||||
},
|
},
|
||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"${workspaceRoot}/src",
|
"${workspaceRoot}/src",
|
||||||
"--disable-dev-mode",
|
"--disable-dev-mode",
|
||||||
"--remote-debugging-port=9222"
|
"--remote-debugging-port=9222"
|
||||||
],
|
],
|
||||||
"webRoot": "${workspaceRoot}/src/browser",
|
"webRoot": "${workspaceRoot}/src/browser",
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"preLaunchTask": "Build sources"
|
"preLaunchTask": "Build sources"
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Mocha Tests",
|
"name": "Mocha Tests",
|
||||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
||||||
"args": [
|
"args": [
|
||||||
"-r",
|
"-r",
|
||||||
"@babel/register",
|
"@babel/register",
|
||||||
"--recursive",
|
"--recursive",
|
||||||
"--timeout",
|
"--timeout",
|
||||||
"999999",
|
"999999",
|
||||||
"--colors",
|
"--colors",
|
||||||
"${workspaceRoot}/test/specs"
|
"${workspaceRoot}/e2e/specs"
|
||||||
],
|
],
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
"preLaunchTask": "Build sources"
|
"preLaunchTask": "Build sources"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ Mattermost Desktop
|
||||||
│ ├── common/ - Common JavaScript modules for both Electron's processes.
|
│ ├── common/ - Common JavaScript modules for both Electron's processes.
|
||||||
│ └── main/ - Implementation of Electron's main process.
|
│ └── main/ - Implementation of Electron's main process.
|
||||||
│ └── menus/ - Application menu.
|
│ └── menus/ - Application menu.
|
||||||
└── test/ - Automated tests.
|
└── e2e/ - Automated tests.
|
||||||
├── modules/ - Scripts which are commonly used in tests.
|
├── modules/ - Scripts which are commonly used in tests.
|
||||||
└── specs/ - Test scripts.
|
└── specs/ - Test scripts.
|
||||||
```
|
```
|
||||||
|
|
|
@ -24,7 +24,7 @@ const electronBinaryPath = (() => {
|
||||||
const exeExtension = (process.platform === 'win32') ? '.exe' : '';
|
const exeExtension = (process.platform === 'win32') ? '.exe' : '';
|
||||||
return path.join(sourceRootDir, 'node_modules/electron/dist/electron' + exeExtension);
|
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 configFilePath = path.join(userDataDir, 'config.json');
|
||||||
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
|
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
|
||||||
const mattermostURL = 'http://example.com/';
|
const mattermostURL = 'http://example.com/';
|
|
@ -3,7 +3,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import 'airbnb-js-shims/target/es2015';
|
|
||||||
|
|
||||||
import TrustedOriginsStore from 'main/trustedOrigins.ts';
|
import TrustedOriginsStore from 'main/trustedOrigins.ts';
|
||||||
import {BASIC_AUTH_PERMISSION} from 'common/permissions.ts';
|
import {BASIC_AUTH_PERMISSION} from 'common/permissions.ts';
|
|
@ -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';
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const glob = require('glob');
|
||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
|
|
||||||
const base = require('./webpack.config.base');
|
const base = require('./webpack.config.base');
|
||||||
|
@ -15,8 +16,8 @@ const WEBSERVER_PORT = 9001;
|
||||||
|
|
||||||
module.exports = merge(base, {
|
module.exports = merge(base, {
|
||||||
entry: {
|
entry: {
|
||||||
test: './test/unit/index.js',
|
test: glob.sync('./src/**/*.test.js'),
|
||||||
e2e: './test/specs/index.js',
|
e2e: './e2e/specs/index.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'dist/tests'),
|
path: path.resolve(__dirname, 'dist/tests'),
|
||||||
|
@ -29,7 +30,6 @@ module.exports = merge(base, {
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
puppeteer: 'require("puppeteer")',
|
|
||||||
fs: 'require("fs")',
|
fs: 'require("fs")',
|
||||||
ws: 'require("ws")',
|
ws: 'require("ws")',
|
||||||
child_process: 'require("child_process")',
|
child_process: 'require("child_process")',
|
||||||
|
|
Loading…
Reference in a new issue