Skip to content

Commit 5c44cb2

Browse files
Added cypress tests for startpage
1 parent b4052f8 commit 5c44cb2

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

cypress/e2e/ui/settings.cy.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
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 nums = [...Array(options.length).keys()];
15+
nums.forEach((index) => {
16+
if (options[index].innerText === 'Overview / Utilization') {
17+
cy.get(options[index]).click();
18+
}
19+
});
20+
});
21+
cy.intercept('PATCH', '/api/users/1').as('settingsUpdate');
22+
cy.get('.bx--form > .bx--btn-set > .bx--btn--primary').click();
23+
cy.wait('@settingsUpdate').its('response.statusCode').should('eq', 200);
24+
25+
cy.get('#menu_item_logout').click();
26+
cy.login();
27+
cy.url().should('include', '/utilization');
28+
29+
cy.menu('Settings', 'My Settings');
30+
cy.get('#display\\.startpage').then((value) => {
31+
expect(value[0].value).to.equal('Overview / Utilization');
32+
});
33+
cy.get('#display\\.startpage').click();
34+
cy.get('.bx--list-box__menu-item__option').then((options) => {
35+
const nums = [...Array(options.length).keys()];
36+
nums.forEach((index) => {
37+
if (options[index].innerText === 'Overview / Dashboard') {
38+
cy.get(options[index]).click();
39+
}
40+
});
41+
});
42+
cy.intercept('PATCH', '/api/users/1').as('settingsUpdate');
43+
cy.get('.bx--form > .bx--btn-set > .bx--btn--primary').click();
44+
cy.wait('@settingsUpdate').its('response.statusCode').should('eq', 200);
45+
46+
cy.get('#menu_item_logout').click();
47+
cy.login();
48+
cy.url().should('include', '/dashboard');
549
});
650
});

0 commit comments

Comments
 (0)