Skip to content
Snippets Groups Projects
Verified Commit 4936a172 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3059356 by finnsky, mogtofu33, klausi, jibran, justafish, joaogarin:...

Issue #3059356 by finnsky, mogtofu33, klausi, jibran, justafish, joaogarin: [Security] Update yarn packages to fix 19 vulnerabilities by updating nightwatch
parent 0192048d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"babel-preset-env": "^1.4.0", "babel-preset-env": "^1.4.0",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"chokidar": "^2.0.0", "chokidar": "^2.0.0",
"chromedriver": "^2.35.0", "chromedriver": "^75.1.0",
"cross-env": "^5.1.3", "cross-env": "^5.1.3",
"dotenv-safe": "^5.0.1", "dotenv-safe": "^5.0.1",
"eslint": "^4.19.1", "eslint": "^4.19.1",
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
"glob": "^7.1.2", "glob": "^7.1.2",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"nightwatch": "^0.9.20", "nightwatch": "^1.2.1",
"prettier": "^1.14.0", "prettier": "^1.14.0",
"stylelint": "^9.10.1", "stylelint": "^9.10.1",
"stylelint-checkstyle-formatter": "^0.1.1", "stylelint-checkstyle-formatter": "^0.1.1",
"stylelint-config-standard": "^18.2.0", "stylelint-config-standard": "^18.2.0",
"stylelint-no-browser-hacks": "^1.1.0", "stylelint-no-browser-hacks": "^1.2.1",
"stylelint-order": "^2.1.0" "stylelint-order": "^2.1.0"
}, },
"//": "'development is the default environment, and legacy is for transpiling the old jQuery codebase", "//": "'development is the default environment, and legacy is for transpiling the old jQuery codebase",
......
...@@ -25,14 +25,12 @@ exports.command = function drupalInstall({ setupFile = '' } = {}, callback) { ...@@ -25,14 +25,12 @@ exports.command = function drupalInstall({ setupFile = '' } = {}, callback) {
: ''; : '';
const install = execSync( const install = execSync(
commandAsWebserver( commandAsWebserver(
`php ./scripts/test-site.php install ${setupFile} --base-url ${ `php ./scripts/test-site.php install ${setupFile} --base-url ${process.env.DRUPAL_TEST_BASE_URL} ${dbOption} --json`,
process.env.DRUPAL_TEST_BASE_URL
} ${dbOption} --json`,
), ),
); );
const installData = JSON.parse(install.toString()); const installData = JSON.parse(install.toString());
this.drupalDbPrefix = installData.db_prefix; this.globals.drupalDbPrefix = installData.db_prefix;
this.drupalSitePath = installData.site_path; this.globals.drupalSitePath = installData.site_path;
const url = new URL(process.env.DRUPAL_TEST_BASE_URL); const url = new URL(process.env.DRUPAL_TEST_BASE_URL);
this.url(process.env.DRUPAL_TEST_BASE_URL).setCookie({ this.url(process.env.DRUPAL_TEST_BASE_URL).setCookie({
name: 'SIMPLETEST_USER_AGENT', name: 'SIMPLETEST_USER_AGENT',
......
...@@ -18,9 +18,7 @@ exports.command = function drupalLoginAsAdmin(callback) { ...@@ -18,9 +18,7 @@ exports.command = function drupalLoginAsAdmin(callback) {
} }
const userLink = execSync( const userLink = execSync(
commandAsWebserver( commandAsWebserver(
`php ./scripts/test-site.php user-login 1 --site-path ${ `php ./scripts/test-site.php user-login 1 --site-path ${this.globals.drupalSitePath}`,
this.drupalSitePath
}`,
), ),
); );
......
...@@ -11,7 +11,7 @@ import { commandAsWebserver } from '../globals'; ...@@ -11,7 +11,7 @@ import { commandAsWebserver } from '../globals';
*/ */
exports.command = function drupalUninstal(callback) { exports.command = function drupalUninstal(callback) {
const self = this; const self = this;
const prefix = self.drupalDbPrefix; const prefix = this.globals.drupalDbPrefix;
// Check for any existing errors, because running this will cause Nightwatch to hang. // Check for any existing errors, because running this will cause Nightwatch to hang.
if (!this.currentTest.results.errors && !this.currentTest.results.failed) { if (!this.currentTest.results.errors && !this.currentTest.results.failed) {
......
...@@ -5,13 +5,16 @@ import mkdirp from 'mkdirp'; ...@@ -5,13 +5,16 @@ import mkdirp from 'mkdirp';
import chromedriver from 'chromedriver'; import chromedriver from 'chromedriver';
import nightwatchSettings from './nightwatch.conf'; import nightwatchSettings from './nightwatch.conf';
const commandAsWebserver = command => { export const commandAsWebserver = command => {
if (process.env.DRUPAL_TEST_WEBSERVER_USER) { if (process.env.DRUPAL_TEST_WEBSERVER_USER) {
return `sudo -u ${process.env.DRUPAL_TEST_WEBSERVER_USER} ${command}`; return `sudo -u ${process.env.DRUPAL_TEST_WEBSERVER_USER} ${command}`;
} }
return command; return command;
}; };
export const drupalDbPrefix = null;
export const drupalSitePath = null;
module.exports = { module.exports = {
before: done => { before: done => {
if (JSON.parse(process.env.DRUPAL_TEST_CHROMEDRIVER_AUTOSTART)) { if (JSON.parse(process.env.DRUPAL_TEST_CHROMEDRIVER_AUTOSTART)) {
...@@ -35,9 +38,7 @@ module.exports = { ...@@ -35,9 +38,7 @@ module.exports = {
) { ) {
const resultPath = path.join( const resultPath = path.join(
__dirname, __dirname,
`../../../${nightwatchSettings.output_folder}/consoleLogs/${ `../../../${nightwatchSettings.output_folder}/consoleLogs/${browser.currentTest.module}`,
browser.currentTest.module
}`,
); );
const status = const status =
browser.currentTest.results.errors > 0 || browser.currentTest.results.errors > 0 ||
......
...@@ -50,7 +50,7 @@ module.exports = { ...@@ -50,7 +50,7 @@ module.exports = {
custom_commands_path: collectedFolders.Commands, custom_commands_path: collectedFolders.Commands,
custom_assertions_path: collectedFolders.Assertions, custom_assertions_path: collectedFolders.Assertions,
page_objects_path: collectedFolders.Pages, page_objects_path: collectedFolders.Pages,
globals_path: 'tests/Drupal/Nightwatch/globals.js', globals_path: 'globals.js',
selenium: { selenium: {
start_process: false, start_process: false,
}, },
...@@ -63,6 +63,31 @@ module.exports = { ...@@ -63,6 +63,31 @@ module.exports = {
browserName: 'chrome', browserName: 'chrome',
acceptSslCerts: true, acceptSslCerts: true,
chromeOptions: { chromeOptions: {
w3c: false,
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
: [],
},
},
screenshots: {
enabled: true,
on_failure: true,
on_error: true,
path: `${process.env.DRUPAL_NIGHTWATCH_OUTPUT}/screenshots`,
},
end_session_on_fail: false,
},
local: {
webdriver: {
start_process: process.env.DRUPAL_TEST_CHROMEDRIVER_AUTOSTART,
port: process.env.DRUPAL_TEST_WEBDRIVER_PORT,
server_path: 'node_modules/.bin/chromedriver',
},
desiredCapabilities: {
browserName: 'chrome',
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ') ? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
: [], : [],
......
...@@ -76,14 +76,17 @@ chromedriver using port 4444, and keep it running: ...@@ -76,14 +76,17 @@ chromedriver using port 4444, and keep it running:
(e.g. by running `composer install`) (e.g. by running `composer install`)
* Install [Node.js](https://nodejs.org/en/download/) and * Install [Node.js](https://nodejs.org/en/download/) and
[yarn](https://yarnpkg.com/en/docs/install). The versions required are [yarn](https://yarnpkg.com/en/docs/install). The versions required are
specificed inside core/package.json in the `engines` field specified inside core/package.json in the `engines` field. You can use
[nvm](https://github.com/nvm-sh/nvm) and [yvm](https://github.com/tophat/yvm)
to manage your local versions of these.
* Install * Install
[Google Chrome](https://www.google.com/chrome/browser/desktop/index.html) [Google Chrome](https://www.google.com/chrome/browser/desktop/index.html)
* Inside the `core` folder, run `yarn install` * Inside the `core` folder, run `yarn install`
* Configure the nightwatch settings by copying `.env.example` to `.env` and * Configure the nightwatch settings by copying `.env.example` to `.env` and
editing as necessary. editing as necessary.
* Ensure you have a web server running (as instructed in `.env`) * Ensure you have a web server running (as instructed in `.env`)
* Again inside the `core` folder, run `yarn test:nightwatch` to run the tests. * Again inside the `core` folder, run `yarn test:nightwatch --env local` to run
the tests.
By default this will output reports to `core/reports` By default this will output reports to `core/reports`
* Nightwatch will run tests for core, as well as contrib and custom modules and * Nightwatch will run tests for core, as well as contrib and custom modules and
themes. It will search for tests located under folders with the pattern themes. It will search for tests located under folders with the pattern
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment