increase login code coverage

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-30 10:13:34 -05:00
parent e895909392
commit b1cc77ac53
6 changed files with 35 additions and 2 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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
});
});
});

View File

@ -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
})
})
})

View File

@ -58,5 +58,5 @@ export function getSafeRedirectURL(possibleRedirectURL = '') {
return urlPrefix + urlToCheck;
}
}
return urlPrefix + '/dashboard';
return urlPrefix + '/dashboard/';
}

View File

@ -81,5 +81,5 @@ export function getSafeRedirectURL(possibleRedirectURL = ''): string {
}
}
return urlPrefix + '/dashboard'
return urlPrefix + '/dashboard/'
}