Unverified Commit b496f2d6 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3017176 by finnsky, mogtofu33, alexpott, huzooka, dawehner: Support...

Issue #3017176 by finnsky, mogtofu33, alexpott, huzooka, dawehner: Support install profile and language code params in drupalInstall Nightwatch command
parent 305c401f
Loading
Loading
Loading
Loading
+12 −3
Changes for core/tests/Drupal/Nightwatch/Commands/drupalInstall.js: 12 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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());
+19 −0
Changes for core/tests/Drupal/Nightwatch/Tests/installProfileTest.js: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
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 });
  },
};
+18 −0
Changes for core/tests/Drupal/Nightwatch/Tests/langcodeTest.js: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
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 });
  },
};