Skip to content

Commit

Permalink
Adding logout function and refactoring its use.
Browse files Browse the repository at this point in the history
Adding login as admin to delete user

Signed-off-by: Manuel Martín <manuel.martin@suse.com>
  • Loading branch information
mmartin24 committed May 13, 2024
1 parent 230f009 commit 870ab2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cypress/e2e/unit-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ describe('Cypress Library e2e tests', () => {
cy.login();
cypressLib.burgerMenuToggle();
cypressLib.createUser('mytestuserwithrole', 'mytestpassword', 'User-Base', true);
// Log out
cy.get('.user.user-menu').click()
cy.contains('Log Out').should('be.visible').click();
// Log in with new user
// Log out with admin role and login with "User-Base" role to check
// "User-base" does not have these options available
cypressLib.logout();
cy.login('mytestuserwithrole', 'mytestpassword');
cypressLib.burgerMenuToggle();
// Check "User-base" does not have these options available
cy.contains('Continue Delivery').should('not.exist');
cy.contains('Cluster Management').should('not.exist');
// Log out as user and login back as admin to delete created user
cypressLib.logout();
cy.login();
cypressLib.burgerMenuToggle();
cypressLib.deleteUser('mytestuserwithrole');
});

Expand Down
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ export function deleteUser(username) {
cy.contains(username).should('not.exist');
}

/**
* Logout with the current user
* @remarks : Useful when testing role changes
*/
export function logout() {
cy.get('.user.user-menu').click()
cy.contains('Log Out').should('be.visible').click();
cy.contains('You have been logged out.').should('be.visible')
}

/**
* Enable the extension support
* @remarks : Disable the Rancher Repo if you provide your own repo
Expand Down

0 comments on commit 870ab2c

Please sign in to comment.