diff --git a/packages/marketplace/src/components/pages/client-app-detail/__test__/client-app-detail.test.tsx b/packages/marketplace/src/components/pages/client-app-detail/__test__/client-app-detail.test.tsx index cbd900bca4..e5d7b5ea0d 100644 --- a/packages/marketplace/src/components/pages/client-app-detail/__test__/client-app-detail.test.tsx +++ b/packages/marketplace/src/components/pages/client-app-detail/__test__/client-app-detail.test.tsx @@ -195,12 +195,7 @@ describe('ClientAppDetail', () => { }) describe('onBackToAppsButtonClick', () => { it('should run correctly', () => { - const fn = onBackToAppsButtonClick(history, 'DEVELOPER') - fn() - expect(history.push).toBeCalledWith(Routes.DEVELOPER_MY_APPS) - }) - it('should run correctly', () => { - const fn = onBackToAppsButtonClick(history, 'CLIENT') + const fn = onBackToAppsButtonClick(history) fn() expect(history.push).toBeCalledWith(Routes.CLIENT) }) diff --git a/packages/marketplace/src/components/pages/client-app-detail/client-app-detail.tsx b/packages/marketplace/src/components/pages/client-app-detail/client-app-detail.tsx index 32080167a9..a2bcc528bf 100644 --- a/packages/marketplace/src/components/pages/client-app-detail/client-app-detail.tsx +++ b/packages/marketplace/src/components/pages/client-app-detail/client-app-detail.tsx @@ -14,7 +14,7 @@ import { Loader, Button, Alert, FormSection } from '@reapit/elements' import clientAppDetailStyles from '@/styles/pages/client-app-detail.scss?mod' import ClientAppInstallConfirmation from '@/components/ui/client-app-detail/client-app-install-confirmation' import { Aside } from './aside' -import { clientFetchAppDetailFailed } from '@/actions/client' +import { clientFetchAppDetail } from '@/actions/client' import { developerApplyAppDetails } from '@/actions/developer' import { useParams } from 'react-router' import { Dispatch } from 'redux' @@ -52,11 +52,8 @@ export const handleUnInstallAppButtonClick = (setIsVisibleUnInstallConfirmation: } } -export const onBackToAppsButtonClick = (history: History, loginType: LoginType) => { +export const onBackToAppsButtonClick = (history: History) => { return () => { - if (loginType === 'DEVELOPER') { - history.push(Routes.DEVELOPER_MY_APPS) - } history.push(Routes.CLIENT) } } @@ -69,18 +66,14 @@ export const handleApplyAppDetailsFromLocalStorage = ( if (loginType !== 'DEVELOPER' || !appId) return try { const appDataString = localStorage.getItem('developer-preview-app') - if (!appDataString) { - throw 'No app preview' - } + if (!appDataString) throw 'No preview data' const appData = JSON.parse(appDataString) - if (appData.id !== appId) { - throw 'No app preview' - } + if (appData.id !== appId) throw 'Preview data not match appId' dispatch(developerApplyAppDetails(appData)) } catch (err) { - dispatch(clientFetchAppDetailFailed(err)) + dispatch(clientFetchAppDetail({ id: appId })) } } @@ -186,20 +179,22 @@ const ClientAppDetail: React.FC = () => { )} /> - -
- -
- -
+ {loginType !== 'DEVELOPER' && ( + +
+ +
+ +
+ )} {isVisibleUninstallConfirmation && ( - + { expect(wrapper).toMatchSnapshot() }) }) + + describe('handleOpenAppPreview', () => { + it('should run correctly', () => { + const appId = 'appId' + const spyOpenUrl = jest.spyOn(window, 'open') + const fn = handleOpenAppPreview(appId) + fn() + expect(spyOpenUrl).toBeCalledWith('developer/apps/appId/preview', '_blank') + }) + }) }) diff --git a/packages/marketplace/src/components/pages/developer-app-detail/app-detail/app-content/app-content.tsx b/packages/marketplace/src/components/pages/developer-app-detail/app-detail/app-content/app-content.tsx index 0d7a64ee7c..837321f023 100644 --- a/packages/marketplace/src/components/pages/developer-app-detail/app-detail/app-content/app-content.tsx +++ b/packages/marketplace/src/components/pages/developer-app-detail/app-detail/app-content/app-content.tsx @@ -92,6 +92,11 @@ export const handleUninstallSuccess = ({ ) } +export const handleOpenAppPreview = (appId: string) => () => { + const url = `developer/apps/${appId}/preview` + window.open(url, '_blank') +} + export const CustomUninstallCell: React.FC<{ onClick: () => void }> = ({ onClick }) => ( Uninstall ) @@ -146,7 +151,7 @@ const AppContent: React.FC = ({ appDetailState }) => {
See listing preview{' '} - +

The listing preview will display your app as it would appear in the Marketplace

diff --git a/packages/marketplace/src/tests/badges/badge-functions.svg b/packages/marketplace/src/tests/badges/badge-functions.svg index da0ea73599..96fea2e99d 100644 --- a/packages/marketplace/src/tests/badges/badge-functions.svg +++ b/packages/marketplace/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions80.03%80.03% \ No newline at end of file +Coverage:functionsCoverage:functions80.03%80.03% diff --git a/packages/marketplace/src/tests/badges/badge-lines.svg b/packages/marketplace/src/tests/badges/badge-lines.svg index 79f5b44491..c733a3b83b 100644 --- a/packages/marketplace/src/tests/badges/badge-lines.svg +++ b/packages/marketplace/src/tests/badges/badge-lines.svg @@ -1 +1 @@ -Coverage:linesCoverage:lines90.65%90.65% \ No newline at end of file +Coverage:linesCoverage:lines90.65%90.65%