Skip to content
Snippets Groups Projects
Commit 32e973c0 authored by tzanmix's avatar tzanmix
Browse files

more-custom-commands

parent b679c623
No related branches found
No related tags found
1 merge request!22Draft: Resolve "Implement user journey tests"
This commit is part of merge request !22. Comments created here will be created in the context of that merge request.
import { inject } from "@angular/core";
import { defineConfig } from "cypress"; import { defineConfig } from "cypress";
import { AppService } from "src/app/shared/services/app.service";
//let appConfig = inject(AppService); //let appConfig = inject(AppService);
...@@ -12,5 +10,6 @@ export default defineConfig({ ...@@ -12,5 +10,6 @@ export default defineConfig({
// implement node event listeners here // implement node event listeners here
}, },
baseUrl: "http://localhost:4200/", baseUrl: "http://localhost:4200/",
pageLoadTimeout: 8000
}, },
}); });
...@@ -7,19 +7,7 @@ describe('logged user journeys', () => { ...@@ -7,19 +7,7 @@ describe('logged user journeys', () => {
}); });
it('logs in through services', () => { it('logs in through services', () => {
cy.get(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn').click(); cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services');
//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 //back on services marketplace after login
cy.location("pathname").should("equal", "/services/services_marketplace"); cy.location("pathname").should("equal", "/services/services_marketplace");
...@@ -38,4 +26,13 @@ describe('logged user journeys', () => { ...@@ -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
...@@ -31,7 +31,9 @@ interface Chainable { ...@@ -31,7 +31,9 @@ interface Chainable {
navigateToServices(selector): Chainable<any>, navigateToServices(selector): Chainable<any>,
navigateToResources(selector): Chainable<any>, navigateToResources(selector): Chainable<any>,
navigateToTesting(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) => { ...@@ -103,4 +105,23 @@ Cypress.Commands.add('navigateToProducts', (selector) => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment