govcms-2.x-dev/tests/cy/cypress/support/authenticate.js

tests/cy/cypress/support/authenticate.js
// --- Commands (Functions) ----------------------------------------------------

// Drupal login.
Cypress.Commands.add("drupalLogin", (user, password) => {
    user = user || Cypress.env('user').super.username
    password = password || Cypress.env('user').super.password

    return cy.request({
        method: 'POST',
        url: '/user/login',
        form: true,
        body: {
            name: user,
            pass: password,
            form_id: 'user_login_form'
        }
    });
});
// Drupal login
Cypress.Commands.add("login", () => {
  // Visit the link.
  cy.visit("user")
  // Login the user with password.
  cy.get("#edit-name").type(Cypress.env('user').super.username)
  cy.get("#edit-pass").type(Cypress.env('user').super.password)
  // Submit the form.
  cy.get("#edit-submit").click()
})
// Drupal logout.
Cypress.Commands.add('drupalLogout', () => {
    return cy.request('/user/logout');
});

// Drupal drush command.
Cypress.Commands.add("drupalDrushCommand", (command) => {
    var cmd = Cypress.env('drupalDrushCmdLine');

    if (cmd == null) {
        cmd = 'drush %command'
    }

    if (typeof command === 'string') {
        command = [command];
    }

    const execCmd = cmd.replace('%command', command.join(' '));

    return cy.exec(execCmd);
});

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc