diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.js b/cypress/e2e/03-readOnly/readOnlyUser.cy.js index c54ff222..084ad22c 100644 --- a/cypress/e2e/03-readOnly/readOnlyUser.cy.js +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.js @@ -32,6 +32,11 @@ describe('Read Only User', () => { cy.visit('/workOrders'); cy.get("a[href*='/new']").should('not.exist'); }); + it('Redirects to Dashboard when attempting to access the login page while authenticated', () => { + cy.visit('/login'); + cy.wait(200); + cy.location('pathname').should('equal', '/dashboard/'); + }); it('Redirects to Dashboard when attempting to create a work order', () => { cy.visit('/workOrders/new'); cy.wait(200); diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.ts b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts index 40528a8c..923b2f3e 100644 --- a/cypress/e2e/03-readOnly/readOnlyUser.cy.ts +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts @@ -46,6 +46,12 @@ describe('Read Only User', () => { cy.get("a[href*='/new']").should('not.exist') }) + it('Redirects to Dashboard when attempting to access the login page while authenticated', () => { + cy.visit('/login') + cy.wait(200) + cy.location('pathname').should('equal', '/dashboard/') + }) + it('Redirects to Dashboard when attempting to create a work order', () => { cy.visit('/workOrders/new') cy.wait(200) diff --git a/cypress/e2e/xx-other/loginPage.cy.js b/cypress/e2e/xx-other/loginPage.cy.js index 2db0f367..d3be2f2a 100644 --- a/cypress/e2e/xx-other/loginPage.cy.js +++ b/cypress/e2e/xx-other/loginPage.cy.js @@ -30,4 +30,13 @@ describe('Login Page', () => { cy.wait(200); cy.location('pathname').should('contain', '/login'); }); + it('Redirects to login when invalid credentials are used', () => { + cy.get("form [name='userName']").type('*testUser'); + cy.get("form [name='password']").type('b@dP@ssword'); + cy.get('form').submit(); + cy.location('pathname').should('contain', '/login'); + cy.get('form').contains('Login Failed', { + matchCase: false + }); + }); }); diff --git a/cypress/e2e/xx-other/loginPage.cy.ts b/cypress/e2e/xx-other/loginPage.cy.ts index 48d94fe7..37581a97 100644 --- a/cypress/e2e/xx-other/loginPage.cy.ts +++ b/cypress/e2e/xx-other/loginPage.cy.ts @@ -38,4 +38,17 @@ describe('Login Page', () => { cy.wait(200) cy.location('pathname').should('contain', '/login') }) + + it('Redirects to login when invalid credentials are used', () => { + cy.get("form [name='userName']").type('*testUser') + cy.get("form [name='password']").type('b@dP@ssword') + + cy.get('form').submit() + + cy.location('pathname').should('contain', '/login') + + cy.get('form').contains('Login Failed', { + matchCase: false + }) + }) }) diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index c355a57f..78170067 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -58,5 +58,5 @@ export function getSafeRedirectURL(possibleRedirectURL = '') { return urlPrefix + urlToCheck; } } - return urlPrefix + '/dashboard'; + return urlPrefix + '/dashboard/'; } diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index 5613662d..9984fb0a 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -81,5 +81,5 @@ export function getSafeRedirectURL(possibleRedirectURL = ''): string { } } - return urlPrefix + '/dashboard' + return urlPrefix + '/dashboard/' }