diff --git a/plugins/techdocs/src/EntityPageDocs.tsx b/plugins/techdocs/src/EntityPageDocs.tsx
index 29f44f2931..b0e529f9a5 100644
--- a/plugins/techdocs/src/EntityPageDocs.tsx
+++ b/plugins/techdocs/src/EntityPageDocs.tsx
@@ -19,7 +19,8 @@ import React from 'react';
import { Entity, getCompoundEntityRef } from '@backstage/catalog-model';
import { TechDocsReaderPage } from './plugin';
-import { TechDocsReaderLayout } from './reader';
+import { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader';
+import { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent';
type EntityPageDocsProps = { entity: Entity };
@@ -28,7 +29,8 @@ export const EntityPageDocs = ({ entity }: EntityPageDocsProps) => {
return (
-
+
+
);
};
diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx
new file mode 100644
index 0000000000..4b23075908
--- /dev/null
+++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.test.tsx
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2020 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React from 'react';
+import { act } from '@testing-library/react';
+import { ThemeProvider } from '@material-ui/core';
+import { scmIntegrationsApiRef } from '@backstage/integration-react';
+
+import { lightTheme } from '@backstage/theme';
+import { entityRouteRef } from '@backstage/plugin-catalog-react';
+import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
+
+import { techdocsApiRef, techdocsStorageApiRef } from '../../../api';
+
+import { rootRouteRef, rootDocsRouteRef } from '../../../routes';
+
+import { TechDocsReaderPage } from './TechDocsReaderPage';
+
+const mockEntityMetadata = {
+ locationMetadata: {
+ type: 'github',
+ target: 'https://example.com/',
+ },
+ apiVersion: 'v1',
+ kind: 'test',
+ metadata: {
+ name: 'test-name',
+ namespace: 'test-namespace',
+ },
+ spec: {
+ owner: 'test',
+ },
+};
+
+const mockTechDocsMetadata = {
+ site_name: 'test-site-name',
+ site_description: 'test-site-desc',
+};
+
+const getEntityMetadata = jest.fn();
+const getTechDocsMetadata = jest.fn();
+
+const techdocsApiMock = {
+ getEntityMetadata,
+ getTechDocsMetadata,
+};
+
+const techdocsStorageApiMock: jest.Mocked = {
+ getApiOrigin: jest.fn(),
+ getBaseUrl: jest.fn(),
+ getBuilder: jest.fn(),
+ getEntityDocs: jest.fn(),
+ getStorageUrl: jest.fn(),
+ syncEntityDocs: jest.fn(),
+};
+
+const Wrapper = ({ children }: { children: React.ReactNode }) => {
+ return (
+
+
+ {children}
+
+
+ );
+};
+
+const mountedRoutes = {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ '/docs': rootRouteRef,
+ '/docs/:namespace/:kind/:name/*': rootDocsRouteRef,
+};
+
+describe('', () => {
+ beforeEach(() => {
+ getEntityMetadata.mockResolvedValue(mockEntityMetadata);
+ getTechDocsMetadata.mockResolvedValue(mockTechDocsMetadata);
+ });
+
+ afterEach(() => {
+ jest.resetAllMocks();
+ });
+ it('should render a techdocs reader page without children', async () => {
+ const rendered = await renderInTestApp(
+
+
+ ,
+ {
+ mountedRoutes,
+ },
+ );
+
+ // TechDocsReaderPageHeader
+ expect(rendered.container.querySelector('header')).toBeInTheDocument();
+ // TechDocsReaderPageContent
+ expect(rendered.container.querySelector('article')).toBeInTheDocument();
+ });
+
+ it('should render a techdocs reader page with children', async () => {
+ await act(async () => {
+ const rendered = await renderInTestApp(
+
+
+ techdocs reader page
+
+ ,
+ {
+ mountedRoutes,
+ },
+ );
+ expect(
+ rendered.container.querySelector('header'),
+ ).not.toBeInTheDocument();
+ expect(
+ rendered.container.querySelector('article'),
+ ).not.toBeInTheDocument();
+ expect(rendered.getByText('techdocs reader page')).toBeInTheDocument();
+ });
+ });
+});
diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx
index 3c96d463ff..e26cd5a3d6 100644
--- a/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx
+++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx
@@ -61,11 +61,11 @@ export const TechDocsReaderLayout = ({
withHeader = true,
}: TechDocsReaderLayoutProps) => {
return (
- <>
+
{withHeader && }
- >
+
);
};
@@ -101,9 +101,7 @@ export const TechDocsReaderPage = ({
return (
(page as JSX.Element) || (
-
-
-
+
)
);