chore: fix e2e tests and add new for x-tag

This commit is contained in:
Alex Varchuk 2023-07-19 12:37:19 +03:00
parent 869216ecab
commit 2e55017136
No known key found for this signature in database
GPG Key ID: 8A9260AE529FF454

View File

@ -1,22 +1,22 @@
describe('Menu', () => { describe('Menu', () => {
describe('3.0 spec', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('e2e/standalone.html'); cy.visit('e2e/standalone.html');
}); });
it('should have valid items count', () => { it('should have valid items count', () => {
cy.get('.menu-content').find('li').should('have.length', 34); cy.get('.menu-content').find('li').should('have.length', 35);
}); });
it('should sync active menu items while scroll', () => { it('should sync active menu items while scroll', () => {
cy.contains('h1', 'Introduction') cy.contains('h1', 'Introduction')
.scrollIntoView() .scrollIntoView()
.get('[role=menuitem].active') .get('[role=menuitem] > label.active')
.should('have.text', 'Introduction'); .should('have.text', 'Introduction');
cy.contains('h2', 'Add a new pet to the store') cy.contains('h2', 'Add a new pet to the store')
.scrollIntoView() .scrollIntoView()
.wait(100) .wait(100)
.get('[role=menuitem].active') .get('[role=menuitem] > label.active')
.children() .children()
.last() .last()
.should('have.text', 'Add a new pet to the store') .should('have.text', 'Add a new pet to the store')
@ -27,7 +27,7 @@ describe('Menu', () => {
cy.contains('h2', 'Add a new pet to the store') cy.contains('h2', 'Add a new pet to the store')
.scrollIntoView() .scrollIntoView()
.wait(100) .wait(100)
.get('[role=menuitem].active') .get('[role=menuitem] > label.active')
.children() .children()
.last() .last()
.should('have.text', 'Add a new pet to the store') .should('have.text', 'Add a new pet to the store')
@ -38,14 +38,22 @@ describe('Menu', () => {
cy.contains('h1', 'Introduction') cy.contains('h1', 'Introduction')
.scrollIntoView() .scrollIntoView()
.wait(100) .wait(100)
.get('[role=menuitem].active') .get('[role=menuitem] > label.active')
.should('have.text', 'Introduction'); .should('have.text', 'Introduction');
cy.url().should('include', '#section/Introduction'); cy.url().should('include', '#section/Introduction');
}); });
it('should update URL hash when clicking on menu items', () => { it('should update URL hash when clicking on menu items', () => {
cy.contains('[role=menuitem].-depth1', 'pet').click({ force: true }); cy.contains('[role=menuitem] > label.-depth1', 'pet').click({ force: true });
cy.get('li[data-item-id="schema/Cat"]')
.should('have.text', 'schemaCat')
.click({ force: true });
cy.location('hash').should('equal', '#schema/Cat');
});
it('should contains Cat schema in Pet using x-tags', () => {
cy.contains('[role=menuitem] > label.-depth1', 'pet').click({ force: true });
cy.location('hash').should('equal', '#tag/pet'); cy.location('hash').should('equal', '#tag/pet');
cy.contains('[role=menuitem]', 'Find pet by ID').click({ force: true }); cy.contains('[role=menuitem]', 'Find pet by ID').click({ force: true });
@ -53,10 +61,10 @@ describe('Menu', () => {
}); });
it('should deactivate tag when other is activated', () => { it('should deactivate tag when other is activated', () => {
const petItem = () => cy.contains('[role=menuitem].-depth1', 'pet'); const petItem = () => cy.contains('[role=menuitem] > label.-depth1', 'pet');
petItem().click({ force: true }).should('have.class', 'active'); petItem().click({ force: true }).should('have.class', 'active');
cy.contains('[role=menuitem].-depth1', 'store').click({ force: true }); cy.contains('[role=menuitem] > label.-depth1', 'store').click({ force: true });
petItem().should('not.have.class', 'active'); petItem().should('not.have.class', 'active');
}); });
@ -76,6 +84,7 @@ describe('Menu', () => {
.then($h5 => $h5[0].firstChild!.nodeValue!.trim()) .then($h5 => $h5[0].firstChild!.nodeValue!.trim())
.should('eq', 'Response Schema:'); .should('eq', 'Response Schema:');
}); });
});
it('should be able to open the operation details when the operation IDs have quotes', () => { it('should be able to open the operation details when the operation IDs have quotes', () => {
cy.visit('e2e/standalone-3-1.html'); cy.visit('e2e/standalone-3-1.html');
@ -85,7 +94,7 @@ describe('Menu', () => {
cy.url().should('include', 'deletePetBy%22Id'); cy.url().should('include', 'deletePetBy%22Id');
}); });
it.only('should encode URL when the operation IDs have backslashes', () => { it('should encode URL when the operation IDs have backslashes', () => {
cy.visit('e2e/standalone-3-1.html'); cy.visit('e2e/standalone-3-1.html');
cy.get('label span[title="pet"]').click({ multiple: true, force: true }); cy.get('label span[title="pet"]').click({ multiple: true, force: true });
cy.get('li').contains('OperationId with backslash').click({ multiple: true, force: true }); cy.get('li').contains('OperationId with backslash').click({ multiple: true, force: true });