Loading .gitignore +4 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,10 @@ npm-debug.log yarn-error.log yarn-error.log testem.log testem.log /typings /typings .env cypress/fixtures cypress/screenshots cypress/downloads # System Files # System Files .DS_Store .DS_Store Loading cypress.config.ts 0 → 100644 +33 −0 Original line number Original line Diff line number Diff line import { defineConfig } from "cypress"; import * as dotenv from "dotenv"; dotenv.config( { path: 'cypress/.env'}); export default defineConfig({ e2e: { setupNodeEvents(on, config) { // implement node event listeners here require("ts-node").register({ project: "tsconfig.json", }); return config; }, //baseUrl: "http://orgosletsitmfweb:4200", baseUrl: process.env.CYPRESS_BASE_URL, pageLoadTimeout: 16000, viewportWidth: 1500, viewportHeight: 900, env: { username: process.env.CYPRESS_username, password: process.env.CYPRESS_password, authURL: process.env.CYPRESS_AUTH_URL, authRealm: process.env.CYPRESS_AUTH_REALM, resetCredentials: process.env.CYPRESS_RESET_CREDENTIALS, registration: process.env.CYPRESS_REGISTRATION } }, }); cypress/default.env 0 → 100644 +7 −0 Original line number Original line Diff line number Diff line CYPRESS_username=admin CYPRESS_password=openslice CYPRESS_BASE_URL=http://localhost:4200/ CYPRESS_AUTH_URL=https://portal.openslice.eu/ CYPRESS_AUTH_REALM=/auth/realms/openslice/protocol/openid-connect/auth CYPRESS_RESET_CREDENTIALS=/auth/realms/openslice/login-actions/reset-credentials CYPRESS_REGISTRATION=/auth/realms/openslice/login-actions/registration No newline at end of file cypress/e2e/auth.cy.ts 0 → 100644 +131 −0 Original line number Original line Diff line number Diff line describe("user authentication", () => { beforeEach(() => { cy.visit(window.location.origin); }); it("should block unauthenticated user from entering a protected route", () => { cy.fixture("routes.json").then((data) => { cy.log(data.routes); for (let route of data.routes) { cy.intercept(route); cy.log(route); cy.visit(route); cy.location("pathname").should("equal", "/"); } }); }); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); 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(1) > .nav-link", "/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("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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); cy.get(":nth-child(2) > span > a").click(); cy.log(Cypress.env("resetCredentials")); cy.location("pathname").should("equal", Cypress.env("resetCredentials")); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); cy.get("#kc-registration > span > a").click(); cy.location("pathname").should("equal", Cypress.env("registration")); }); }); it("register form should not be empty when submitted", () => { cy.origin(Cypress.env("authURL") + Cypress.env("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(Cypress.env("authURL") + Cypress.env("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(Cypress.env("authURL") + Cypress.env("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"); }); }); }); }); cypress/e2e/user-journeys-logged-in.cy.ts 0 → 100644 +102 −0 Original line number Original line Diff line number Diff line describe('logged user journeys', () => { beforeEach(() => { //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"); //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(); //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 Loading
.gitignore +4 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,10 @@ npm-debug.log yarn-error.log yarn-error.log testem.log testem.log /typings /typings .env cypress/fixtures cypress/screenshots cypress/downloads # System Files # System Files .DS_Store .DS_Store Loading
cypress.config.ts 0 → 100644 +33 −0 Original line number Original line Diff line number Diff line import { defineConfig } from "cypress"; import * as dotenv from "dotenv"; dotenv.config( { path: 'cypress/.env'}); export default defineConfig({ e2e: { setupNodeEvents(on, config) { // implement node event listeners here require("ts-node").register({ project: "tsconfig.json", }); return config; }, //baseUrl: "http://orgosletsitmfweb:4200", baseUrl: process.env.CYPRESS_BASE_URL, pageLoadTimeout: 16000, viewportWidth: 1500, viewportHeight: 900, env: { username: process.env.CYPRESS_username, password: process.env.CYPRESS_password, authURL: process.env.CYPRESS_AUTH_URL, authRealm: process.env.CYPRESS_AUTH_REALM, resetCredentials: process.env.CYPRESS_RESET_CREDENTIALS, registration: process.env.CYPRESS_REGISTRATION } }, });
cypress/default.env 0 → 100644 +7 −0 Original line number Original line Diff line number Diff line CYPRESS_username=admin CYPRESS_password=openslice CYPRESS_BASE_URL=http://localhost:4200/ CYPRESS_AUTH_URL=https://portal.openslice.eu/ CYPRESS_AUTH_REALM=/auth/realms/openslice/protocol/openid-connect/auth CYPRESS_RESET_CREDENTIALS=/auth/realms/openslice/login-actions/reset-credentials CYPRESS_REGISTRATION=/auth/realms/openslice/login-actions/registration No newline at end of file
cypress/e2e/auth.cy.ts 0 → 100644 +131 −0 Original line number Original line Diff line number Diff line describe("user authentication", () => { beforeEach(() => { cy.visit(window.location.origin); }); it("should block unauthenticated user from entering a protected route", () => { cy.fixture("routes.json").then((data) => { cy.log(data.routes); for (let route of data.routes) { cy.intercept(route); cy.log(route); cy.visit(route); cy.location("pathname").should("equal", "/"); } }); }); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); 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(1) > .nav-link", "/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("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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); cy.get(":nth-child(2) > span > a").click(); cy.log(Cypress.env("resetCredentials")); cy.location("pathname").should("equal", Cypress.env("resetCredentials")); 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(Cypress.env("authURL"), () => { cy.location("pathname").should("equal", Cypress.env("authRealm")); cy.get("#kc-registration > span > a").click(); cy.location("pathname").should("equal", Cypress.env("registration")); }); }); it("register form should not be empty when submitted", () => { cy.origin(Cypress.env("authURL") + Cypress.env("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(Cypress.env("authURL") + Cypress.env("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(Cypress.env("authURL") + Cypress.env("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"); }); }); }); });
cypress/e2e/user-journeys-logged-in.cy.ts 0 → 100644 +102 −0 Original line number Original line Diff line number Diff line describe('logged user journeys', () => { beforeEach(() => { //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"); //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(); //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