diff --git a/cypress/integration/intro.spec.ts b/cypress/integration/intro.spec.ts index 8206d92e0..781b7ece1 100644 --- a/cypress/integration/intro.spec.ts +++ b/cypress/integration/intro.spec.ts @@ -11,11 +11,20 @@ describe('Intro page', () => { cy.visit('/') }) - describe('content', () => { + describe('customizable content', () => { it('fetches and shows the correct intro page content', () => { cy.getMarkdownBody() .contains('test content') }) + + it('won\'t show anything if no content was found', () => { + cy.intercept('/mock-backend/public/intro.md', { + statusCode: 404 + }) + + cy.get(`iframe[data-cy="documentIframe"]`) + .should('not.exist') + }) }) describe('features button', () => { diff --git a/src/components/intro-page/hooks/use-intro-page-content.ts b/src/components/intro-page/hooks/use-intro-page-content.ts index f08733a26..29c17ea19 100644 --- a/src/components/intro-page/hooks/use-intro-page-content.ts +++ b/src/components/intro-page/hooks/use-intro-page-content.ts @@ -9,20 +9,15 @@ import { useTranslation } from 'react-i18next' import { fetchFrontPageContent } from '../requests' import { useCustomizeAssetsUrl } from '../../../hooks/common/use-customize-assets-url' -const MARKDOWN_WHILE_LOADING = ':zzz: {message}' -const MARKDOWN_IF_ERROR = ':::danger\n' + - '{message}\n' + - ':::' - -export const useIntroPageContent = (): string => { +export const useIntroPageContent = (): string | undefined => { const { t } = useTranslation() - const [content, setContent] = useState(() => MARKDOWN_WHILE_LOADING.replace('{message}', t('landing.intro.markdownWhileLoading'))) + const [content, setContent] = useState(undefined) const customizeAssetsUrl = useCustomizeAssetsUrl() useEffect(() => { fetchFrontPageContent(customizeAssetsUrl) .then((content) => setContent(content)) - .catch(() => setContent(MARKDOWN_IF_ERROR.replace('{message}', t('landing.intro.markdownLoadingError')))) + .catch(() => setContent(undefined)) }, [customizeAssetsUrl, t]) return content diff --git a/src/components/intro-page/intro-page.tsx b/src/components/intro-page/intro-page.tsx index 961e120a5..792f986aa 100644 --- a/src/components/intro-page/intro-page.tsx +++ b/src/components/intro-page/intro-page.tsx @@ -22,12 +22,12 @@ import { WaitSpinner } from '../common/wait-spinner/wait-spinner' export const IntroPage: React.FC = () => { const introPageContent = useIntroPageContent() - const [showSpinner, setShowSpinner] = useState(true) + const [rendererReady, setRendererReady] = useState(true) return (
-

+

@@ -37,16 +37,18 @@ export const IntroPage: React.FC = () => {

- + - setShowSpinner(!rendererReady)) } - rendererType={ RendererType.INTRO } - forcedDarkMode={ true }/> + + setRendererReady(!rendererReady)) } + rendererType={ RendererType.INTRO } + forcedDarkMode={ true }/> +