mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Refactor to use "data-e2e" attributes in code to make selecting fields/buttons easier in e2e tests
This commit is contained in:
@@ -2,14 +2,18 @@ import { TEST_ADMIN_PASSWORD, TEST_ADMIN_USER, TEST_ENTITY_PUBLICATION } from 'c
|
||||
|
||||
const page = {
|
||||
openLoginMenu() {
|
||||
// Click the closed "Log In" dropdown menu (to open Login menu)
|
||||
cy.get('ds-auth-nav-menu.navbar-collapsed').click();
|
||||
// Click the "Log In" dropdown menu in header
|
||||
cy.get('ds-themed-navbar [data-e2e="login-menu"]').click();
|
||||
},
|
||||
openUserMenu() {
|
||||
// Once logged in, click the User menu in header
|
||||
cy.get('ds-themed-navbar [data-e2e="user-menu"]').click();
|
||||
},
|
||||
submitLoginAndPasswordByPressingEnter(email, password) {
|
||||
// In opened Login modal, fill out email & password, then click Enter
|
||||
cy.get('ds-themed-navbar ds-log-in-password input[type = "email"]').type(email);
|
||||
cy.get('ds-themed-navbar ds-log-in-password input[type = "password"]').type(password);
|
||||
cy.get('ds-themed-navbar ds-log-in-password input[type = "password"]').type('{enter}');
|
||||
cy.get('ds-themed-navbar [data-e2e="email"]').type(email);
|
||||
cy.get('ds-themed-navbar [data-e2e="password"]').type(password);
|
||||
cy.get('ds-themed-navbar [data-e2e="password"]').type('{enter}');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,8 +28,8 @@ describe('Login Modal', () => {
|
||||
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
||||
cy.get('ds-log-in').should('not.exist');
|
||||
|
||||
// Open login menu again, verify user menu & logout button now available
|
||||
page.openLoginMenu();
|
||||
// Open user menu, verify user menu & logout button now available
|
||||
page.openUserMenu();
|
||||
cy.get('ds-user-menu').should('be.visible');
|
||||
cy.get('ds-log-out').should('be.visible');
|
||||
});
|
||||
@@ -41,8 +45,8 @@ describe('Login Modal', () => {
|
||||
page.submitLoginAndPasswordByPressingEnter(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
||||
cy.get('.form-login').should('not.exist');
|
||||
|
||||
// Open login menu again, verify user menu & logout button now available
|
||||
page.openLoginMenu();
|
||||
// Open user menu, verify user menu & logout button now available
|
||||
page.openUserMenu();
|
||||
cy.get('ds-user-menu').should('be.visible');
|
||||
cy.get('ds-log-out').should('be.visible');
|
||||
});
|
||||
@@ -51,23 +55,15 @@ describe('Login Modal', () => {
|
||||
const ENTITYPAGE = '/entities/publication/' + TEST_ENTITY_PUBLICATION;
|
||||
cy.visit(ENTITYPAGE);
|
||||
|
||||
// Login menu should exist
|
||||
cy.get('ds-log-in').should('exist');
|
||||
|
||||
// Login, and the <ds-log-in> tag should no longer exist
|
||||
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
||||
cy.get('ds-log-in').should('not.exist');
|
||||
|
||||
// Verify we are still on the same page
|
||||
cy.url().should('include', ENTITYPAGE);
|
||||
|
||||
// Open login menu again, verify user menu & logout button now available
|
||||
page.openLoginMenu();
|
||||
cy.get('ds-user-menu').should('be.visible');
|
||||
cy.get('ds-log-out').should('be.visible');
|
||||
});
|
||||
|
||||
it('logout should work', () => {
|
||||
it('should support logout', () => {
|
||||
cy.visit('/');
|
||||
|
||||
cy.get('ds-log-in').should('exist');
|
||||
@@ -85,4 +81,32 @@ describe('Login Modal', () => {
|
||||
cy.get('ds-log-in').should('exist');
|
||||
cy.get('ds-log-out').should('not.exist');
|
||||
});
|
||||
|
||||
it('should allow new user registration', () => {
|
||||
cy.visit('/');
|
||||
|
||||
page.openLoginMenu();
|
||||
|
||||
// Registration link should be visible
|
||||
cy.get('ds-themed-navbar [data-e2e="register"]').should('be.visible');
|
||||
|
||||
// Click registration link & you should go to registration page
|
||||
cy.get('ds-themed-navbar [data-e2e="register"]').click();
|
||||
cy.location('pathname').should('eq', '/register');
|
||||
cy.get('ds-register-email').should('exist');
|
||||
});
|
||||
|
||||
it('should allow forgot password', () => {
|
||||
cy.visit('/');
|
||||
|
||||
page.openLoginMenu();
|
||||
|
||||
// Forgot password link should be visible
|
||||
cy.get('ds-themed-navbar [data-e2e="forgot"]').should('be.visible');
|
||||
|
||||
// Click link & you should go to Forgot Password page
|
||||
cy.get('ds-themed-navbar [data-e2e="forgot"]').click();
|
||||
cy.location('pathname').should('eq', '/forgot');
|
||||
cy.get('ds-forgot-email').should('exist');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user