Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
sam committed Feb 25, 2024
1 parent 4744ea5 commit ccda826
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions cypress/e2e/keycloak/admin/admin1_can_login.cy.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
// NO PERMANENT CHANGE TO DATABASE


// temporarily disable uncaught exception handling
import {login} from "../keycloak_reusables.cytools";

let keycloakUrl = Cypress.env('KEYCLOAK_URL')

// check if there is no reference error
if (keycloakUrl === undefined) {
keycloakUrl = 'http://localhost:8080' // default value need for CI
}

if (!['http://localhost:8080', 'http://keycloak:8080'].includes(keycloakUrl)) {
keycloakUrl = 'http://localhost:8080' // default value need for CI
}

// temporarily disable uncaught exception handling
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
Expand All @@ -23,23 +14,39 @@ describe('admin1 can login', function () {
it('admin story', function () {

cy.visit("/")
cy.get('#login').click()

cy.visit("/")
cy.get('#login').click()

cy.origin(keycloakUrl, () => {
cy.get('#username').type('test', {force: true})
cy.log("fill in the login form")
cy.get('#username').type('admin1', {force: true})
cy.get('#password').type('password', {force: true})

// submit
cy.get('#kc-login').click()

cy.location().then((location) => {
if (location !== null && location.origin === keycloakUrl) {
cy.get('#kc-login').click()
} else {
cy.log("not asked for access to user data")
}
})
})

// login(keycloakUrl, "admin1", "password")
//
// cy.log('home page banner contains "admin"')
// cy.get('[data-cy=home_welcome_message]').contains('admin')
//
// cy.log('go to settings page')
// cy.get('[data-cy=settings_link]').click()
//
// cy.log('display informations')
// cy.get('[data-cy=open_my_informations]').click()
//
// cy.log('check if role_admin in the page')
// cy.get('[data-cy=user_roles_container]').contains('ROLE_ADMIN', {timeout: 2000})
cy.log('home page banner contains "admin"')
cy.get('[data-cy=home_welcome_message]').contains('admin')

cy.log('go to settings page')
cy.get('[data-cy=settings_link]').click()

cy.log('display informations')
cy.get('[data-cy=open_my_informations]').click()

cy.log('check if role_admin in the page')
cy.get('[data-cy=user_roles_container]').contains('ROLE_ADMIN', {timeout: 2000})

})
})

0 comments on commit ccda826

Please sign in to comment.