diff --git a/packages/sanity/src/_singletons/context/ReleasesTableContext.ts b/packages/sanity/src/_singletons/context/ReleasesTableContext.ts index 8d35e73535b..64f9023bb61 100644 --- a/packages/sanity/src/_singletons/context/ReleasesTableContext.ts +++ b/packages/sanity/src/_singletons/context/ReleasesTableContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {TableContextValue} from '../../core/releases/components/Table/TableProvider' +import type {TableContextValue} from '../../core/releases/tool/components/Table/TableProvider' /** * @internal diff --git a/packages/sanity/src/core/index.ts b/packages/sanity/src/core/index.ts index d259c09de0e..fc5c99bba0a 100644 --- a/packages/sanity/src/core/index.ts +++ b/packages/sanity/src/core/index.ts @@ -1,12 +1,3 @@ -export { - getDocumentIsInPerspective, - LATEST, - ReleaseActions, - ReleaseBadge, - ReleasesMenu, - useDocumentVersions, - usePerspective, -} from './bundles' export * from './changeIndicators' export { CommentInput, @@ -30,6 +21,15 @@ export * from './hooks' export * from './i18n' export * from './presence' export * from './preview' +export { + getDocumentIsInPerspective, + LATEST, + ReleaseActions, + ReleaseBadge, + ReleasesMenu, + useDocumentVersions, + usePerspective, +} from './releases' export * from './scheduledPublishing' export * from './schema' export type {SearchFactoryOptions, SearchOptions, SearchSort, SearchTerms} from './search' diff --git a/packages/sanity/src/core/bundles/__telemetry__/releases.telemetry.ts b/packages/sanity/src/core/releases/__telemetry__/releases.telemetry.ts similarity index 100% rename from packages/sanity/src/core/bundles/__telemetry__/releases.telemetry.ts rename to packages/sanity/src/core/releases/__telemetry__/releases.telemetry.ts diff --git a/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx b/packages/sanity/src/core/releases/components/ReleaseBadge.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/ReleaseBadge.tsx rename to packages/sanity/src/core/releases/components/ReleaseBadge.tsx diff --git a/packages/sanity/src/core/bundles/components/ReleasesMenu.tsx b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/ReleasesMenu.tsx rename to packages/sanity/src/core/releases/components/ReleasesMenu.tsx diff --git a/packages/sanity/src/core/bundles/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/__tests__/ReleasesMenu.test.tsx rename to packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseDetailsDialog.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseDetailsDialog.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseIconEditorPicker.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseIconEditorPicker.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseForm.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseForm.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseForm.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseForm.test.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx diff --git a/packages/sanity/src/core/bundles/components/index.ts b/packages/sanity/src/core/releases/components/index.ts similarity index 100% rename from packages/sanity/src/core/bundles/components/index.ts rename to packages/sanity/src/core/releases/components/index.ts diff --git a/packages/sanity/src/core/bundles/components/panes/ReleaseActions.tsx b/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/panes/ReleaseActions.tsx rename to packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx diff --git a/packages/sanity/src/core/bundles/hooks/__tests__/useDocumentVersions.test.tsx b/packages/sanity/src/core/releases/hooks/__tests__/useDocumentVersions.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/hooks/__tests__/useDocumentVersions.test.tsx rename to packages/sanity/src/core/releases/hooks/__tests__/useDocumentVersions.test.tsx diff --git a/packages/sanity/src/core/bundles/hooks/index.ts b/packages/sanity/src/core/releases/hooks/index.ts similarity index 100% rename from packages/sanity/src/core/bundles/hooks/index.ts rename to packages/sanity/src/core/releases/hooks/index.ts diff --git a/packages/sanity/src/core/bundles/hooks/useDocumentVersions.tsx b/packages/sanity/src/core/releases/hooks/useDocumentVersions.tsx similarity index 100% rename from packages/sanity/src/core/bundles/hooks/useDocumentVersions.tsx rename to packages/sanity/src/core/releases/hooks/useDocumentVersions.tsx diff --git a/packages/sanity/src/core/bundles/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx similarity index 100% rename from packages/sanity/src/core/bundles/hooks/usePerspective.tsx rename to packages/sanity/src/core/releases/hooks/usePerspective.tsx diff --git a/packages/sanity/src/core/bundles/index.ts b/packages/sanity/src/core/releases/index.ts similarity index 100% rename from packages/sanity/src/core/bundles/index.ts rename to packages/sanity/src/core/releases/index.ts diff --git a/packages/sanity/src/core/releases/components/Chip.tsx b/packages/sanity/src/core/releases/tool/components/Chip.tsx similarity index 100% rename from packages/sanity/src/core/releases/components/Chip.tsx rename to packages/sanity/src/core/releases/tool/components/Chip.tsx diff --git a/packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx similarity index 88% rename from packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index 132b6b25b09..f6502b9c6fa 100644 --- a/packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -5,11 +5,11 @@ import {type ForwardedRef, forwardRef, useMemo} from 'react' import {DocumentPreviewPresence, useDocumentPresence} from 'sanity' import {IntentLink} from 'sanity/router' -import {Tooltip} from '../../../ui-components' -import {useTranslation} from '../../i18n' -import {SanityDefaultPreview} from '../../preview/components/SanityDefaultPreview' -import {getPublishedId} from '../../util/draftUtils' -import {releasesLocaleNamespace} from '../i18n' +import {Tooltip} from '../../../../ui-components' +import {useTranslation} from '../../../i18n' +import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' +import {getPublishedId} from '../../../util/draftUtils' +import {releasesLocaleNamespace} from '../../i18n' interface ReleaseDocumentPreviewProps { documentId: string diff --git a/packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx similarity index 92% rename from packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx index 8b0485c2ff8..64e07dbe256 100644 --- a/packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx @@ -10,17 +10,17 @@ import {Menu, Spinner, Text, useToast} from '@sanity/ui' import {useState} from 'react' import {useRouter} from 'sanity/router' -import {Button, Dialog, MenuButton, MenuItem} from '../../../../ui-components' +import {Button, Dialog, MenuButton, MenuItem} from '../../../../../ui-components' +import {Translate, useTranslation} from '../../../../i18n' +import {type BundleDocument} from '../../../../store/bundles/types' +import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' import { ArchivedRelease, DeletedRelease, UnarchivedRelease, -} from '../../../bundles/__telemetry__/releases.telemetry' -import {ReleaseDetailsDialog} from '../../../bundles/components/dialog/ReleaseDetailsDialog' -import {Translate, useTranslation} from '../../../i18n' -import {type BundleDocument} from '../../../store/bundles/types' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {releasesLocaleNamespace} from '../../i18n' +} from '../../../__telemetry__/releases.telemetry' +import {ReleaseDetailsDialog} from '../../../components/dialog/ReleaseDetailsDialog' +import {releasesLocaleNamespace} from '../../../i18n' export type ReleaseMenuButtonProps = { disabled?: boolean diff --git a/packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx similarity index 93% rename from packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx index 24e715510ad..cf45f419b83 100644 --- a/packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx @@ -3,17 +3,17 @@ import {fireEvent, render, screen} from '@testing-library/react' import {act} from 'react' import {useRouter} from 'sanity/router' -import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {type BundleDocument} from '../../../../store/bundles/types' -import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' -import {releasesUsEnglishLocaleBundle} from '../../../i18n' +import {createTestProvider} from '../../../../../../../test/testUtils/TestProvider' +import {type BundleDocument} from '../../../../../store/bundles/types' +import {useBundleOperations} from '../../../../../store/bundles/useBundleOperations' +import {releasesUsEnglishLocaleBundle} from '../../../../i18n' import {ReleaseMenuButton, type ReleaseMenuButtonProps} from '../ReleaseMenuButton' jest.mock('sanity', () => ({ useTranslation: jest.fn().mockReturnValue({t: jest.fn()}), })) -jest.mock('../../../../store/bundles/useBundleOperations', () => ({ +jest.mock('../../../../../store/bundles/useBundleOperations', () => ({ useBundleOperations: jest.fn().mockReturnValue({ deleteBundle: jest.fn(), updateBundle: jest.fn(), diff --git a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx similarity index 91% rename from packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx rename to packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx index b9f65f16c2f..21eaec5db51 100644 --- a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx @@ -4,12 +4,12 @@ import {Flex, Text, useToast} from '@sanity/ui' import {useCallback, useMemo, useState} from 'react' import {type BundleDocument} from 'sanity' -import {Button, Dialog} from '../../../../ui-components' -import {PublishedRelease} from '../../../bundles/__telemetry__/releases.telemetry' -import {Translate, useTranslation} from '../../../i18n' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {releasesLocaleNamespace} from '../../i18n' -import {type DocumentInBundleResult} from '../../tool/detail/useBundleDocuments' +import {Button, Dialog} from '../../../../../ui-components' +import {Translate, useTranslation} from '../../../../i18n' +import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {PublishedRelease} from '../../../__telemetry__/releases.telemetry' +import {releasesLocaleNamespace} from '../../../i18n' +import {type DocumentInBundleResult} from '../../../tool/detail/useBundleDocuments' import {useObserveDocumentRevisions} from './useObserveDocumentRevisions' interface ReleasePublishAllButtonProps { diff --git a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts similarity index 100% rename from packages/sanity/src/core/releases/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts rename to packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts diff --git a/packages/sanity/src/core/releases/components/Table/Table.tsx b/packages/sanity/src/core/releases/tool/components/Table/Table.tsx similarity index 98% rename from packages/sanity/src/core/releases/components/Table/Table.tsx rename to packages/sanity/src/core/releases/tool/components/Table/Table.tsx index 7478c1a5665..0d65198931d 100644 --- a/packages/sanity/src/core/releases/components/Table/Table.tsx +++ b/packages/sanity/src/core/releases/tool/components/Table/Table.tsx @@ -17,8 +17,8 @@ import { } from 'react' import {styled} from 'styled-components' -import {TooltipDelayGroupProvider} from '../../../../ui-components' -import {LoadingBlock} from '../../../components' +import {TooltipDelayGroupProvider} from '../../../../../ui-components' +import {LoadingBlock} from '../../../../components' import {TableHeader} from './TableHeader' import {TableProvider, type TableSort, useTableContext} from './TableProvider' import {type Column} from './types' diff --git a/packages/sanity/src/core/releases/components/Table/TableHeader.tsx b/packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx similarity index 96% rename from packages/sanity/src/core/releases/components/Table/TableHeader.tsx rename to packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx index 620eebfa2ad..ef73a358fec 100644 --- a/packages/sanity/src/core/releases/components/Table/TableHeader.tsx +++ b/packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx @@ -1,7 +1,7 @@ import {ArrowDownIcon, ArrowUpIcon, SearchIcon} from '@sanity/icons' import {Card, Flex, Stack, TextInput} from '@sanity/ui' -import {Button, type ButtonProps} from '../../../../ui-components' +import {Button, type ButtonProps} from '../../../../../ui-components' import {useTableContext} from './TableProvider' import {type HeaderProps, type TableHeaderProps} from './types' diff --git a/packages/sanity/src/core/releases/components/Table/TableProvider.tsx b/packages/sanity/src/core/releases/tool/components/Table/TableProvider.tsx similarity index 100% rename from packages/sanity/src/core/releases/components/Table/TableProvider.tsx rename to packages/sanity/src/core/releases/tool/components/Table/TableProvider.tsx diff --git a/packages/sanity/src/core/releases/components/Table/types.ts b/packages/sanity/src/core/releases/tool/components/Table/types.ts similarity index 100% rename from packages/sanity/src/core/releases/components/Table/types.ts rename to packages/sanity/src/core/releases/tool/components/Table/types.ts diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx index 768e01585ad..64568bcebdb 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx @@ -7,10 +7,10 @@ import {type RouterContextValue, useRouter} from 'sanity/router' import {Button} from '../../../../ui-components' import {Translate, useTranslation} from '../../../i18n' import {useBundles} from '../../../store/bundles' -import {ReleaseMenuButton} from '../../components/ReleaseMenuButton/ReleaseMenuButton' -import {ReleasePublishAllButton} from '../../components/ReleasePublishAllButton/ReleasePublishAllButton' import {releasesLocaleNamespace} from '../../i18n' import {type ReleasesRouterState} from '../../types/router' +import {ReleaseMenuButton} from '../components/ReleaseMenuButton/ReleaseMenuButton' +import {ReleasePublishAllButton} from '../components/ReleasePublishAllButton/ReleasePublishAllButton' import {useReleaseHistory} from './documentTable/useReleaseHistory' import {ReleaseReview} from './ReleaseReview' import {ReleaseSummary} from './ReleaseSummary' diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index fc85fb86b81..06ededa46ee 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -2,18 +2,18 @@ import {DocumentsIcon} from '@sanity/icons' import {AvatarStack, Box, Flex, Heading, Stack, Text, useToast} from '@sanity/ui' import {type RefObject, useCallback, useEffect, useMemo, useState} from 'react' -import { - ReleaseIconEditorPicker, - type ReleaseIconEditorPickerValue, -} from '../../../bundles/components/dialog/ReleaseIconEditorPicker' import {RelativeTime} from '../../../components/RelativeTime' import {UserAvatar} from '../../../components/userAvatar/UserAvatar' import {Translate, useTranslation} from '../../../i18n' import {type BundleDocument} from '../../../store/bundles/types' import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {Chip} from '../../components/Chip' -import {Table, type TableProps} from '../../components/Table/Table' +import { + ReleaseIconEditorPicker, + type ReleaseIconEditorPickerValue, +} from '../../components/dialog/ReleaseIconEditorPicker' import {releasesLocaleNamespace} from '../../i18n' +import {Chip} from '../components/Chip' +import {Table, type TableProps} from '../components/Table/Table' import {DocumentActions} from './documentTable/DocumentActions' import {getDocumentTableColumnDefs} from './documentTable/DocumentTableColumnDefs' import {type DocumentHistory} from './documentTable/useReleaseHistory' diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx index 55a36a852a2..380eccd5e1d 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx @@ -32,7 +32,7 @@ jest.mock('sanity', () => ({ useTranslation: jest.fn().mockReturnValue({t: jest.fn()}), })) -jest.mock('../../../components/ReleasePublishAllButton/useObserveDocumentRevisions', () => ({ +jest.mock('../../components/ReleasePublishAllButton/useObserveDocumentRevisions', () => ({ useObserveDocumentRevisions: jest.fn().mockReturnValue({ '123': 'mock revision id', }), diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index 4d9226ff358..9d9bba3b76e 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -1,7 +1,7 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' import {act, fireEvent, render, screen, within} from '@testing-library/react' import {type ReactNode} from 'react' -import {ColorSchemeProvider, UserColorManagerProvider} from 'sanity' +import {ColorSchemeProvider, type DefaultPreview, UserColorManagerProvider} from 'sanity' import {queryByDataUi} from '../../../../../../test/setup/customQueries' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' @@ -131,7 +131,7 @@ jest.mock('sanity/router', () => ({ }), })) -jest.mock('../../../../bundles/components/ReleasesMenu', () => ({ +jest.mock('../../../components/ReleasesMenu', () => ({ ReleasesMenu: () =>
ReleasesMenu
, })) @@ -141,6 +141,17 @@ jest.mock('../../../../preview/useObserveDocument', () => { } }) +jest.mock('../../../../components', () => { + const {DefaultPreview: actualDefaultPreview} = jest.requireActual( + '../../../../components/previews/general/DefaultPreview', + ) as {DefaultPreview: typeof DefaultPreview} + + return { + ...(jest.requireActual('../../../../components') || {}), + DefaultPreview: actualDefaultPreview, + } +}) + const mockedUseObserveDocument = useObserveDocument as jest.Mock async function createReleaseReviewWrapper() { diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 4d16bf0136c..ac065f40193 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -1,6 +1,6 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' import {fireEvent, render, screen, within} from '@testing-library/react' -import {type BundleDocument, defineType} from 'sanity' +import {type BundleDocument, type DefaultPreview, defineType} from 'sanity' import {route, RouterProvider} from 'sanity/router' import {getAllByDataUi, getByDataUi} from '../../../../../../test/setup/customQueries' @@ -23,10 +23,21 @@ jest.mock('../../../../user-color', () => ({ useUserColor: jest.fn().mockReturnValue('red'), })) -jest.mock('../../../../bundles/components/ReleasesMenu', () => ({ +jest.mock('../../../components/ReleasesMenu', () => ({ ReleasesMenu: () =>
ReleasesMenu
, })) +jest.mock('../../../../components', () => { + const {DefaultPreview: actualDefaultPreview} = jest.requireActual( + '../../../../components/previews/general/DefaultPreview', + ) as {DefaultPreview: typeof DefaultPreview} + + return { + ...(jest.requireActual('../../../../components') || {}), + DefaultPreview: actualDefaultPreview, + } +}) + const timeNow = new Date() const releaseDocuments: DocumentInBundleResult[] = [ @@ -56,7 +67,7 @@ const releaseDocuments: DocumentInBundleResult[] = [ }, }, { - memoKey: 'key123', + memoKey: 'key456', document: { _id: '456', _type: 'document', diff --git a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx index 94f3c5c60cb..6b0abd90b73 100644 --- a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx @@ -3,9 +3,9 @@ import {memo} from 'react' import {type TFunction, UserAvatar} from 'sanity' import {RelativeTime} from '../../../../components/RelativeTime' -import {ReleaseDocumentPreview} from '../../../components/ReleaseDocumentPreview' -import {Headers} from '../../../components/Table/TableHeader' -import {type Column} from '../../../components/Table/types' +import {ReleaseDocumentPreview} from '../../components/ReleaseDocumentPreview' +import {Headers} from '../../components/Table/TableHeader' +import {type Column} from '../../components/Table/types' import {type BundleDocumentRow} from '../ReleaseSummary' import {type DocumentInBundleResult} from '../useBundleDocuments' diff --git a/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx b/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx index 2dd171ee6b6..3b33e4b7342 100644 --- a/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx +++ b/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx @@ -6,9 +6,9 @@ import {Translate, useTranslation} from 'sanity' import {Button} from '../../../../../ui-components' import {RelativeTime} from '../../../../components/RelativeTime' import {UserAvatar} from '../../../../components/userAvatar/UserAvatar' -import {Chip} from '../../../components/Chip' -import {ReleaseDocumentPreview} from '../../../components/ReleaseDocumentPreview' import {releasesLocaleNamespace} from '../../../i18n' +import {Chip} from '../../components/Chip' +import {ReleaseDocumentPreview} from '../../components/ReleaseDocumentPreview' import {type DocumentValidationStatus} from '../useBundleDocuments' export function DocumentReviewHeader({ diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx index 98233ae6bd2..cccb44ba505 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx @@ -4,14 +4,14 @@ import {isBefore} from 'date-fns' import {type MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState} from 'react' import {Button, Button as StudioButton} from '../../../../ui-components' -import {ReleaseDetailsDialog} from '../../../bundles/components/dialog/ReleaseDetailsDialog' import {useTranslation} from '../../../i18n' import {type BundleDocument, useBundles} from '../../../store' -import {ReleaseMenuButton} from '../../components/ReleaseMenuButton/ReleaseMenuButton' -import {Table, type TableProps} from '../../components/Table/Table' -import {type TableSort} from '../../components/Table/TableProvider' +import {ReleaseDetailsDialog} from '../../components/dialog/ReleaseDetailsDialog' import {releasesLocaleNamespace} from '../../i18n' import {containsBundles} from '../../types/bundle' +import {ReleaseMenuButton} from '../components/ReleaseMenuButton/ReleaseMenuButton' +import {Table, type TableProps} from '../components/Table/Table' +import {type TableSort} from '../components/Table/TableProvider' import {type BundlesMetadata, useBundlesMetadata} from '../useBundlesMetadata' import {releasesOverviewColumnDefs} from './ReleasesOverviewColumnDefs' diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx index 9bf6263c364..d55c81e087e 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx @@ -3,12 +3,12 @@ import {type TFunction, Translate, useTranslation} from 'sanity' import {useRouter} from 'sanity/router' import {Tooltip} from '../../../../ui-components' -import {ReleaseBadge} from '../../../bundles' import {RelativeTime, UserAvatar} from '../../../components' -import {type TableRowProps} from '../../components/Table/Table' -import {Headers} from '../../components/Table/TableHeader' -import {type Column} from '../../components/Table/types' +import {ReleaseBadge} from '../../components/ReleaseBadge' import {releasesLocaleNamespace} from '../../i18n' +import {type TableRowProps} from '../components/Table/Table' +import {Headers} from '../components/Table/TableHeader' +import {type Column} from '../components/Table/types' import {type TableBundle} from './ReleasesOverview' const ReleaseNameCell: Column['cell'] = ({cellProps, datum: bundle}) => { diff --git a/packages/sanity/src/core/bundles/util/const.ts b/packages/sanity/src/core/releases/util/const.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/const.ts rename to packages/sanity/src/core/releases/util/const.ts diff --git a/packages/sanity/src/core/bundles/util/createReleaseId.ts b/packages/sanity/src/core/releases/util/createReleaseId.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/createReleaseId.ts rename to packages/sanity/src/core/releases/util/createReleaseId.ts diff --git a/packages/sanity/src/core/bundles/util/util.test.ts b/packages/sanity/src/core/releases/util/util.test.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/util.test.ts rename to packages/sanity/src/core/releases/util/util.test.ts diff --git a/packages/sanity/src/core/bundles/util/util.ts b/packages/sanity/src/core/releases/util/util.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/util.ts rename to packages/sanity/src/core/releases/util/util.ts diff --git a/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx b/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx index 3fb7550c32e..a3225ae2311 100644 --- a/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx +++ b/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx @@ -5,10 +5,10 @@ import {useCallback, useMemo, useState} from 'react' import {useTranslation} from 'sanity' import {MenuItem} from '../../../../../ui-components' -import {ReleaseDetailsDialog} from '../../../../bundles/components/dialog/ReleaseDetailsDialog' -import {ReleaseBadge} from '../../../../bundles/components/ReleaseBadge' -import {ReleasesMenu} from '../../../../bundles/components/ReleasesMenu' -import {usePerspective} from '../../../../bundles/hooks/usePerspective' +import {ReleaseDetailsDialog} from '../../../../releases/components/dialog/ReleaseDetailsDialog' +import {ReleaseBadge} from '../../../../releases/components/ReleaseBadge' +import {ReleasesMenu} from '../../../../releases/components/ReleasesMenu' +import {usePerspective} from '../../../../releases/hooks/usePerspective' import {useBundles} from '../../../../store/bundles' export function GlobalPerspectiveMenu(): JSX.Element { diff --git a/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx index eca864cccdc..6397f3622a2 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx @@ -11,7 +11,7 @@ jest.mock('../../../useDocumentPane', () => ({ useDocumentPane: jest.fn(), })) -jest.mock('../../../../../../core/bundles/hooks/usePerspective', () => ({ +jest.mock('../../../../../../core/releases/hooks/usePerspective', () => ({ usePerspective: jest.fn(), })) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx similarity index 91% rename from packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx rename to packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx index adaa472e521..6ae083755b0 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx @@ -9,12 +9,12 @@ import { } from 'sanity' import {useRouter} from 'sanity/router' -import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient' -import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {structureUsEnglishLocaleBundle} from '../../../../i18n' -import {type DocumentPaneContextValue} from '../../DocumentPaneContext' -import {useDocumentPane} from '../../useDocumentPane' -import {DocumentHeaderTitle} from './DocumentHeaderTitle' +import {createMockSanityClient} from '../../../../../../../../test/mocks/mockSanityClient' +import {createTestProvider} from '../../../../../../../../test/testUtils/TestProvider' +import {structureUsEnglishLocaleBundle} from '../../../../../../i18n' +import {type DocumentPaneContextValue} from '../../../../DocumentPaneContext' +import {useDocumentPane} from '../../../../useDocumentPane' +import {DocumentHeaderTitle} from '../../DocumentHeaderTitle' function createWrapperComponent(client: SanityClient) { const config = defineConfig({ @@ -29,7 +29,7 @@ function createWrapperComponent(client: SanityClient) { }) } -jest.mock('../../useDocumentPane') +jest.mock('../../../../useDocumentPane') jest.mock('sanity', () => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -43,7 +43,7 @@ jest.mock('sanity', () => { jest.mock('sanity/router') -jest.mock('../../../../../core/store/bundles/useBundles', () => ({ +jest.mock('../../../../../../../core/store/bundles/useBundles', () => ({ useBundles: jest.fn(), }))