diff --git a/cypress.config.ts b/cypress.config.ts index e5f31b453a849322d3653ade504a294bb4386ae9..f7caec46e7eb69491e6e5040cb5a58f991080f5f 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,6 +1,4 @@ -import { inject } from "@angular/core"; import { defineConfig } from "cypress"; -import { AppService } from "src/app/shared/services/app.service"; //let appConfig = inject(AppService); @@ -12,5 +10,6 @@ export default defineConfig({ // implement node event listeners here }, baseUrl: "http://localhost:4200/", + pageLoadTimeout: 8000 }, }); diff --git a/cypress/e2e/user-journeys-logged-in.cy.ts b/cypress/e2e/user-journeys-logged-in.cy.ts index 41c11a1c2d7417f157302348f9786e39135f9cf0..bb556436beee48070558d846dd467e4a26053d4d 100644 --- a/cypress/e2e/user-journeys-logged-in.cy.ts +++ b/cypress/e2e/user-journeys-logged-in.cy.ts @@ -7,19 +7,7 @@ describe('logged user journeys', () => { }); it('logs in through services', () => { - cy.get(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn').click(); - //cy.get(':nth-child(1) > .nav-link').click() - cy.location("pathname").should("equal", "/services"); - // cy.get('.btn').should("contain", "Sign In").click(); - - cy.origin('http://portal.openslice.eu', () => { - cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); - cy.get('#username').type('admin'); - cy.get('#password').type('openslice'); - cy.get('#kc-login').click(); - }); - //redirect page - cy.location("pathname").should("equal", "/redirect"); + cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services'); //back on services marketplace after login cy.location("pathname").should("equal", "/services/services_marketplace"); @@ -38,4 +26,13 @@ describe('logged user journeys', () => { }); }); + it('logs in through resources', () => { + cy.loginPath(':nth-child(3) > .container > .row > .order-md-1 > a > .btn', '/resources'); + }); + it('logs in through testing', () => { + cy.loginPath(':nth-child(5) > .container > .row > .order-md-1 > a > .btn', '/testing'); + }); + it('logs in through products', () => { + cy.loginPath(':nth-child(6) > .container > .row > :nth-child(2) > a > .btn', '/products'); + }); }) \ No newline at end of file diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 96d68efb8c0cedba5bf3ceaf57c89c9eebd12551..13b0a9193b9862c57f175fb6e49b345ea5f6be74 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -31,7 +31,9 @@ interface Chainable { navigateToServices(selector): Chainable<any>, navigateToResources(selector): Chainable<any>, navigateToTesting(selector): Chainable<any>, - navigateToProducts(selector): Chainable<any> + navigateToProducts(selector): Chainable<any>, + authUser(): Chainable<any>, + loginPath(selector, path): Chainable<any> } } @@ -103,4 +105,23 @@ Cypress.Commands.add('navigateToProducts', (selector) => { cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); }); +}); + +Cypress.Commands.add('authUser', () => { + cy.get('.btn').should("contain", "Sign In").click(); + + cy.origin('http://portal.openslice.eu', () => { + cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); + cy.get('#username').type('admin'); + cy.get('#password').type('openslice'); + cy.get('#kc-login').click(); + }); + //redirect page + cy.location("pathname").should("equal", "/redirect"); +}); + +Cypress.Commands.add('loginPath', (selector, path) => { + cy.get(selector).click(); + cy.location("pathname").should("equal", path); + cy.authUser(); }) \ No newline at end of file