Skip to content

Commit

Permalink
test(e2e-login): e2e login tests added to cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
pawel-baran-se committed Jan 30, 2025
1 parent c12d906 commit 7fdc9af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ export default defineConfig({
TEST_ADMIN_USER_PASSWORD: process.env.TEST_ADMIN_USER_PASSWORD,
TEST_USER_LOGIN: process.env.TEST_USER_LOGIN,
TEST_USER_PASSWORD: process.env.TEST_USER_PASSWORD,
KEYCLOAK_ISSUER: process.env.KEYCLOAK_ISSUER,
},
});
4 changes: 2 additions & 2 deletions cypress/e2e/loginKeycloak.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Login Keycloak user roles', function () {
cy.keycloakLogin(adminTestUser.login, adminTestUser.password);
cy.getByTestId('header-burgermenu').click();

cy.getByTestId('user-label').should('have.text', 'test');
cy.getByTestId('user-label').should('have.text', 'admin@test.com');
cy.getByTestId('admin-icon').should('exist');
cy.getByTestId('login-button').should('be.not.exist');
cy.keycloakLogout();
Expand All @@ -38,7 +38,7 @@ describe('Login Keycloak user roles', function () {
cy.keycloakLogin(testUser.login, testUser.password);
cy.getByTestId('header-burgermenu').click();

cy.getByTestId('user-label').should('have.text', 'test_user');
cy.getByTestId('user-label').should('have.text', '[email protected]');
cy.getByTestId('user-icon').should('exist');
cy.getByTestId('login-button').should('be.not.exist');
cy.keycloakLogout();
Expand Down
9 changes: 6 additions & 3 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ Cypress.Commands.add('deleteThumbnailFromAas', (aasId: string) => {
Cypress.Commands.add('keycloakLogin', (login: string, password: string) => {
cy.getByTestId('header-burgermenu').click();
cy.getByTestId('login-button').click();
cy.get('#username').type(login);
cy.get('#password').type(password, { log: false });
cy.get('#kc-login').click();
cy.origin(Cypress.env('KEYCLOAK_ISSUER'), { args: { login, password } }, ({ login, password }) => {
cy.get('#username').invoke('focus').type(login);
cy.get('#password').invoke('focus').type(password, { log: false });
cy.get('#kc-login').invoke('focus').click();
});
cy.get('button').click();
});

Cypress.Commands.add('keycloakLogout', () => {
Expand Down
15 changes: 13 additions & 2 deletions docker-compose/compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
cypress-test:
container_name: cypress-test
profiles: ['', 'tests']
profiles: [ '', 'tests' ]
build:
dockerfile: cypress.dockerfile
environment:
Expand All @@ -12,7 +12,12 @@ services:
CYPRESS_AAS_DISCOVERY_API_URL: 'http://mnestix-api:5064/discovery'
MNESTIX_BACKEND_API_KEY: ${MNESTIX_BACKEND_API_KEY:-verySecureApiKey}
ELECTRON_ENABLE_LOGGING: 1
SPLIT: ${SPLIT:-0}
TEST_ADMIN_USER_LOGIN: ${TEST_ADMIN_USER_LOGIN:-test_admin}
TEST_ADMIN_USER_PASSWORD: ${TEST_ADMIN_USER_PASSWORD:-test_admin}
TEST_USER_LOGIN: ${TEST_USER_LOGIN:-test_user}
TEST_USER_PASSWORD: ${TEST_USER_PASSWORD:-test_user}
KEYCLOAK_ISSUER: 'https://mnestix-keycloak.azurewebsites.net'
SPLIT: ${SPLIT:-1}
SPLIT_INDEX: ${SPLIT_INDEX:-0}
volumes:
- ./cypress-artifacts/screenshots:/cypress_Tests/cypress/screenshots
Expand All @@ -31,3 +36,9 @@ services:
SUBMODEL_REPO_API_URL: 'http://mnestix-api:5064/repo'
DISCOVERY_API_URL: 'http://mnestix-api:5064/discovery'
MNESTIX_BACKEND_API_URL: 'http://mnestix-api:5064'
AUTHENTICATION_FEATURE_FLAG: 'true'
NEXTAUTH_URL: 'http://mnestix-browser:3000/'
KEYCLOAK_ENABLED: 'true'
KEYCLOAK_CLIENT_ID: 'mnestix-cypress-e2e-client'
KEYCLOAK_ISSUER: 'https://mnestix-keycloak.azurewebsites.net'
KEYCLOAK_REALM: 'Mnestix'

0 comments on commit 7fdc9af

Please sign in to comment.