diff --git a/cypress.config.ts b/cypress.config.ts index f7caec46e7eb69491e6e5040cb5a58f991080f5f..d394b94c6120652beb715cd02534e8d7ab776d4d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,7 +1,5 @@ import { defineConfig } from "cypress"; -//let appConfig = inject(AppService); - export default defineConfig({ diff --git a/cypress/e2e/user-journeys-logged-in.cy.ts b/cypress/e2e/user-journeys-logged-in.cy.ts index bb556436beee48070558d846dd467e4a26053d4d..3dedd502a455f70bc5f01d55b3c097a5671167d8 100644 --- a/cypress/e2e/user-journeys-logged-in.cy.ts +++ b/cypress/e2e/user-journeys-logged-in.cy.ts @@ -1,38 +1,102 @@ describe('logged user journeys', () => { - //sign user in before each test beforeEach(() => { - cy.visit("http://localhost:4200/"); - //sign in journey through services portal - + //cy.visit("http://localhost:4200/"); + cy.visit(window.location.origin); }); + afterEach(() => { + //log user out after each test + cy.get('#navbarDropdown2').click(); + cy.get(':nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)').click(); + cy.location("pathname").should("equal", "/"); + }); it('logs in through services', () => { 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"); - - cy.get(':nth-child(2) > #navbarDropdown').each(($link) => { - const url = $link.prop('href'); - console.log(url); - if (url) { - cy.request(url).then((response) => { - expect(response.status).to.eq(200); // Ensure link is not broken - }); - } + //check every 'Manage Services' dropdown item + cy.get(':nth-child(2) > #navbarDropdown').click(); + let i=0; + cy.get('.show .dropdown-item').each(($el) => { + i++; + cy.wrap($el).click(); // Click the link + cy.get(':nth-child(1) > .cdk-column-actions > .btn').first().click(); - cy.wrap($link).click(); // Click the link - cy.url().should('eq', url); // Ensure navigation happened correctly - cy.go('back'); // Navigate back to check the next link + //does the dialog open? + cy.get('mat-dialog-container').should('exist'); + cy.go('back'); + cy.get(':nth-child(2) > #navbarDropdown').click(); + if(i>1) { + return false; + } }); + //access the service specs dropdown + cy.get('#navbarDropdown1').click(); + let j=0; + for(let i=1; i<=2; i++) { + cy.get(`.dropdown-submenu > .dropdown-menu > :nth-child(${i}) `).click(); + cy.location("pathname").should("not.equal", "/services/services_marketplace"); + cy.go('back'); + cy.get(':nth-child(2) > #navbarDropdown').click(); + cy.get('#navbarDropdown1').click(); + } + //check the rest dropdown items + cy.get(':nth-child(4) > .dropdown-item').click(); + cy.get('mat-dialog-container').should('exist'); + cy.go('back'); + cy.get(':nth-child(2) > #navbarDropdown').click(); + + //'Manage Entities' dropdown + cy.manageEntities(':nth-child(3) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2); }); it('logs in through resources', () => { cy.loginPath(':nth-child(3) > .container > .row > .order-md-1 > a > .btn', '/resources'); + cy.location("pathname").should("equal", "/resources/resource_catalogs"); + cy.get('.text-md-right > .btn').click(); + cy.get('mat-dialog-container').should('exist'); + cy.go('back'); + cy.get('#navbarDropdown').click(); + cy.get('.show > :nth-child(2) > .dropdown-item').click(); + cy.location("pathname").should("equal", "/resources/resource_categories"); + cy.get('.text-md-right > .btn').click(); + cy.location("pathname").should("equal", "/resources/resource_categories_update"); + cy.go('back'); + + cy.get('#navbarDropdown').click(); + cy.get('#navbarDropdown1').click(); + for(let i=1; i<=2; i++) { + cy.get(`.dropdown-submenu > .dropdown-menu > :nth-child(${i}) `).click(); + cy.location("pathname").should("not.equal", "/resources/resource_categories"); + cy.go('back'); + cy.get('#navbarDropdown').click(); + cy.get('#navbarDropdown1').click(); + } + + //resource inventory + cy.get(':nth-child(5) > .dropdown-item').click(); + cy.location("pathname").should("equal", "/resources/resource_inventory"); + cy.get('#navbarDropdown').click(); + + //resource pools + cy.get(':nth-child(7) > .dropdown-item').click(); + cy.location("pathname").should("equal", "/resources/resource_pools"); + cy.get('#navbarDropdown').click(); + + //resource reservations + cy.get(':nth-child(8) > .dropdown-item').click(); + cy.location("pathname").should("equal", "/resources/resource_reservations"); + }); it('logs in through testing', () => { cy.loginPath(':nth-child(5) > .container > .row > .order-md-1 > a > .btn', '/testing'); + + cy.manageEntities(':nth-child(1) > #navbarDropdown', '.text-md-right > .btn', 3, 2); + cy.manageEntities(':nth-child(2) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2); }); it('logs in through products', () => { cy.loginPath(':nth-child(6) > .container > .row > :nth-child(2) > a > .btn', '/products'); + cy.manageEntities(':nth-child(2) > #navbarDropdown', '.text-md-right > .btn', 2, 4); + cy.manageEntities(':nth-child(3) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2); }); }) \ No newline at end of file diff --git a/cypress/e2e/user-journeys.cy.ts b/cypress/e2e/user-journeys.cy.ts index 35721fdb95705bb0bd871e365a89d59d23aefbdd..2dc4dc5bc554de4095afdcd97326773eeff5e9f0 100644 --- a/cypress/e2e/user-journeys.cy.ts +++ b/cypress/e2e/user-journeys.cy.ts @@ -1,9 +1,10 @@ -const baseUrl = Cypress.config('baseUrl'); +// const baseUrl = Cypress.config('baseUrl'); describe('user journey', () => { - + beforeEach(() => { - cy.visit(baseUrl); + //cy.visit(baseUrl); + cy.visit(window.location.origin); }) context('user-not-logged-in', () => { @@ -48,7 +49,7 @@ describe('user journey', () => { cy.navigateToProducts(':nth-child(5) > .nav-link'); }) }); - context.only('<who we are> links', () => { + context('<who we are> links', () => { it('checks ETSI SDG OpenSlice Link', () => { cy.get('.ng-star-inserted > :nth-child(1) > .text-white').click(); cy.origin('https://osl.etsi.org/', () => { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 13b0a9193b9862c57f175fb6e49b345ea5f6be74..14577b31beafd0166f3b6af088026c6e8f222319 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,42 +1,18 @@ -/// <reference types="cypress" /> -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -// declare namespace Cypress { -interface Chainable { - navigateToServices(selector): Chainable<any>, - navigateToResources(selector): Chainable<any>, - navigateToTesting(selector): Chainable<any>, - navigateToProducts(selector): Chainable<any>, - authUser(): Chainable<any>, - loginPath(selector, path): Chainable<any> - } + interface Chainable { + navigateToServices(selector): Chainable<any>, + navigateToResources(selector): Chainable<any>, + navigateToTesting(selector): Chainable<any>, + navigateToProducts(selector): Chainable<any>, + authUser(): Chainable<any>, + loginPath(selector, path): Chainable<any>, + manageEntities(selector, button, scndIndx, numOfItems): Chainable<any> + } } + + Cypress.Commands.add('navigateToServices', (selector) => { cy.get(selector).click(); cy.location("pathname").should("equal", "/services"); @@ -52,7 +28,7 @@ Cypress.Commands.add('navigateToServices', (selector) => { cy.get(':nth-child(2) > .nav-item > .nav-link').click(); //sign in button should redirect to auth form - cy.origin('http://portal.openslice.eu', () => { + cy.origin('https://portal.openslice.eu', () => { cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); }); @@ -66,7 +42,7 @@ Cypress.Commands.add('navigateToResources', (selector) => { //cy.get('nav-link').should('exist').click(); //sign in button should redirect to auth form - cy.origin('http://portal.openslice.eu', () => { + cy.origin('https://portal.openslice.eu/', () => { cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); }); @@ -80,7 +56,7 @@ Cypress.Commands.add('navigateToTesting', (selector) => { //cy.get('nav-link').should('exist').click(); //sign in button should redirect to auth form - cy.origin('http://portal.openslice.eu', () => { + cy.origin('https://portal.openslice.eu', () => { cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); }); @@ -101,7 +77,7 @@ Cypress.Commands.add('navigateToProducts', (selector) => { cy.get(':nth-child(2) > .nav-item > .nav-link').click(); //sign in button should redirect to auth form - cy.origin('http://portal.openslice.eu', () => { + cy.origin('https://portal.openslice.eu', () => { cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); }); @@ -110,7 +86,7 @@ Cypress.Commands.add('navigateToProducts', (selector) => { Cypress.Commands.add('authUser', () => { cy.get('.btn').should("contain", "Sign In").click(); - cy.origin('http://portal.openslice.eu', () => { + cy.origin('https://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'); @@ -124,4 +100,20 @@ Cypress.Commands.add('loginPath', (selector, path) => { cy.get(selector).click(); cy.location("pathname").should("equal", path); cy.authUser(); +}) + +Cypress.Commands.add('manageEntities', (selector, button, scndIndx, numOfItems) => { + + for(let i=1; i<=numOfItems; i++) { + cy.get(selector).click(); + if(i == 2 && scndIndx == 3){ + cy.get(`.nav-item.show > .dropdown-menu > :nth-child(3) > .dropdown-item`).click(); + cy.go('back'); + } + + else + cy.get(`.nav-item.show > .dropdown-menu > :nth-child(${i}) > .dropdown-item`).click(); + cy.get(button).click(); + cy.go('back'); + } }) \ No newline at end of file diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index e4e246ec993e4636b1f5c2595090c648d3d6de93..c90b6b6d3e0799ca98447d4d6645bec3bfe9efe1 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -14,4 +14,4 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' \ No newline at end of file +import './commands'