fix e2e docker:ssh command to work in any repo

This commit is contained in:
Ron Rennick 2020-08-10 14:54:10 -03:00
parent 6aa52c8499
commit c14ce54752
8 changed files with 27 additions and 9 deletions

View File

@ -4,7 +4,7 @@ const { spawnSync } = require( 'child_process' );
const program = require( 'commander' );
const path = require( 'path' );
const fs = require( 'fs' );
const { getAppRoot, getTestConfig } = require( '../utils' );
const { getAppRoot, getAppName, getTestConfig } = require( '../utils' );
const dockerArgs = [];
let command = '';
@ -45,7 +45,7 @@ if ( appPath ) {
}
// Provide an "app name" to use in Docker container names.
envVars.APP_NAME = path.basename( appPath );
envVars.APP_NAME = getAppName();
}
// Load test configuration file into an object.

View File

@ -62,8 +62,7 @@ if ! [[ ${CURRENT_DOMAIN} == ${URL} ]]; then
wp search-replace ${CURRENT_DOMAIN} ${URL}
fi
if [[ $WORDPRESS_INSTALLING ]];
then
if [[ $WORDPRESS_INSTALLING ]]; then
wp post create \
--post_type=page \
--post_status=publish \

View File

@ -50,7 +50,7 @@
"docker:up": "./bin/docker-compose.sh up",
"docker:down": "./bin/docker-compose.sh down",
"docker:clear-all": "docker rmi --force $(docker images -q)",
"docker:ssh": "docker exec -it woocommerce_wordpress-www /bin/bash",
"docker:ssh": "docker exec -it $(node utils/get-app-name.js)_wordpress-www /bin/bash",
"install-wp-tests": "./bin/install-wp-tests.sh",
"test:e2e": "bash ./bin/wait-for-build.sh && ./bin/e2e-test-integration.js",
"test:e2e-dev": "bash ./bin/wait-for-build.sh && ./bin/e2e-test-integration.js --dev"

View File

@ -16,4 +16,12 @@ const getAppRoot = () => {
return appPath;
};
module.exports = getAppRoot;
const getAppName = () => {
const appRoot = getAppRoot();
return path.basename( appRoot );
};
module.exports = {
getAppRoot,
getAppName,
};

7
tests/e2e/env/utils/get-app-name.js vendored Normal file
View File

@ -0,0 +1,7 @@
/**
* Provide the application name to bash scripts.
*/
const { getAppName } = require( './app-root' );
const appName = getAppName();
console.log( appName );

View File

@ -1,4 +1,7 @@
/**
* Provide the base test URL to bash scripts.
*/
const getTestConfig = require( './test-config' );
const testConfig = getTestConfig();
console.log(testConfig.baseUrl);
console.log( testConfig.baseUrl );

View File

@ -1,7 +1,8 @@
const getAppRoot = require( './app-root' );
const { getAppRoot, getAppName } = require( './app-root' );
const getTestConfig = require( './test-config' );
module.exports = {
getAppRoot,
getAppName,
getTestConfig,
};

View File

@ -1,6 +1,6 @@
const path = require( 'path' );
const fs = require( 'fs' );
const getAppRoot = require( './app-root' );
const { getAppRoot } = require( './app-root' );
// Copy local test configuration file if it exists.
const appPath = getAppRoot();