diff --git a/cypress/src/integration/plugins/catalog.spec.ts b/cypress/src/integration/plugins/catalog.spec.ts index 20dcdd9b8a..adf9b9a384 100644 --- a/cypress/src/integration/plugins/catalog.spec.ts +++ b/cypress/src/integration/plugins/catalog.spec.ts @@ -25,5 +25,62 @@ describe('Catalog', () => { cy.contains('Owned (10)').should('be.visible'); }); + + it('Should navigate to a docs tab', () => { + cy.loginAsGuest(); + + cy.visit('/catalog'); + + cy.contains('techdocs-e2e-fixture').click(); + + cy.location().should(loc => { + expect(loc.pathname).to.eq( + '/catalog/default/component/techdocs-e2e-fixture', + ); + }); + + cy.getCatalogDocsTab().click(); + + cy.getTechDocsShadowRoot() + .find('h1') + .contains('Home page') + .should('be.visible'); + }); + + it('Should navigate to a sub-route in docs tab', () => { + cy.loginAsGuest(); + + cy.visit('/catalog'); + + cy.contains('techdocs-e2e-fixture').click(); + + cy.location().should(loc => { + expect(loc.pathname).to.eq( + '/catalog/default/component/techdocs-e2e-fixture', + ); + }); + + cy.getCatalogDocsTab().click(); + + cy.getTechDocsShadowRoot() + .find('h1') + .contains('Home page') + .should('be.visible'); + + cy.getTechDocsShadowRoot().within(() => { + cy.getTechDocsNavigation().find('a').contains('Sub-page 1').click(); + }); + + cy.location().should(loc => { + expect(loc.pathname).to.eq( + '/catalog/default/component/techdocs-e2e-fixture/docs/sub-page-one/', + ); + }); + + cy.getTechDocsShadowRoot() + .find('h1') + .contains('Sub-page 1') + .should('be.visible'); + }); }); }); diff --git a/cypress/src/support/commands.ts b/cypress/src/support/commands.ts index 9973afb6a7..02723ffc90 100644 --- a/cypress/src/support/commands.ts +++ b/cypress/src/support/commands.ts @@ -64,6 +64,10 @@ Cypress.Commands.add('getTechDocsNavigation', () => { cy.get('[data-md-type="navigation"]'); }); +Cypress.Commands.add('getCatalogDocsTab', () => { + cy.get('button[role="tab"]').contains('Docs'); +}); + Cypress.Commands.add('mockSockJSNode', () => { cy.intercept('GET', '**/sockjs-node/info**', { body: { diff --git a/cypress/src/types.d.ts b/cypress/src/types.d.ts index 838f5571ed..181b608a9b 100644 --- a/cypress/src/types.d.ts +++ b/cypress/src/types.d.ts @@ -42,6 +42,11 @@ declare namespace Cypress { * @example cy.getTechDocsNavigation */ getTechDocsNavigation(): Chainable; + /** + * Get the Catalog docs tab + * @example cy.getCatalogDocsTab + */ + getCatalogDocsTab(): Chainable; /** * Intercept the TechDocs API calls * @example cy.interceptTechDocsAPICalls