Issue #3017176 by finnsky, mogtofu33, alexpott, huzooka, dawehner: Support install profile and language code params in drupalInstall Nightwatch command

merge-requests/2419/head
Lauri Eskola 2020-02-26 18:08:19 +02:00
parent 305c401f90
commit b496f2d6a2
No known key found for this signature in database
GPG Key ID: 37E6EF00B7EEF188
3 changed files with 49 additions and 3 deletions

View File

@ -5,27 +5,36 @@ import { commandAsWebserver } from '../globals';
/**
* Installs a Drupal test site.
*
* @param {oject} [settings={}]
* @param {object} [settings={}]
* Settings object
* @param {string} [settings.setupFile='']
* Setup file used by TestSiteApplicationTest
* @param {string} [settings.installProfile='']
* The install profile to use.
* @param {string} [settings.langcode='']
* The language to install the site in.
* @param {function} callback
* A callback which will be called, when the installation is finished.
* @return {object}
* The 'browser' object.
*/
exports.command = function drupalInstall({ setupFile = '' } = {}, callback) {
exports.command = function drupalInstall(
{ setupFile = '', installProfile = 'nightwatch_testing', langcode = '' } = {},
callback,
) {
const self = this;
try {
setupFile = setupFile ? `--setup-file "${setupFile}"` : '';
installProfile = `--install-profile "${installProfile}"`;
const langcodeOption = langcode ? `--langcode "${langcode}"` : '';
const dbOption =
process.env.DRUPAL_TEST_DB_URL.length > 0
? `--db-url ${process.env.DRUPAL_TEST_DB_URL}`
: '';
const install = execSync(
commandAsWebserver(
`php ./scripts/test-site.php install ${setupFile} --install-profile nightwatch_testing --base-url ${process.env.DRUPAL_TEST_BASE_URL} ${dbOption} --json`,
`php ./scripts/test-site.php install ${setupFile} ${installProfile} ${langcodeOption} --base-url ${process.env.DRUPAL_TEST_BASE_URL} ${dbOption} --json`,
),
);
const installData = JSON.parse(install.toString());

View File

@ -0,0 +1,19 @@
module.exports = {
'@tags': ['core'],
before(browser) {
browser.drupalInstall({
setupFile: 'core/tests/Drupal/TestSite/TestSiteInstallTestScript.php',
installProfile: 'demo_umami',
});
},
after(browser) {
browser.drupalUninstall();
},
'Test umami profile': browser => {
browser
.drupalRelativeURL('/test-page')
.waitForElementVisible('body', 1000)
.assert.elementPresent('#block-umami-branding')
.drupalLogAndEnd({ onlyOnError: false });
},
};

View File

@ -0,0 +1,18 @@
module.exports = {
'@tags': ['core'],
before(browser) {
browser.drupalInstall({
setupFile: 'core/tests/Drupal/TestSite/TestSiteInstallTestScript.php',
langcode: 'fr',
});
},
after(browser) {
browser.drupalUninstall();
},
'Test page with langcode': browser => {
browser
.drupalRelativeURL('/test-page')
.assert.attributeEquals('html', 'lang', 'fr')
.drupalLogAndEnd({ onlyOnError: false });
},
};