2018-02-17 22:27:15 +03:00
|
|
|
describe('Menu', () => {
|
2018-03-15 23:11:20 +03:00
|
|
|
beforeEach(() => {
|
2018-02-17 22:27:15 +03:00
|
|
|
cy.visit('e2e/standalone.html');
|
|
|
|
});
|
|
|
|
|
2018-07-16 18:29:36 +03:00
|
|
|
it('should have valid items count', () => {
|
|
|
|
cy.get('.menu-content')
|
2018-02-17 22:27:15 +03:00
|
|
|
.find('li')
|
2020-08-14 16:33:25 +03:00
|
|
|
.should('have.length', 34);
|
2018-02-17 22:27:15 +03:00
|
|
|
});
|
|
|
|
|
2018-07-16 18:29:36 +03:00
|
|
|
it('should sync active menu items while scroll', () => {
|
|
|
|
cy.contains('h1', 'Introduction')
|
2018-02-17 22:27:15 +03:00
|
|
|
.scrollIntoView()
|
2018-08-22 13:22:58 +03:00
|
|
|
.get('[role=menuitem].active')
|
2018-02-17 22:27:15 +03:00
|
|
|
.should('have.text', 'Introduction');
|
|
|
|
|
2018-07-16 18:29:36 +03:00
|
|
|
cy.contains('h2', 'Add a new pet to the store')
|
2018-02-17 22:27:15 +03:00
|
|
|
.scrollIntoView()
|
2018-08-22 13:22:58 +03:00
|
|
|
.wait(100)
|
|
|
|
.get('[role=menuitem].active')
|
|
|
|
.children()
|
2018-02-17 22:27:15 +03:00
|
|
|
.last()
|
|
|
|
.should('have.text', 'Add a new pet to the store')
|
|
|
|
.should('be.visible');
|
|
|
|
});
|
|
|
|
|
2018-07-16 18:29:36 +03:00
|
|
|
it('should update URL hash when clicking on menu items', () => {
|
2018-03-19 17:33:26 +03:00
|
|
|
cy.contains('[role=menuitem].-depth1', 'pet').click({ force: true });
|
2018-02-17 22:27:15 +03:00
|
|
|
cy.location('hash').should('equal', '#tag/pet');
|
|
|
|
|
2018-07-18 13:05:19 +03:00
|
|
|
cy.contains('[role=menuitem]', 'Find pet by ID').click({ force: true });
|
2018-02-17 22:27:15 +03:00
|
|
|
cy.location('hash').should('equal', '#operation/getPetById');
|
|
|
|
});
|
|
|
|
|
2018-07-16 18:29:36 +03:00
|
|
|
it('should deactivate tag when other is activated', () => {
|
2018-03-19 17:33:26 +03:00
|
|
|
const petItem = () => cy.contains('[role=menuitem].-depth1', 'pet');
|
2018-02-17 22:27:15 +03:00
|
|
|
|
|
|
|
petItem()
|
|
|
|
.click({ force: true })
|
|
|
|
.should('have.class', 'active');
|
2018-07-18 13:05:19 +03:00
|
|
|
cy.contains('[role=menuitem].-depth1', 'store').click({ force: true });
|
2018-02-17 22:27:15 +03:00
|
|
|
petItem().should('not.have.class', 'active');
|
|
|
|
});
|
|
|
|
});
|