|
1 | 1 | /* eslint-disable no-undef */
|
2 | 2 |
|
3 |
| -Cypress.Commands.add('disableAlertsIfVisible', () => { |
4 |
| - // Look for notification popups and disable them if present |
5 |
| - return cy.get('body').then(($body) => { |
6 |
| - const $link = $body.find( |
7 |
| - '.miq-toast-wrapper .row .alert a:contains("Disable notifications")' |
8 |
| - ); |
9 |
| - if ($link.length && $link.is(':visible')) { |
10 |
| - cy.wrap($link).click({ force: true }); |
11 |
| - } |
12 |
| - return cy.wrap(null); |
13 |
| - }); |
14 |
| -}); |
15 |
| - |
16 | 3 | // user: String of username to log in with, default is admin.
|
17 | 4 | // password: String of password to log in with, default is smartvm.
|
18 |
| -Cypress.Commands.add( |
19 |
| - 'login', |
20 |
| - (user = 'admin', password = 'smartvm', options = {}) => { |
21 |
| - const { disableNotifications = false } = options; |
22 |
| - if (disableNotifications) { |
23 |
| - cy.intercept('GET', '/api/notifications').as('getNotifications'); |
24 |
| - } |
25 |
| - cy.visit('/'); |
| 5 | +Cypress.Commands.add('login', (user = 'admin', password = 'smartvm') => { |
| 6 | + cy.visit('/'); |
26 | 7 |
|
27 |
| - cy.get('#user_name').type(user); |
28 |
| - cy.get('#user_password').type(password); |
29 |
| - const triggerLogin = () => cy.get('#login').click(); |
| 8 | + cy.get('#user_name').type(user); |
| 9 | + cy.get('#user_password').type(password); |
| 10 | + return cy.get('#login').click(); |
| 11 | +}); |
30 | 12 |
|
31 |
| - if (disableNotifications) { |
32 |
| - return triggerLogin() |
33 |
| - .then(() => cy.wait('@getNotifications')) |
34 |
| - .then(() => cy.disableAlertsIfVisible()); |
35 |
| - } |
36 |
| - return triggerLogin(); |
37 |
| - } |
38 |
| -); |
0 commit comments