From 449d6527e403f3da2d82786ed8f203114b73d625 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Tue, 17 May 2022 12:39:24 +0200 Subject: [PATCH 1/3] refactor(techdocs): change entity docs path to be more specific Signed-off-by: Camila Belo --- plugins/techdocs/src/Router.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs/src/Router.tsx b/plugins/techdocs/src/Router.tsx index e04090089a..de63838bc8 100644 --- a/plugins/techdocs/src/Router.tsx +++ b/plugins/techdocs/src/Router.tsx @@ -69,7 +69,7 @@ export const EmbeddedDocsRouter = (props: PropsWithChildren<{}>) => { return ( - }> + }> {children} From 79774207791c29dde1cdb849e51f7f5bfc671f0e Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Tue, 17 May 2022 12:40:16 +0200 Subject: [PATCH 2/3] test(techdocs): cover entity docs sub-routes Signed-off-by: Camila Belo --- .../src/integration/plugins/catalog.spec.ts | 57 +++++++++++++++++++ cypress/src/support/commands.ts | 4 ++ cypress/src/types.d.ts | 5 ++ 3 files changed, 66 insertions(+) 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 From 50ff56a80f4f0f7855211fb45efcfbaa6fde47bb Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Tue, 17 May 2022 12:48:44 +0200 Subject: [PATCH 3/3] chore(techdocs): add changeset file Signed-off-by: Camila Belo --- .changeset/techdocs-ways-type.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/techdocs-ways-type.md diff --git a/.changeset/techdocs-ways-type.md b/.changeset/techdocs-ways-type.md new file mode 100644 index 0000000000..6e147f62a7 --- /dev/null +++ b/.changeset/techdocs-ways-type.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Change the `EntityDocsPage` path to be more specific and also add integration tests for `sub-routes` on this page.