[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:
Devin Binnie 2021-11-04 11:29:32 -04:00 committed by GitHub
parent ba974dbf75
commit 0bd5a54c76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 76 additions and 81 deletions

View file

@ -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",

122
.vscode/launch.json vendored
View file

@ -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"
}
]
}

View file

@ -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.
```

View file

@ -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/';

View file

@ -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';

View file

@ -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';

View file

@ -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")',