diff --git a/apps/google-docs/.env.example b/apps/google-docs/.env.example index 01cbc6d89d..07c538bb66 100644 --- a/apps/google-docs/.env.example +++ b/apps/google-docs/.env.example @@ -2,8 +2,5 @@ STATIC_S3_BASE= GOOGLE_DOCS_CLOUDFRONT_DIST_ID= CONTENTFUL_ACCESS_TOKEN= -# Frontend (Vite): dev-only UI to view a review payload from a fixture. -VITE_ENABLE_MOCK_REVIEW_PAYLOAD= - # Frontend (Vite): dev-only UI to preview the exclude/edit modal inside the mapping view. VITE_ENABLE_MOCK_EDIT_MODAL= diff --git a/apps/google-docs/src/fixtures/googleDocsReview/loadFixtureReviewPayload.ts b/apps/google-docs/src/fixtures/googleDocsReview/loadFixtureReviewPayload.ts deleted file mode 100644 index 337d2d8886..0000000000 --- a/apps/google-docs/src/fixtures/googleDocsReview/loadFixtureReviewPayload.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { MappingReviewSuspendPayload } from '@types'; - -// This file is temporary to load a mapping suspend payload from the fixture.json file to speed up development. -// TODO: remove this file before launch -type FixtureReviewPayloadModule = - | MappingReviewSuspendPayload - | { - default: MappingReviewSuspendPayload; - }; - -type FixtureReviewPayloadImporter = () => Promise; - -export async function resolveFixtureReviewPayload( - importers: Record -): Promise { - const importer = Object.values(importers)[0]; - - if (!importer) { - return null; - } - - const module = await importer(); - - if ('default' in module) { - return module.default; - } - - return module; -} - -export async function loadFixtureReviewPayload(): Promise { - return resolveFixtureReviewPayload( - import.meta.glob('./fixture.json') - ); -} diff --git a/apps/google-docs/src/locations/Page/Page.tsx b/apps/google-docs/src/locations/Page/Page.tsx index ffe81da589..c9ba3e4bf1 100644 --- a/apps/google-docs/src/locations/Page/Page.tsx +++ b/apps/google-docs/src/locations/Page/Page.tsx @@ -1,19 +1,16 @@ -import { useEffect, useRef, useState } from 'react'; +import { useRef, useState } from 'react'; import { PageAppSDK } from '@contentful/app-sdk'; import { useSDK } from '@contentful/react-apps-toolkit'; -import { Button, Layout } from '@contentful/f36-components'; +import { Layout } from '@contentful/f36-components'; import { ModalOrchestrator, ModalOrchestratorHandle, } from './components/mainpage/ModalOrchestrator'; import { MainPageView } from './components/mainpage/MainPageView'; import { ReviewPage } from './components/review/ReviewPage'; -import { loadFixtureReviewPayload } from '../../fixtures/googleDocsReview/loadFixtureReviewPayload'; import type { MappingReviewSuspendPayload } from '@types'; import { useWorkflowAgent } from '@hooks/useWorkflowAgent'; -const enableMockReviewPayload = import.meta.env.VITE_ENABLE_MOCK_REVIEW_PAYLOAD === 'true'; - const Page = () => { const sdk = useSDK(); const modalOrchestratorRef = useRef(null); @@ -24,35 +21,12 @@ const Page = () => { payload: MappingReviewSuspendPayload; runId?: string; } | null>(null); - const [fixtureReviewPayload, setFixtureReviewPayload] = - useState(null); const { resumeWorkflow } = useWorkflowAgent({ sdk, documentId: '', oauthToken: '', }); - // TODO: remove fixture review payload loading before launch - useEffect(() => { - let isCancelled = false; - - void loadFixtureReviewPayload() - .then((payload) => { - if (!isCancelled) { - setFixtureReviewPayload(payload); - } - }) - .catch(() => { - if (!isCancelled) { - setFixtureReviewPayload(null); - } - }); - - return () => { - isCancelled = true; - }; - }, []); - const handleOauthTokenChange = (token: string) => { setOauthToken(token); }; @@ -104,24 +78,16 @@ const Page = () => { onReturnToMainPage={handleReturnToMainPage} /> ) : ( - <> - {/* TODO: remove mock review payload button before launch */} - {enableMockReviewPayload && fixtureReviewPayload ? ( - - ) : null} - - + )} diff --git a/apps/google-docs/src/vite-env.d.ts b/apps/google-docs/src/vite-env.d.ts index 62d6804974..f4a4fb8e66 100644 --- a/apps/google-docs/src/vite-env.d.ts +++ b/apps/google-docs/src/vite-env.d.ts @@ -2,7 +2,6 @@ interface ImportMetaEnv { readonly VITE_ENABLE_MOCK_EDIT_MODAL?: string; - readonly VITE_ENABLE_MOCK_REVIEW_PAYLOAD?: string; } declare module '*.png' { diff --git a/apps/google-docs/test/locations/Page/Page.spec.tsx b/apps/google-docs/test/locations/Page/Page.spec.tsx index 00a626a57d..edc7572429 100644 --- a/apps/google-docs/test/locations/Page/Page.spec.tsx +++ b/apps/google-docs/test/locations/Page/Page.spec.tsx @@ -42,7 +42,7 @@ vi.mock('../../../src/locations/Page/components/mainpage/OAuthConnector', () => })); vi.mock('../../../src/locations/Page/components/review/mapping/MappingView', () => ({ - MappingView: () =>
Mock fixture review
, + MappingView: () =>
Mock MappingView
, })); const { mockModalOrchestrator } = vi.hoisted(() => ({ @@ -132,7 +132,7 @@ describe('Page component', () => { await waitFor(() => { expect(screen.getByText('Create from document "Document mapping review"')).toBeTruthy(); - expect(screen.getByText('Mock fixture review')).toBeTruthy(); + expect(screen.getByText('Mock MappingView')).toBeTruthy(); expect(screen.queryByRole('heading', { name: 'Drive Integration' })).toBeNull(); }); });