mirror of https://github.com/rancher/dashboard.git
fix login tests w/ sessions
This commit is contained in:
parent
e38f9ed8e2
commit
51a85fb20b
|
|
@ -1,24 +1,26 @@
|
|||
// describe('Local authentication', () => {
|
||||
// it('Log in with valid creds', () => {
|
||||
// cy.visit('/auth/login');
|
||||
// cy.intercept('POST', '/v3-public/localProviders/local*').as('loginReq');
|
||||
describe('Local authentication', () => {
|
||||
it('Log in with valid creds', () => {
|
||||
cy.visit('/auth/login');
|
||||
cy.intercept('POST', '/v3-public/localProviders/local*').as('loginReq');
|
||||
|
||||
// cy.login(Cypress.env('username'), Cypress.env('password'));
|
||||
cy.login(Cypress.env('username'), Cypress.env('password'), false);
|
||||
|
||||
// cy.wait('@loginReq').then((login) => {
|
||||
// expect(login.response?.statusCode).to.equal(200);
|
||||
// cy.url().should('not.equal', `${ Cypress.config().baseUrl }/auth/login`);
|
||||
// });
|
||||
// });
|
||||
cy.wait('@loginReq').then((login) => {
|
||||
expect(login.response?.statusCode).to.equal(200);
|
||||
cy.url().should('not.equal', `${ Cypress.config().baseUrl }/auth/login`);
|
||||
});
|
||||
});
|
||||
|
||||
// it('Cannot login with invalid creds', () => {
|
||||
// cy.intercept('POST', '/v3-public/localProviders/local*').as('loginReq');
|
||||
it('Cannot login with invalid creds', () => {
|
||||
cy.visit('/auth/login');
|
||||
|
||||
// cy.login(Cypress.env('username'), `${ Cypress.env('password') }abc`);
|
||||
cy.intercept('POST', '/v3-public/localProviders/local*').as('loginReq');
|
||||
|
||||
// cy.wait('@loginReq').then((login) => {
|
||||
// expect(login.response?.statusCode).to.not.equal(200);
|
||||
// cy.url().should('equal', `${ Cypress.config().baseUrl }/auth/login`);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
cy.login(Cypress.env('username'), `${ Cypress.env('password') }abc`, false);
|
||||
|
||||
cy.wait('@loginReq').then((login) => {
|
||||
expect(login.response?.statusCode).to.not.equal(200);
|
||||
cy.url().should('equal', `${ Cypress.config().baseUrl }/auth/login`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Cypress.Commands.add('login', (username = Cypress.env('username'), password = Cypress.env('password')) => {
|
||||
cy.session([username, password], () => {
|
||||
Cypress.Commands.add('login', (username = Cypress.env('username'), password = Cypress.env('password'), cacheSession = true) => {
|
||||
const login = () => {
|
||||
cy.intercept('POST', '/v3-public/localProviders/local*').as('loginReq');
|
||||
cy.visit('/auth/login');
|
||||
|
||||
|
|
@ -13,7 +13,13 @@ Cypress.Commands.add('login', (username = Cypress.env('username'), password = Cy
|
|||
|
||||
cy.get('button').click();
|
||||
cy.wait('@loginReq');
|
||||
});
|
||||
};
|
||||
|
||||
if (cacheSession) {
|
||||
cy.session([username, password], login);
|
||||
} else {
|
||||
login();
|
||||
}
|
||||
});
|
||||
|
||||
Cypress.Commands.add('byLabel', (label) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue