From 354c90467cf302cbfd8013116ef01c2b03d893e9 Mon Sep 17 00:00:00 2001 From: tzanmix <tzanmix@gmail.com> Date: Thu, 6 Feb 2025 13:15:08 +0200 Subject: [PATCH] fixed-config --- cypress.config.ts | 2 + cypress/e2e/user-journeys-logged-in.cy.ts | 41 +++++++++++++++++ cypress/e2e/user-journeys.cy.ts | 56 ++++++++++++++++------- 3 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 cypress/e2e/user-journeys-logged-in.cy.ts diff --git a/cypress.config.ts b/cypress.config.ts index 17161e3..078d58e 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -5,5 +5,7 @@ export default defineConfig({ setupNodeEvents(on, config) { // implement node event listeners here }, + baseUrl: "http://localhost:4200/", + pageLoadTimeout: 80000 }, }); diff --git a/cypress/e2e/user-journeys-logged-in.cy.ts b/cypress/e2e/user-journeys-logged-in.cy.ts new file mode 100644 index 0000000..41c11a1 --- /dev/null +++ b/cypress/e2e/user-journeys-logged-in.cy.ts @@ -0,0 +1,41 @@ +describe('logged user journeys', () => { + //sign user in before each test + beforeEach(() => { + cy.visit("http://localhost:4200/"); + //sign in journey through services portal + + + }); + 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"); + //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 + }); + } + + 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 + }); + + }); +}) \ No newline at end of file diff --git a/cypress/e2e/user-journeys.cy.ts b/cypress/e2e/user-journeys.cy.ts index dc90047..d939eb5 100644 --- a/cypress/e2e/user-journeys.cy.ts +++ b/cypress/e2e/user-journeys.cy.ts @@ -1,10 +1,12 @@ +const baseUrl = Cypress.config('baseUrl'); + describe('user journey', () => { beforeEach(() => { - cy.visit('http://localhost:4200/'); - + cy.visit(baseUrl); }) - context('user-not-logged-in', () => { + + context.skip('user-not-logged-in', () => { it('checks services portal', () => { cy.get(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn').click(); //cy.get(':nth-child(1) > .nav-link').click() @@ -99,14 +101,13 @@ describe('user journey', () => { }); }); - //infinite loop - // it.only('checks linkedin link', () => { - // cy.get(':nth-child(2) > .ng-star-inserted > :nth-child(1)').click(); - // cy.origin('https://www.linkedin.com/company/openslice/', ()=> { - // cy.location("pathname").should("equal", "/"); - // }); - // }); - it.only('checks slack link', () => { + it('checks linkedin link', () => { + cy.get(':nth-child(2) > .ng-star-inserted > :nth-child(1)').click(); + cy.origin('https://www.linkedin.com/company/openslice', ()=> { + cy.location("pathname").should("equal", "/company/openslice"); + }); + }); + it('checks slack link', () => { cy.get(':nth-child(2) > .ng-star-inserted > :nth-child(2)').click(); cy.origin('https://openslice.slack.com/', () => { cy.location("pathname").should("equal", "/"); @@ -114,12 +115,33 @@ describe('user journey', () => { }); }); //twitter test cannot pass, depends on user login - // it.only('checks twitter link', () => { - // cy.get(':nth-child(2) > .ng-star-inserted > :nth-child(3)').click(); - // cy.origin('https://x.com/OpensliceOSS', () => { - // cy.location("pathname").should("equal", '/') - // }); - // }); + it('checks twitter link', () => { + cy.get(':nth-child(2) > .ng-star-inserted > :nth-child(3)').click(); + cy.origin('https://x.com/OpensliceOSS', () => { + cy.location("pathname").should("satisfy", (url) => { + return url === '/OpensliceOSS' || url === '/i/flow/login'; + }) + }); + }); + it('checks ecosystem link', () => { + cy.get('.col-md-10 > :nth-child(1) > a').click(); + cy.origin('https://osl.etsi.org/ecosystem/', () => { + cy.location("pathname").should("equal", "/ecosystem/"); + }); + }); + //never loads, timeout + it.skip('opens terms and conditions', () => { + cy.get('[href="https://osl.etsi.org/files/SDG_OSL_Terms_and_Conditions.pdf"]').click(); + // cy.origin('https://osl.etsi.org/files/SDG_OSL_Terms_and_Conditions.pdf/', () => { + // cy.location("pathname").should("equal", "/files/SDG_OSL_Terms_and_Conditions.pdf/") + // }) + }) + it('checks osl etsi link', () => { + cy.get('[target="_blank"]').click(); + cy.location("pathname").should("equal", "/") + + }) + }); -- GitLab