Skip to content

Commit 06ced01

Browse files
Added cypress tests for startpage
1 parent b4052f8 commit 06ced01

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

cypress/e2e/ui/settings.cy.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,48 @@
11
/* eslint-disable no-undef */
2-
describe('GTL', () => {
2+
describe('Settings > My Settings', () => {
33
beforeEach(() => {
44
cy.login();
5+
cy.menu('Settings', 'My Settings');
6+
});
7+
8+
it('Saves the start page setting', () => {
9+
cy.get('#display\\.startpage').then((value) => {
10+
expect(value[0].value).to.be.oneOf(['', 'Overview / Dashboard']);
11+
});
12+
cy.get('#display\\.startpage').click();
13+
cy.get('.bx--list-box__menu-item__option').then((options) => {
14+
const optionArray = Cypress.$.makeArray(options);
15+
const match = optionArray.find((el) => el.innerText.trim() === 'Overview / Utilization');
16+
if (match) {
17+
cy.wrap(match).click();
18+
}
19+
});
20+
cy.intercept('PATCH', '/api/users/1').as('settingsUpdate');
21+
cy.get('button').contains('Save').click();
22+
cy.wait('@settingsUpdate').its('response.statusCode').should('eq', 200);
23+
24+
cy.get('#menu_item_logout').click();
25+
cy.login();
26+
cy.url().should('include', '/utilization');
27+
28+
cy.menu('Settings', 'My Settings');
29+
cy.get('#display\\.startpage').then((value) => {
30+
expect(value[0].value).to.equal('Overview / Utilization');
31+
});
32+
cy.get('#display\\.startpage').click();
33+
cy.get('.bx--list-box__menu-item__option').then((options) => {
34+
const optionArray = Cypress.$.makeArray(options);
35+
const match = optionArray.find((el) => el.innerText.trim() === 'Overview / Dashboard');
36+
if (match) {
37+
cy.wrap(match).click();
38+
}
39+
});
40+
cy.intercept('PATCH', '/api/users/1').as('settingsUpdate');
41+
cy.get('button').contains('Save').click();
42+
cy.wait('@settingsUpdate').its('response.statusCode').should('eq', 200);
43+
44+
cy.get('#menu_item_logout').click();
45+
cy.login();
46+
cy.url().should('include', '/dashboard');
547
});
648
});

0 commit comments

Comments
 (0)