Merge pull request #11546 from backstage/camilal/add-entity-docs-tests

[TechDocs] Add Entity Docs Tests
This commit is contained in:
Camila Belo
2022-05-17 16:31:19 +02:00
committed by GitHub
5 changed files with 72 additions and 1 deletions
+5
View File
@@ -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.
@@ -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');
});
});
});
+4
View File
@@ -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: {
+5
View File
@@ -42,6 +42,11 @@ declare namespace Cypress {
* @example cy.getTechDocsNavigation
*/
getTechDocsNavigation(): Chainable<Element>;
/**
* Get the Catalog docs tab
* @example cy.getCatalogDocsTab
*/
getCatalogDocsTab(): Chainable<Element>;
/**
* Intercept the TechDocs API calls
* @example cy.interceptTechDocsAPICalls
+1 -1
View File
@@ -69,7 +69,7 @@ export const EmbeddedDocsRouter = (props: PropsWithChildren<{}>) => {
return (
<Routes>
<Route path="*" element={<EntityPageDocs entity={entity} />}>
<Route path="/*" element={<EntityPageDocs entity={entity} />}>
{children}
</Route>
</Routes>