Skip to content
Snippets Groups Projects

Draft: Resolve "Implement user journey tests"

Open trantzas requested to merge 26-implement-user-journey-tests into develop
7 files
+ 194
40
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 121
0
describe('user authentication', () => {
beforeEach(() => {
cy.visit(window.location.origin);
})
//edit profile bug
it('should block unauthenticated user from entering a protected route', () => {
cy.checkProtectedRoutes();
});
it('should display login errors when nothing is typed', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#kc-login').click();
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.');
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true'
});
});
it('should display login errors when credentials are wrong', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#username').type('test').blur();
cy.get('#password').type('test').blur();
cy.get('#kc-login').click();
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.');
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true'
});
});
it('should login, logout', () => {
cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services');
cy.get('#navbarDropdown2').click();
cy.window().then((win) => {
expect(win.localStorage.getItem('access_token')).to.exist;
})
cy.get(':nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)').click();
cy.location("pathname").should("equal", "/");
});
it.skip('forget password should work', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get(':nth-child(2) > span > a').click();
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/reset-credentials");
cy.get('#username').should('exist');
});
});
context('register form', () => {
beforeEach(() => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#kc-registration > span > a').click();
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/registration");
});
})
it('register form should not be empty when submitted', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('.pf-c-button').click();
cy.get('#input-error-firstname').should('exist').and('contain', 'Please specify first name.');
cy.get('#input-error-lastname').should('exist').and('contain', 'Please specify last name.');
cy.get('#input-error-email').should('exist').and('contain', 'Please specify email.');
cy.get('#input-error-username').should('exist').and('contain', 'Please specify username.');
cy.get('#input-error-password').should('exist').and('contain', 'Please specify password.');
});
});
it('invalid email', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('#email').type('email');
cy.get('.pf-c-button').click();
cy.get('#input-error-email').should('exist').and('contain','Invalid email address.');
cy.get('#email').type('@example.com');
cy.get('.pf-c-button').click();
cy.get('#input-error-email').should('not.exist');
});
});
it('confirm password field should be the same with password', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('#password').type('123');
cy.get('#password-confirm').type('1234');
cy.get('.pf-c-button').click();
cy.get('#input-error-password-confirm').should('exist').and('contain',"Password confirmation doesn't match.");
cy.get('#password').type('123');
cy.get('#password-confirm').type('123');
cy.get('.pf-c-button').click();
cy.get('#input-error-password-confirm').should('not.exist');
});
});
})
})
\ No newline at end of file
Loading