@sanity/cli 6.0.0-alpha.5 → 6.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2907 -109
- package/dist/actions/dataset/create.d.ts +49 -0
- package/dist/actions/dataset/create.js +48 -0
- package/dist/actions/dataset/create.js.map +1 -0
- package/dist/actions/dataset/determineDatasetAclMode.d.ts +37 -0
- package/dist/actions/dataset/determineDatasetAclMode.js +36 -0
- package/dist/actions/dataset/determineDatasetAclMode.js.map +1 -0
- package/dist/actions/debug/gatherDebugInfo.js +15 -21
- package/dist/actions/debug/gatherDebugInfo.js.map +1 -1
- package/dist/actions/debug/types.d.ts +0 -2
- package/dist/actions/debug/types.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +13 -0
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/init/remoteTemplate.js +1 -1
- package/dist/actions/init/remoteTemplate.js.map +1 -1
- package/dist/actions/manifest/extractAppManifest.d.ts +20 -0
- package/dist/actions/manifest/extractAppManifest.js +51 -0
- package/dist/actions/manifest/extractAppManifest.js.map +1 -0
- package/dist/actions/manifest/extractManifest.js +1 -1
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/manifest/types.d.ts +6 -1
- package/dist/actions/manifest/types.js.map +1 -1
- package/dist/actions/media/importAspects.js +2 -1
- package/dist/actions/media/importAspects.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +1 -1
- package/dist/actions/telemetry/resolveConsent.d.ts +1 -9
- package/dist/actions/telemetry/resolveConsent.js +2 -2
- package/dist/actions/telemetry/resolveConsent.js.map +1 -1
- package/dist/actions/telemetry/setConsent.d.ts +1 -4
- package/dist/actions/telemetry/setConsent.js +4 -8
- package/dist/actions/telemetry/setConsent.js.map +1 -1
- package/dist/commands/dataset/create.d.ts +0 -2
- package/dist/commands/dataset/create.js +8 -54
- package/dist/commands/dataset/create.js.map +1 -1
- package/dist/commands/debug.js +5 -9
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.js +358 -20
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/manifest/extract.js +7 -8
- package/dist/commands/manifest/extract.js.map +1 -1
- package/dist/commands/telemetry/disable.js +0 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js +0 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js +1 -3
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/config/createCliConfig.d.ts +9 -0
- package/dist/hooks/prerun/flushTelemetry.worker.d.ts +2 -0
- package/dist/hooks/prerun/flushTelemetry.worker.js +22 -0
- package/dist/hooks/prerun/flushTelemetry.worker.js.map +1 -0
- package/dist/hooks/prerun/setupTelemetry.js +65 -1
- package/dist/hooks/prerun/setupTelemetry.js.map +1 -1
- package/dist/prompts/init/promptForTypescript.d.ts +2 -0
- package/dist/prompts/init/promptForTypescript.js +15 -0
- package/dist/prompts/init/promptForTypescript.js.map +1 -0
- package/dist/prompts/promptForDatasetAclMode.d.ts +9 -0
- package/dist/prompts/promptForDatasetAclMode.js +27 -0
- package/dist/prompts/promptForDatasetAclMode.js.map +1 -0
- package/dist/prompts/promptForDatasetName.d.ts +1 -1
- package/dist/prompts/promptForDatasetName.js +4 -1
- package/dist/prompts/promptForDatasetName.js.map +1 -1
- package/dist/services/organizations.d.ts +3 -1
- package/dist/services/organizations.js +2 -1
- package/dist/services/organizations.js.map +1 -1
- package/dist/services/telemetry.d.ts +2 -0
- package/dist/services/telemetry.js +20 -0
- package/dist/services/telemetry.js.map +1 -0
- package/dist/services/user.d.ts +5 -0
- package/dist/services/user.js +12 -1
- package/dist/services/user.js.map +1 -1
- package/dist/services/userApplications.d.ts +3 -1
- package/dist/services/userApplications.js +5 -1
- package/dist/services/userApplications.js.map +1 -1
- package/dist/telemetry/cli.telemetry.d.ts +20 -0
- package/dist/telemetry/cli.telemetry.js +8 -0
- package/dist/telemetry/cli.telemetry.js.map +1 -0
- package/dist/telemetry/store/cleanupOldTelemetryFiles.d.ts +5 -0
- package/dist/telemetry/store/cleanupOldTelemetryFiles.js +30 -0
- package/dist/telemetry/store/cleanupOldTelemetryFiles.js.map +1 -0
- package/dist/telemetry/store/createTelemetryStore.d.ts +39 -0
- package/dist/telemetry/store/createTelemetryStore.js +95 -0
- package/dist/telemetry/store/createTelemetryStore.js.map +1 -0
- package/dist/telemetry/store/createTraceId.d.ts +10 -0
- package/dist/telemetry/store/createTraceId.js +10 -0
- package/dist/telemetry/store/createTraceId.js.map +1 -0
- package/dist/telemetry/store/debug.d.ts +5 -0
- package/dist/telemetry/store/debug.js +7 -0
- package/dist/telemetry/store/debug.js.map +1 -0
- package/dist/telemetry/store/findTelemetryFiles.d.ts +13 -0
- package/dist/telemetry/store/findTelemetryFiles.js +34 -0
- package/dist/telemetry/store/findTelemetryFiles.js.map +1 -0
- package/dist/telemetry/store/flushTelemetryFiles.d.ts +20 -0
- package/dist/telemetry/store/flushTelemetryFiles.js +107 -0
- package/dist/telemetry/store/flushTelemetryFiles.js.map +1 -0
- package/dist/telemetry/store/generateTelemetryFilePath.d.ts +17 -0
- package/dist/telemetry/store/generateTelemetryFilePath.js +30 -0
- package/dist/telemetry/store/generateTelemetryFilePath.js.map +1 -0
- package/dist/telemetry/store/getTelemetryBaseInfo.d.ts +27 -0
- package/dist/telemetry/store/getTelemetryBaseInfo.js +34 -0
- package/dist/telemetry/store/getTelemetryBaseInfo.js.map +1 -0
- package/dist/telemetry/store/logger.d.ts +6 -0
- package/dist/telemetry/store/logger.js +54 -0
- package/dist/telemetry/store/logger.js.map +1 -0
- package/dist/telemetry/store/trace.d.ts +6 -0
- package/dist/telemetry/store/trace.js +150 -0
- package/dist/telemetry/store/trace.js.map +1 -0
- package/dist/telemetry/utils/readNDJSON.d.ts +10 -0
- package/dist/telemetry/utils/readNDJSON.js +18 -0
- package/dist/telemetry/utils/readNDJSON.js.map +1 -0
- package/dist/util/detectRuntime.d.ts +8 -0
- package/dist/util/detectRuntime.js +20 -0
- package/dist/util/detectRuntime.js.map +1 -0
- package/dist/util/isStaging.d.ts +7 -0
- package/dist/util/isStaging.js +10 -0
- package/dist/util/isStaging.js.map +1 -0
- package/dist/util/parseArguments.d.ts +35 -0
- package/dist/util/parseArguments.js +42 -0
- package/dist/util/parseArguments.js.map +1 -0
- package/oclif.manifest.json +7 -1
- package/package.json +25 -18
- package/templates/app-quickstart/src/App.css +20 -0
- package/templates/app-quickstart/src/App.tsx +25 -0
- package/templates/app-quickstart/src/ExampleComponent.css +90 -0
- package/templates/app-quickstart/src/ExampleComponent.tsx +37 -0
- package/templates/app-sanity-ui/src/App.tsx +34 -0
- package/templates/app-sanity-ui/src/ExampleComponent.tsx +34 -0
- package/templates/app-sanity-ui/src/SanityUI.tsx +23 -0
- package/templates/blog/README.md +11 -0
- package/templates/blog/schemaTypes/author.js +50 -0
- package/templates/blog/schemaTypes/blockContent.js +67 -0
- package/templates/blog/schemaTypes/category.js +19 -0
- package/templates/blog/schemaTypes/index.js +6 -0
- package/templates/blog/schemaTypes/post.js +65 -0
- package/templates/blog/static/.gitkeep +1 -0
- package/templates/clean/README.md +9 -0
- package/templates/clean/schemaTypes/index.js +1 -0
- package/templates/clean/static/.gitkeep +1 -0
- package/templates/ecommerce/README.md +11 -0
- package/templates/ecommerce/plugins/.gitkeep +1 -0
- package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +62 -0
- package/templates/ecommerce/plugins/barcode-input/index.js +9 -0
- package/templates/ecommerce/plugins/barcode-input/schemaType.js +60 -0
- package/templates/ecommerce/schemaTypes/blockContent.js +67 -0
- package/templates/ecommerce/schemaTypes/category.js +39 -0
- package/templates/ecommerce/schemaTypes/index.js +23 -0
- package/templates/ecommerce/schemaTypes/locale/localeBlockContent.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/localeString.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/localeText.js +19 -0
- package/templates/ecommerce/schemaTypes/locale/supportedLanguages.js +5 -0
- package/templates/ecommerce/schemaTypes/product.js +83 -0
- package/templates/ecommerce/schemaTypes/productVariant.js +52 -0
- package/templates/ecommerce/schemaTypes/vendor.js +39 -0
- package/templates/ecommerce/static/.gitkeep +1 -0
- package/templates/get-started/README.md +9 -0
- package/templates/get-started/plugins/.gitkeep +1 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/CustomDefaultLayout.tsx +16 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +104 -0
- package/templates/get-started/plugins/sanity-plugin-tutorial/index.ts +11 -0
- package/templates/get-started/schemaTypes/index.ts +1 -0
- package/templates/get-started/static/.gitkeep +1 -0
- package/templates/moviedb/README.md +10 -0
- package/templates/moviedb/schemaTypes/blockContent.js +67 -0
- package/templates/moviedb/schemaTypes/castMember.js +37 -0
- package/templates/moviedb/schemaTypes/crewMember.js +52 -0
- package/templates/moviedb/schemaTypes/index.js +22 -0
- package/templates/moviedb/schemaTypes/movie.js +85 -0
- package/templates/moviedb/schemaTypes/person.js +37 -0
- package/templates/moviedb/schemaTypes/plotSummaries.js +20 -0
- package/templates/moviedb/schemaTypes/plotSummary.js +24 -0
- package/templates/moviedb/schemaTypes/screening.js +81 -0
- package/templates/moviedb/static/.gitkeep +1 -0
- package/templates/quickstart/README.md +9 -0
- package/templates/quickstart/schemaTypes/index.js +1 -0
- package/templates/quickstart/static/.gitkeep +1 -0
- package/templates/shared/gitignore.txt +29 -0
- package/templates/shared/tsconfig.json +17 -0
- package/templates/shopify/README.md +85 -0
- package/templates/shopify/components/hotspots/ProductTooltip.tsx +38 -0
- package/templates/shopify/components/icons/Shopify.tsx +20 -0
- package/templates/shopify/components/inputs/CollectionHidden.tsx +23 -0
- package/templates/shopify/components/inputs/PlaceholderString.tsx +20 -0
- package/templates/shopify/components/inputs/ProductHidden.tsx +64 -0
- package/templates/shopify/components/inputs/ProductVariantHidden.tsx +24 -0
- package/templates/shopify/components/inputs/ProxyString.tsx +32 -0
- package/templates/shopify/components/media/ColorTheme.tsx +38 -0
- package/templates/shopify/components/media/ShopifyDocumentStatus.tsx +82 -0
- package/templates/shopify/components/studio/Navbar.tsx +29 -0
- package/templates/shopify/constants.ts +61 -0
- package/templates/shopify/docs/features.md +158 -0
- package/templates/shopify/plugins/customDocumentActions/index.ts +55 -0
- package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +144 -0
- package/templates/shopify/plugins/customDocumentActions/shopifyLink.ts +39 -0
- package/templates/shopify/plugins/customDocumentActions/types.ts +14 -0
- package/templates/shopify/schemaTypes/documents/collection.tsx +142 -0
- package/templates/shopify/schemaTypes/documents/colorTheme.tsx +44 -0
- package/templates/shopify/schemaTypes/documents/page.ts +70 -0
- package/templates/shopify/schemaTypes/documents/product.tsx +132 -0
- package/templates/shopify/schemaTypes/documents/productVariant.tsx +67 -0
- package/templates/shopify/schemaTypes/index.ts +108 -0
- package/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts +27 -0
- package/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts +16 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx +48 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx +50 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts +40 -0
- package/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts +49 -0
- package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
- package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
- package/templates/shopify/schemaTypes/objects/global/menuType.ts +17 -0
- package/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts +37 -0
- package/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts +48 -0
- package/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx +17 -0
- package/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx +60 -0
- package/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx +34 -0
- package/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx +37 -0
- package/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx +33 -0
- package/templates/shopify/schemaTypes/objects/link/linkProductType.tsx +60 -0
- package/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts +33 -0
- package/templates/shopify/schemaTypes/objects/module/accordionType.ts +28 -0
- package/templates/shopify/schemaTypes/objects/module/callToActionType.tsx +85 -0
- package/templates/shopify/schemaTypes/objects/module/calloutType.ts +38 -0
- package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +47 -0
- package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
- package/templates/shopify/schemaTypes/objects/module/gridType.ts +28 -0
- package/templates/shopify/schemaTypes/objects/module/heroType.tsx +40 -0
- package/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx +19 -0
- package/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts +80 -0
- package/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx +51 -0
- package/templates/shopify/schemaTypes/objects/module/instagramType.ts +35 -0
- package/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx +50 -0
- package/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx +42 -0
- package/templates/shopify/schemaTypes/objects/seoType.ts +31 -0
- package/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx +37 -0
- package/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts +25 -0
- package/templates/shopify/schemaTypes/objects/shopify/optionType.tsx +31 -0
- package/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts +11 -0
- package/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts +20 -0
- package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +142 -0
- package/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts +12 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopType.ts +15 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts +84 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts +131 -0
- package/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts +121 -0
- package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
- package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
- package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
- package/templates/shopify/schemaTypes/singletons/settingsType.ts +96 -0
- package/templates/shopify/static/.gitkeep +1 -0
- package/templates/shopify/structure/collectionStructure.ts +9 -0
- package/templates/shopify/structure/colorThemeStructure.ts +9 -0
- package/templates/shopify/structure/homeStructure.ts +9 -0
- package/templates/shopify/structure/index.ts +57 -0
- package/templates/shopify/structure/pageStructure.ts +11 -0
- package/templates/shopify/structure/productStructure.ts +51 -0
- package/templates/shopify/structure/settingStructure.ts +9 -0
- package/templates/shopify/utils/blocksToText.ts +20 -0
- package/templates/shopify/utils/defineStructure.ts +11 -0
- package/templates/shopify/utils/getPriceRange.ts +24 -0
- package/templates/shopify/utils/shopifyUrls.ts +22 -0
- package/templates/shopify/utils/validateSlug.ts +18 -0
- package/templates/shopify-online-storefront/README.md +54 -0
- package/templates/shopify-online-storefront/components/icons/Shopify.tsx +22 -0
- package/templates/shopify-online-storefront/components/inputs/CollectionHidden.tsx +23 -0
- package/templates/shopify-online-storefront/components/inputs/PlaceholderString.tsx +25 -0
- package/templates/shopify-online-storefront/components/inputs/ProductHidden.tsx +66 -0
- package/templates/shopify-online-storefront/components/inputs/ProductVariantHidden.tsx +25 -0
- package/templates/shopify-online-storefront/components/inputs/ProxyString.tsx +38 -0
- package/templates/shopify-online-storefront/components/media/ShopifyDocumentStatus.tsx +83 -0
- package/templates/shopify-online-storefront/constants.ts +18 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/index.ts +45 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +144 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyLink.ts +39 -0
- package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/types.ts +14 -0
- package/templates/shopify-online-storefront/schemaTypes/blocks/blockContent.ts +32 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/collection.tsx +83 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/product.tsx +102 -0
- package/templates/shopify-online-storefront/schemaTypes/documents/productVariant.tsx +82 -0
- package/templates/shopify-online-storefront/schemaTypes/index.ts +43 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/accordion.ts +31 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/accordionGroup.ts +35 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/callout.ts +40 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/inventory.ts +30 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/option.ts +30 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/priceRange.ts +22 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/proxyString.ts +11 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollection.ts +109 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollectionRule.tsx +45 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProduct.ts +165 -0
- package/templates/shopify-online-storefront/schemaTypes/objects/shopifyProductVariant.ts +151 -0
- package/templates/shopify-online-storefront/structure/collectionStructure.ts +9 -0
- package/templates/shopify-online-storefront/structure/index.ts +37 -0
- package/templates/shopify-online-storefront/structure/productStructure.ts +35 -0
- package/templates/shopify-online-storefront/utils/defineStructure.ts +11 -0
- package/templates/shopify-online-storefront/utils/getPriceRange.ts +24 -0
- package/templates/shopify-online-storefront/utils/shopifyUrls.ts +22 -0
- package/dist/actions/build/__tests__/buildApp.test.js +0 -367
- package/dist/actions/build/__tests__/buildApp.test.js.map +0 -1
- package/dist/actions/build/__tests__/buildStudio.test.js +0 -561
- package/dist/actions/build/__tests__/buildStudio.test.js.map +0 -1
- package/dist/actions/build/__tests__/checkRequiredDependencies.test.js +0 -233
- package/dist/actions/build/__tests__/checkRequiredDependencies.test.js.map +0 -1
- package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js +0 -414
- package/dist/actions/build/__tests__/checkStudioDependencyVersions.test.js.map +0 -1
- package/dist/actions/build/__tests__/determineBasePath.test.js +0 -24
- package/dist/actions/build/__tests__/determineBasePath.test.js.map +0 -1
- package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js +0 -109
- package/dist/actions/build/__tests__/getAutoUpdatesImportMap.test.js.map +0 -1
- package/dist/actions/build/__tests__/getViteConfig.test.js +0 -493
- package/dist/actions/build/__tests__/getViteConfig.test.js.map +0 -1
- package/dist/actions/build/__tests__/renderDocument.test.js +0 -278
- package/dist/actions/build/__tests__/renderDocument.test.js.map +0 -1
- package/dist/actions/build/__tests__/shouldAutoUpdate.test.js +0 -153
- package/dist/actions/build/__tests__/shouldAutoUpdate.test.js.map +0 -1
- package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js +0 -657
- package/dist/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.js.map +0 -1
- package/dist/actions/dataset/__tests__/validateDatasetName.test.js +0 -182
- package/dist/actions/dataset/__tests__/validateDatasetName.test.js.map +0 -1
- package/dist/actions/deploy/__tests__/checkDir.test.js +0 -120
- package/dist/actions/deploy/__tests__/checkDir.test.js.map +0 -1
- package/dist/actions/docs/__tests__/normalizeDocsPath.test.js +0 -16
- package/dist/actions/docs/__tests__/normalizeDocsPath.test.js.map +0 -1
- package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js +0 -124
- package/dist/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.js.map +0 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +0 -274
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +0 -1
- package/dist/actions/media/__tests__/importMedia.test.js +0 -182
- package/dist/actions/media/__tests__/importMedia.test.js.map +0 -1
- package/dist/actions/schema/__tests__/formatSchemaValidation.test.js +0 -174
- package/dist/actions/schema/__tests__/formatSchemaValidation.test.js.map +0 -1
- package/dist/actions/schema/__tests__/validateAction.test.js +0 -281
- package/dist/actions/schema/__tests__/validateAction.test.js.map +0 -1
- package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js +0 -27
- package/dist/actions/telemetry/__tests__/fetchTelemetryConsent.test.js.map +0 -1
- package/dist/actions/users/__tests__/validateEmail.test.js +0 -16
- package/dist/actions/users/__tests__/validateEmail.test.js.map +0 -1
- package/dist/commands/__tests__/blueprints.test.js +0 -54
- package/dist/commands/__tests__/blueprints.test.js.map +0 -1
- package/dist/commands/__tests__/build.test.js +0 -132
- package/dist/commands/__tests__/build.test.js.map +0 -1
- package/dist/commands/__tests__/codemod.test.js +0 -271
- package/dist/commands/__tests__/codemod.test.js.map +0 -1
- package/dist/commands/__tests__/debug.test.js +0 -590
- package/dist/commands/__tests__/debug.test.js.map +0 -1
- package/dist/commands/__tests__/deploy.test.js +0 -1945
- package/dist/commands/__tests__/deploy.test.js.map +0 -1
- package/dist/commands/__tests__/dev.test.js +0 -453
- package/dist/commands/__tests__/dev.test.js.map +0 -1
- package/dist/commands/__tests__/exec.test.js +0 -207
- package/dist/commands/__tests__/exec.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.authentication.test.js +0 -73
- package/dist/commands/__tests__/init/init.authentication.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.create-new-project.test.js +0 -195
- package/dist/commands/__tests__/init/init.create-new-project.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.plan.test.js +0 -279
- package/dist/commands/__tests__/init/init.plan.test.js.map +0 -1
- package/dist/commands/__tests__/init/init.setup.test.js +0 -335
- package/dist/commands/__tests__/init/init.setup.test.js.map +0 -1
- package/dist/commands/__tests__/install.test.js +0 -282
- package/dist/commands/__tests__/install.test.js.map +0 -1
- package/dist/commands/__tests__/learn.test.js +0 -29
- package/dist/commands/__tests__/learn.test.js.map +0 -1
- package/dist/commands/__tests__/logout.test.js +0 -91
- package/dist/commands/__tests__/logout.test.js.map +0 -1
- package/dist/commands/__tests__/manage.test.js +0 -110
- package/dist/commands/__tests__/manage.test.js.map +0 -1
- package/dist/commands/__tests__/migration.test.js +0 -119
- package/dist/commands/__tests__/migration.test.js.map +0 -1
- package/dist/commands/__tests__/preview.test.js +0 -261
- package/dist/commands/__tests__/preview.test.js.map +0 -1
- package/dist/commands/__tests__/start.test.js +0 -253
- package/dist/commands/__tests__/start.test.js.map +0 -1
- package/dist/commands/__tests__/undeploy.test.js +0 -382
- package/dist/commands/__tests__/undeploy.test.js.map +0 -1
- package/dist/commands/__tests__/versions.test.js +0 -142
- package/dist/commands/__tests__/versions.test.js.map +0 -1
- package/dist/commands/backup/__tests__/disable.test.js +0 -204
- package/dist/commands/backup/__tests__/disable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/download.test.js +0 -768
- package/dist/commands/backup/__tests__/download.test.js.map +0 -1
- package/dist/commands/backup/__tests__/enable.test.js +0 -286
- package/dist/commands/backup/__tests__/enable.test.js.map +0 -1
- package/dist/commands/backup/__tests__/list.test.js +0 -330
- package/dist/commands/backup/__tests__/list.test.js.map +0 -1
- package/dist/commands/cors/__tests__/add.test.js +0 -376
- package/dist/commands/cors/__tests__/add.test.js.map +0 -1
- package/dist/commands/cors/__tests__/delete.test.js +0 -308
- package/dist/commands/cors/__tests__/delete.test.js.map +0 -1
- package/dist/commands/cors/__tests__/list.test.js +0 -241
- package/dist/commands/cors/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/copy.test.js +0 -628
- package/dist/commands/dataset/__tests__/copy.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/create.test.js +0 -342
- package/dist/commands/dataset/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/delete.test.js +0 -231
- package/dist/commands/dataset/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/export.test.js +0 -601
- package/dist/commands/dataset/__tests__/export.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/import.test.js +0 -53
- package/dist/commands/dataset/__tests__/import.test.js.map +0 -1
- package/dist/commands/dataset/__tests__/list.test.js +0 -216
- package/dist/commands/dataset/__tests__/list.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/create.test.js +0 -339
- package/dist/commands/dataset/alias/__tests__/create.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/delete.test.js +0 -247
- package/dist/commands/dataset/alias/__tests__/delete.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/link.test.js +0 -376
- package/dist/commands/dataset/alias/__tests__/link.test.js.map +0 -1
- package/dist/commands/dataset/alias/__tests__/unlink.test.js +0 -313
- package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/get.test.js +0 -128
- package/dist/commands/dataset/visibility/__tests__/get.test.js.map +0 -1
- package/dist/commands/dataset/visibility/__tests__/set.test.js +0 -198
- package/dist/commands/dataset/visibility/__tests__/set.test.js.map +0 -1
- package/dist/commands/docs/__tests__/browse.test.js +0 -29
- package/dist/commands/docs/__tests__/browse.test.js.map +0 -1
- package/dist/commands/docs/__tests__/read.test.js +0 -78
- package/dist/commands/docs/__tests__/read.test.js.map +0 -1
- package/dist/commands/docs/__tests__/search.test.js +0 -255
- package/dist/commands/docs/__tests__/search.test.js.map +0 -1
- package/dist/commands/documents/__tests__/create.test.js +0 -1030
- package/dist/commands/documents/__tests__/create.test.js.map +0 -1
- package/dist/commands/documents/__tests__/delete.test.js +0 -300
- package/dist/commands/documents/__tests__/delete.test.js.map +0 -1
- package/dist/commands/documents/__tests__/get.test.js +0 -182
- package/dist/commands/documents/__tests__/get.test.js.map +0 -1
- package/dist/commands/documents/__tests__/query.test.js +0 -300
- package/dist/commands/documents/__tests__/query.test.js.map +0 -1
- package/dist/commands/documents/__tests__/validate.test.js +0 -249
- package/dist/commands/documents/__tests__/validate.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/list.test.js +0 -240
- package/dist/commands/graphql/__tests__/list.test.js.map +0 -1
- package/dist/commands/graphql/__tests__/undeploy.test.js +0 -410
- package/dist/commands/graphql/__tests__/undeploy.test.js.map +0 -1
- package/dist/commands/hook/__tests__/attempt.test.js +0 -275
- package/dist/commands/hook/__tests__/attempt.test.js.map +0 -1
- package/dist/commands/hook/__tests__/create.test.js +0 -119
- package/dist/commands/hook/__tests__/create.test.js.map +0 -1
- package/dist/commands/hook/__tests__/delete.test.js +0 -233
- package/dist/commands/hook/__tests__/delete.test.js.map +0 -1
- package/dist/commands/hook/__tests__/list.test.js +0 -145
- package/dist/commands/hook/__tests__/list.test.js.map +0 -1
- package/dist/commands/hook/__tests__/logs.test.js +0 -798
- package/dist/commands/hook/__tests__/logs.test.js.map +0 -1
- package/dist/commands/manifest/__tests__/extract.test.js +0 -132
- package/dist/commands/manifest/__tests__/extract.test.js.map +0 -1
- package/dist/commands/mcp/__tests__/configure.test.js +0 -397
- package/dist/commands/mcp/__tests__/configure.test.js.map +0 -1
- package/dist/commands/media/__tests__/create-aspect.test.js +0 -173
- package/dist/commands/media/__tests__/create-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/delete-aspect.test.js +0 -342
- package/dist/commands/media/__tests__/delete-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/deploy-aspect.test.js +0 -619
- package/dist/commands/media/__tests__/deploy-aspect.test.js.map +0 -1
- package/dist/commands/media/__tests__/export.test.js +0 -697
- package/dist/commands/media/__tests__/export.test.js.map +0 -1
- package/dist/commands/media/__tests__/import.test.js +0 -347
- package/dist/commands/media/__tests__/import.test.js.map +0 -1
- package/dist/commands/openapi/__tests__/get.test.js +0 -149
- package/dist/commands/openapi/__tests__/get.test.js.map +0 -1
- package/dist/commands/openapi/__tests__/list.test.js +0 -113
- package/dist/commands/openapi/__tests__/list.test.js.map +0 -1
- package/dist/commands/projects/__tests__/list.test.js +0 -154
- package/dist/commands/projects/__tests__/list.test.js.map +0 -1
- package/dist/commands/schema/__tests__/delete.test.js +0 -454
- package/dist/commands/schema/__tests__/delete.test.js.map +0 -1
- package/dist/commands/schema/__tests__/deploy.test.js +0 -348
- package/dist/commands/schema/__tests__/deploy.test.js.map +0 -1
- package/dist/commands/schema/__tests__/extract.test.js +0 -121
- package/dist/commands/schema/__tests__/extract.test.js.map +0 -1
- package/dist/commands/schema/__tests__/list.test.js +0 -399
- package/dist/commands/schema/__tests__/list.test.js.map +0 -1
- package/dist/commands/schema/__tests__/validate.test.js +0 -121
- package/dist/commands/schema/__tests__/validate.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/disable.test.js +0 -147
- package/dist/commands/telemetry/__tests__/disable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/enable.test.js +0 -133
- package/dist/commands/telemetry/__tests__/enable.test.js.map +0 -1
- package/dist/commands/telemetry/__tests__/status.test.js +0 -155
- package/dist/commands/telemetry/__tests__/status.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/add.test.js +0 -435
- package/dist/commands/tokens/__tests__/add.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/delete.test.js +0 -405
- package/dist/commands/tokens/__tests__/delete.test.js.map +0 -1
- package/dist/commands/tokens/__tests__/list.test.js +0 -395
- package/dist/commands/tokens/__tests__/list.test.js.map +0 -1
- package/dist/commands/users/__tests__/invite.test.js +0 -362
- package/dist/commands/users/__tests__/invite.test.js.map +0 -1
- package/dist/commands/users/__tests__/list.test.js +0 -407
- package/dist/commands/users/__tests__/list.test.js.map +0 -1
- package/dist/hooks/prerun/__tests__/setupTelemetry.test.js +0 -77
- package/dist/hooks/prerun/__tests__/setupTelemetry.test.js.map +0 -1
- package/dist/services/__tests__/datasetAliases.test.js +0 -131
- package/dist/services/__tests__/datasetAliases.test.js.map +0 -1
- package/dist/services/__tests__/datasets.test.js +0 -436
- package/dist/services/__tests__/datasets.test.js.map +0 -1
- package/dist/services/__tests__/graphql.test.js +0 -43
- package/dist/services/__tests__/graphql.test.js.map +0 -1
- package/dist/services/__tests__/mediaLibraries.test.js +0 -88
- package/dist/services/__tests__/mediaLibraries.test.js.map +0 -1
- package/dist/services/__tests__/projects.test.js +0 -41
- package/dist/services/__tests__/projects.test.js.map +0 -1
- package/dist/services/__tests__/userApplications.test.js +0 -113
- package/dist/services/__tests__/userApplications.test.js.map +0 -1
- package/dist/util/__tests__/appId.test.js +0 -31
- package/dist/util/__tests__/appId.test.js.map +0 -1
- package/dist/util/__tests__/cliClient.test.js +0 -184
- package/dist/util/__tests__/cliClient.test.js.map +0 -1
- package/dist/util/__tests__/compareDependencyVersions.test.js +0 -426
- package/dist/util/__tests__/compareDependencyVersions.test.js.map +0 -1
- package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js +0 -74
- package/dist/util/__tests__/extractDocumentsFromNdjsonOrTarball.test.js.map +0 -1
- package/dist/util/__tests__/findNdjsonEntry.test.js +0 -54
- package/dist/util/__tests__/findNdjsonEntry.test.js.map +0 -1
- package/dist/util/__tests__/getCliVersion.test.js +0 -28
- package/dist/util/__tests__/getCliVersion.test.js.map +0 -1
- package/dist/util/__tests__/getLocalPackageVersion.test.js +0 -84
- package/dist/util/__tests__/getLocalPackageVersion.test.js.map +0 -1
- package/dist/util/__tests__/getWorkspace.test.js +0 -37
- package/dist/util/__tests__/getWorkspace.test.js.map +0 -1
- package/dist/util/__tests__/readPackageJson.test.js +0 -69
- package/dist/util/__tests__/readPackageJson.test.js.map +0 -1
- package/dist/util/__tests__/warnAboutMissingAppId.test.js +0 -28
- package/dist/util/__tests__/warnAboutMissingAppId.test.js.map +0 -1
- package/dist/util/packageManager/__tests__/installPackages.test.js +0 -388
- package/dist/util/packageManager/__tests__/installPackages.test.js.map +0 -1
- package/dist/util/validation/ __tests__/validateDocuments.test.js +0 -274
- package/dist/util/validation/ __tests__/validateDocuments.test.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.ts"],"sourcesContent":["import fs from 'node:fs'\nimport {tmpdir} from 'node:os'\nimport path from 'node:path'\nimport {type MessagePort} from 'node:worker_threads'\n\nimport {type ReactElement, type ReactNode} from 'react'\nimport {renderToStaticMarkup} from 'react-dom/server'\nimport {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {renderDocumentWorker, type RenderDocumentWorkerOptions} from '../renderDocumentWorker.js'\nimport {type DocumentProps} from '../types.js'\n\n// Mock the lower-level dependencies that we still need to mock\nvi.mock('../../buildDebug.js')\nvi.mock('react-dom/server', () => ({\n renderToStaticMarkup: vi.fn(),\n}))\n\nconst mockRenderToStaticMarkup = vi.mocked(renderToStaticMarkup)\n\n// Create test document components as strings\nconst validDocumentComponent = `\nconst React = require('react');\n\nfunction TestDocument(props) {\n const { basePath = '', css = [], entryPath = './.sanity/runtime/app.js' } = props;\n\n return React.createElement('html', { lang: 'en' },\n React.createElement('head', null,\n React.createElement('meta', { charSet: 'utf-8' }),\n React.createElement('title', null, 'Test Document'),\n ...css.map((href) => React.createElement('link', { rel: 'stylesheet', href, key: href }))\n ),\n React.createElement('body', null,\n React.createElement('div', { id: 'root' }),\n React.createElement('script', { src: entryPath, type: 'module' }),\n React.createElement('div', null, \\`Base: \\${basePath || 'default'}\\`)\n )\n );\n}\n\nmodule.exports = TestDocument;\nmodule.exports.default = TestDocument;\n`\n\nconst invalidDocumentComponent = `\nconst notDefault = 'invalid';\nconst someFunction = () => 'test';\n\nmodule.exports = { notDefault, someFunction };\n`\n\nconst documentComponentWithoutDefaultExport = `\nfunction NamedComponent() {\n return 'not default export';\n}\n\nmodule.exports = { NamedComponent };\n`\n\ndescribe('#renderDocumentWorker', () => {\n let mockParent: MessagePort\n let originalDateNow: typeof Date.now\n let tempDir: string\n let testStudioPath: string\n\n beforeEach(async () => {\n vi.clearAllMocks()\n\n // Mock Date.now to return a consistent timestamp for testing\n originalDateNow = Date.now\n Date.now = vi.fn(() => 1_640_995_200_000) // Fixed timestamp: 2022-01-01 00:00:00 UTC\n\n // Create a mock MessagePort\n mockParent = {\n postMessage: vi.fn(),\n } as unknown as MessagePort\n\n // Create temporary directory for test files\n tempDir = await fs.promises.mkdtemp(path.join(tmpdir(), 'sanity-test-'))\n testStudioPath = path.join(tempDir, 'studio')\n await fs.promises.mkdir(testStudioPath, {recursive: true})\n\n // Setup default mock for renderToStaticMarkup\n mockRenderToStaticMarkup.mockImplementation((element: ReactNode) => {\n // Simple mock that returns the component's rendered output\n const props = (element as ReactElement<DocumentProps>)?.props || {}\n const {basePath = '', css = [], entryPath = './.sanity/runtime/app.js'} = props\n return `<html><head><title>Test Document</title>${css.map((href: string) => `<link rel=\"stylesheet\" href=\"${href}\" />`).join('')}</head><body><script src=\"${entryPath}\" type=\"module\"></script><div>Base: ${basePath || 'default'}</div></body></html>`\n })\n })\n\n afterEach(async () => {\n // Restore original Date.now\n Date.now = originalDateNow\n\n // Clean up temporary directory\n try {\n await fs.promises.rm(tempDir, {force: true, recursive: true})\n } catch (error) {\n console.warn('Failed to clean up temp directory:', error)\n }\n })\n\n async function createTestDocumentComponent(content: string, filename = '_document.js') {\n const filePath = path.join(testStudioPath, filename)\n await fs.promises.writeFile(filePath, content)\n return filePath\n }\n\n describe('input validation', () => {\n test('should send error message when studioRootPath is not a string', async () => {\n const options = {\n studioRootPath: 123,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n message: 'Missing/invalid `studioRootPath` option',\n type: 'error',\n })\n expect(mockRenderToStaticMarkup).not.toHaveBeenCalled()\n })\n\n test('should send error message when studioRootPath is undefined', async () => {\n const options = {\n studioRootPath: undefined,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n message: 'Missing/invalid `studioRootPath` option',\n type: 'error',\n })\n expect(mockRenderToStaticMarkup).not.toHaveBeenCalled()\n })\n\n test('should send error message when studioRootPath is null', async () => {\n const options = {\n studioRootPath: null,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n message: 'Missing/invalid `studioRootPath` option',\n type: 'error',\n })\n expect(mockRenderToStaticMarkup).not.toHaveBeenCalled()\n })\n\n test('should render document when studioRootPath is empty string', async () => {\n const options = {\n studioRootPath: '',\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should send error message when props is not an object', async () => {\n const options = {\n props: 'invalid',\n studioRootPath: testStudioPath,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n message: '`props` must be an object if provided',\n type: 'error',\n })\n expect(mockRenderToStaticMarkup).not.toHaveBeenCalled()\n })\n\n test('should send error message when props is a primitive value', async () => {\n const options = {\n props: 123,\n studioRootPath: testStudioPath,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n message: '`props` must be an object if provided',\n type: 'error',\n })\n expect(mockRenderToStaticMarkup).not.toHaveBeenCalled()\n })\n\n test('should render document when props is an array (arrays are objects)', async () => {\n const options = {\n props: [],\n studioRootPath: testStudioPath,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n })\n\n describe('successful rendering with default components', () => {\n test('should render document with minimal options', async () => {\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should render document with all options provided', async () => {\n const props: DocumentProps = {\n basePath: '/studio',\n css: ['style.css', 'theme.css'],\n entryPath: './custom-entry.js',\n }\n\n const importMap = {\n imports: {\n react: 'https://esm.sh/react@18',\n 'react-dom': 'https://esm.sh/react-dom@18',\n },\n }\n\n const options = {\n importMap,\n isApp: true,\n props,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n basePath: '/studio',\n css: ['/studio/style.css', '/studio/theme.css'], // CSS paths should be processed\n entryPath: './custom-entry.js',\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should render document with isApp=false', async () => {\n const options = {\n isApp: false,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should render document with empty props object', async () => {\n const options = {\n props: {} as DocumentProps,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n entryPath: './.sanity/runtime/app.js', // Default entry path\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should render document with complex props', async () => {\n const props: DocumentProps = {\n basePath: '/complex/path',\n css: ['main.css', 'components.css', 'theme.css'],\n entryPath: './src/index.js',\n }\n\n const options = {\n props,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n basePath: '/complex/path',\n css: [\n '/complex/path/main.css',\n '/complex/path/components.css',\n '/complex/path/theme.css',\n ],\n entryPath: './src/index.js',\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should render document with complex importMap', async () => {\n const importMap = {\n imports: {\n '@sanity/ui': 'https://esm.sh/@sanity/ui@2.0.0',\n react: 'https://esm.sh/react@18.2.0',\n 'react-dom': 'https://esm.sh/react-dom@18.2.0',\n 'react-dom/client': 'https://esm.sh/react-dom@18.2.0/client',\n },\n }\n\n const options = {\n importMap,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should use BasicDocument when isApp=true', async () => {\n const options = {\n isApp: true,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should use DefaultDocument when isApp=false', async () => {\n const options = {\n isApp: false,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n })\n\n describe('user-defined document components', () => {\n test('should handle user-defined document component', async () => {\n await createTestDocumentComponent(validDocumentComponent)\n\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle user-defined component with warning when not a function', async () => {\n await createTestDocumentComponent(invalidDocumentComponent)\n\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith(\n expect.objectContaining({\n message: expect.arrayContaining([\n expect.stringContaining('did not have a default export that is a React component'),\n ]),\n type: 'warning',\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle user-defined component without default export', async () => {\n await createTestDocumentComponent(documentComponentWithoutDefaultExport)\n\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith(\n expect.objectContaining({\n message: expect.arrayContaining([\n expect.stringContaining('did not have a default export that is a React component'),\n ]),\n type: 'warning',\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should prefer .tsx over .js when both exist', async () => {\n // Create both .js and .tsx files\n await createTestDocumentComponent(invalidDocumentComponent, '_document.js')\n await createTestDocumentComponent(validDocumentComponent, '_document.tsx')\n\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n // Should use the .js file (first in the list from getPossibleDocumentComponentLocations)\n expect(mockParent.postMessage).toHaveBeenCalledWith(\n expect.objectContaining({\n message: expect.arrayContaining([\n expect.stringContaining('did not have a default export that is a React component'),\n ]),\n type: 'warning',\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n })\n\n describe('error handling', () => {\n test('should handle renderToStaticMarkup throwing', async () => {\n const options = {\n props: {\n basePath: '/studio',\n } as DocumentProps,\n studioRootPath: testStudioPath,\n }\n\n const error = new Error('React rendering failed')\n mockRenderToStaticMarkup.mockImplementation(() => {\n throw error\n })\n\n await expect(renderDocumentWorker(mockParent, options)).rejects.toThrow(\n 'React rendering failed',\n )\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n })\n\n test('should handle invalid document component module', async () => {\n // Create a file with syntax errors\n await createTestDocumentComponent('invalid javascript syntax!@#$')\n\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await expect(renderDocumentWorker(mockParent, options)).rejects.toThrow()\n })\n })\n\n describe('edge cases', () => {\n test('should handle null props correctly', async () => {\n const options = {\n props: null,\n studioRootPath: testStudioPath,\n } as unknown as RenderDocumentWorkerOptions\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle undefined props correctly', async () => {\n const options = {\n props: undefined,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle empty importMap correctly', async () => {\n const options = {\n importMap: {},\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle isApp=false explicitly', async () => {\n const options = {\n isApp: false,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalled()\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n })\n\n describe('integration tests', () => {\n test('should maintain correct call order and data flow', async () => {\n const options = {\n importMap: {imports: {react: 'https://esm.sh/react'}},\n isApp: true,\n props: {basePath: '/studio'} as DocumentProps,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n // Verify the complete integration flow\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n basePath: '/studio',\n entryPath: './.sanity/runtime/app.js',\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should handle all parameters in correct order with realistic data flow', async () => {\n const options = {\n importMap: {\n imports: {\n '@test/module': './test-module.js',\n },\n },\n isApp: false,\n props: {\n basePath: '/integration',\n css: ['test.css'],\n entryPath: './test-entry.js',\n } as DocumentProps,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n // Verify that all parameters flow through the integration correctly\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n basePath: '/integration',\n css: ['/integration/test.css'], // CSS should be processed with basePath\n entryPath: './test-entry.js',\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n\n test('should process CSS paths correctly with different basePath scenarios', async () => {\n const testCases = [\n {\n basePath: '/studio',\n css: ['style.css', '/absolute.css'],\n expected: ['/studio/style.css', '/studio/absolute.css'],\n },\n {\n basePath: '/studio/',\n css: ['style.css', '/absolute.css'],\n expected: ['/studio/style.css', '/studio/absolute.css'],\n },\n {\n basePath: 'studio',\n css: ['style.css'],\n expected: ['/studio/style.css'],\n },\n ]\n\n for (const testCase of testCases) {\n vi.clearAllMocks()\n\n const options = {\n props: {\n basePath: testCase.basePath,\n css: testCase.css,\n } as DocumentProps,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n css: testCase.expected,\n }),\n }),\n )\n }\n })\n\n test('should include import map script tags when importMap is provided', async () => {\n const importMap = {\n imports: {\n react: 'https://sanity-cdn.com/react@18/t1640995000',\n 'react-dom': 'https://esm.sh/react-dom@18',\n },\n }\n\n const options = {\n importMap,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('__imports'),\n type: 'result',\n })\n\n // Check that the result HTML contains the import map JSON\n const mockPostMessage = vi.mocked(mockParent.postMessage)\n const resultCall = mockPostMessage.mock.calls.find((call) => {\n const message = call[0] as {type: string}\n return message.type === 'result'\n })\n const resultMessage = resultCall?.[0] as {html: string}\n expect(resultMessage.html).toContain(JSON.stringify(importMap))\n expect(resultMessage.html).toContain('auto-generated script to add import map with timestamp')\n })\n\n test('should not include import map scripts when importMap is not provided', async () => {\n const options = {\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n const mockPostMessage = vi.mocked(mockParent.postMessage)\n const resultCall = mockPostMessage.mock.calls.find((call) => {\n const message = call[0] as {type: string}\n return message.type === 'result'\n })\n const resultMessage = resultCall?.[0] as {html: string}\n expect(resultMessage.html).not.toContain('__imports')\n expect(resultMessage.html).not.toContain(\n 'auto-generated script to add import map with timestamp',\n )\n })\n\n test('should work with user-defined component and complex props', async () => {\n await createTestDocumentComponent(validDocumentComponent)\n\n const props: DocumentProps = {\n basePath: '/custom',\n css: ['custom.css', 'theme.css'],\n entryPath: './custom-entry.js',\n }\n\n const options = {\n props,\n studioRootPath: testStudioPath,\n }\n\n await renderDocumentWorker(mockParent, options)\n\n expect(mockRenderToStaticMarkup).toHaveBeenCalledWith(\n expect.objectContaining({\n props: expect.objectContaining({\n basePath: '/custom',\n css: ['/custom/custom.css', '/custom/theme.css'],\n entryPath: './custom-entry.js',\n }),\n }),\n )\n expect(mockParent.postMessage).toHaveBeenCalledWith({\n html: expect.stringContaining('<!DOCTYPE html>'),\n type: 'result',\n })\n })\n })\n})\n"],"names":["fs","tmpdir","path","renderToStaticMarkup","afterEach","beforeEach","describe","expect","test","vi","renderDocumentWorker","mock","fn","mockRenderToStaticMarkup","mocked","validDocumentComponent","invalidDocumentComponent","documentComponentWithoutDefaultExport","mockParent","originalDateNow","tempDir","testStudioPath","clearAllMocks","Date","now","postMessage","promises","mkdtemp","join","mkdir","recursive","mockImplementation","element","props","basePath","css","entryPath","map","href","rm","force","error","console","warn","createTestDocumentComponent","content","filename","filePath","writeFile","options","studioRootPath","toHaveBeenCalledWith","message","type","not","toHaveBeenCalled","undefined","html","stringContaining","importMap","imports","react","isApp","objectContaining","arrayContaining","Error","rejects","toThrow","testCases","expected","testCase","mockPostMessage","resultCall","calls","find","call","resultMessage","toContain","JSON","stringify"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,SAAQC,MAAM,QAAO,UAAS;AAC9B,OAAOC,UAAU,YAAW;AAI5B,SAAQC,oBAAoB,QAAO,mBAAkB;AACrD,SAAQC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAExE,SAAQC,oBAAoB,QAAyC,6BAA4B;AAGjG,+DAA+D;AAC/DD,GAAGE,IAAI,CAAC;AACRF,GAAGE,IAAI,CAAC,oBAAoB,IAAO,CAAA;QACjCR,sBAAsBM,GAAGG,EAAE;IAC7B,CAAA;AAEA,MAAMC,2BAA2BJ,GAAGK,MAAM,CAACX;AAE3C,6CAA6C;AAC7C,MAAMY,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBhC,CAAC;AAED,MAAMC,2BAA2B,CAAC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S,CACtC;QAEJ;QAEArE,KAAK,6DAA6D;YAChE,MAAMoC,4BAA4B7B;YAElC,MAAMkB,QAAuB;gBAC3BC,UAAU;gBACVC,KAAK;oBAAC;oBAAc;iBAAY;gBAChCC,WAAW;YACb;YAEA,MAAMa,UAAU;gBACdhB;gBACAiB,gBAAgB7B;YAClB;YAEA,MAAMX,qBAAqBQ,YAAY+B;YAEvC1C,OAAOM,0BAA0BsC,oBAAoB,CACnD5C,OAAOwD,gBAAgB,CAAC;gBACtB9B,OAAO1B,OAAOwD,gBAAgB,CAAC;oBAC7B7B,UAAU;oBACVC,KAAK;wBAAC;wBAAsB;qBAAoB;oBAChDC,WAAW;gBACb;YACF;YAEF7B,OAAOW,WAAWO,WAAW,EAAE0B,oBAAoB,CAAC;gBAClDM,MAAMlD,OAAOmD,gBAAgB,CAAC;gBAC9BL,MAAM;YACR;QACF;IACF;AACF"}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { validateDatasetName } from '../validateDatasetName';
|
|
3
|
-
describe('validateDatasetName', ()=>{
|
|
4
|
-
test.each([
|
|
5
|
-
[
|
|
6
|
-
'abc',
|
|
7
|
-
false
|
|
8
|
-
],
|
|
9
|
-
[
|
|
10
|
-
'test-dataset',
|
|
11
|
-
false
|
|
12
|
-
],
|
|
13
|
-
[
|
|
14
|
-
'test_dataset',
|
|
15
|
-
false
|
|
16
|
-
],
|
|
17
|
-
[
|
|
18
|
-
'dataset123',
|
|
19
|
-
false
|
|
20
|
-
],
|
|
21
|
-
[
|
|
22
|
-
'a1',
|
|
23
|
-
false
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
'1a',
|
|
27
|
-
false
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
'ab',
|
|
31
|
-
false
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
'test-123_dataset',
|
|
35
|
-
false
|
|
36
|
-
],
|
|
37
|
-
// 64 character name (max length)
|
|
38
|
-
[
|
|
39
|
-
'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01',
|
|
40
|
-
false
|
|
41
|
-
]
|
|
42
|
-
])('should return false for valid dataset name: "%s"', (datasetName, expected)=>{
|
|
43
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
44
|
-
});
|
|
45
|
-
test.each([
|
|
46
|
-
[
|
|
47
|
-
'',
|
|
48
|
-
'Dataset name is missing'
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
null,
|
|
52
|
-
'Dataset name is missing'
|
|
53
|
-
],
|
|
54
|
-
[
|
|
55
|
-
undefined,
|
|
56
|
-
'Dataset name is missing'
|
|
57
|
-
]
|
|
58
|
-
])('should return error for missing dataset name: %s', (datasetName, expected)=>{
|
|
59
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
60
|
-
});
|
|
61
|
-
test.each([
|
|
62
|
-
[
|
|
63
|
-
'Test',
|
|
64
|
-
'Dataset name must be all lowercase characters'
|
|
65
|
-
],
|
|
66
|
-
[
|
|
67
|
-
'TEST',
|
|
68
|
-
'Dataset name must be all lowercase characters'
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
'tEst',
|
|
72
|
-
'Dataset name must be all lowercase characters'
|
|
73
|
-
],
|
|
74
|
-
[
|
|
75
|
-
'test-Dataset',
|
|
76
|
-
'Dataset name must be all lowercase characters'
|
|
77
|
-
]
|
|
78
|
-
])('should return error for non-lowercase names: "%s"', (datasetName, expected)=>{
|
|
79
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
80
|
-
});
|
|
81
|
-
test.each([
|
|
82
|
-
[
|
|
83
|
-
'a',
|
|
84
|
-
'Dataset name must be at least two characters long'
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
'1',
|
|
88
|
-
'Dataset name must be at least two characters long'
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
'-',
|
|
92
|
-
'Dataset name must be at least two characters long'
|
|
93
|
-
]
|
|
94
|
-
])('should return error for names shorter than 2 characters: "%s"', (datasetName, expected)=>{
|
|
95
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
96
|
-
});
|
|
97
|
-
test('should return error for names longer than 64 characters', ()=>{
|
|
98
|
-
const longName = 'a'.repeat(65);
|
|
99
|
-
expect(validateDatasetName(longName)).toBe('Dataset name must be at most 64 characters');
|
|
100
|
-
});
|
|
101
|
-
test.each([
|
|
102
|
-
[
|
|
103
|
-
'-abc',
|
|
104
|
-
'Dataset name must start with a letter or a number'
|
|
105
|
-
],
|
|
106
|
-
[
|
|
107
|
-
'_abc',
|
|
108
|
-
'Dataset name must start with a letter or a number'
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
'-123',
|
|
112
|
-
'Dataset name must start with a letter or a number'
|
|
113
|
-
],
|
|
114
|
-
[
|
|
115
|
-
'_test',
|
|
116
|
-
'Dataset name must start with a letter or a number'
|
|
117
|
-
]
|
|
118
|
-
])('should return error for names not starting with letter or number: "%s"', (datasetName, expected)=>{
|
|
119
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
120
|
-
});
|
|
121
|
-
test.each([
|
|
122
|
-
[
|
|
123
|
-
'test!',
|
|
124
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
125
|
-
],
|
|
126
|
-
[
|
|
127
|
-
'test@name',
|
|
128
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
129
|
-
],
|
|
130
|
-
[
|
|
131
|
-
'test name',
|
|
132
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
133
|
-
],
|
|
134
|
-
[
|
|
135
|
-
'test.name',
|
|
136
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
'test#123',
|
|
140
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
141
|
-
],
|
|
142
|
-
[
|
|
143
|
-
'test$',
|
|
144
|
-
'Dataset name must only contain letters, numbers, dashes and underscores'
|
|
145
|
-
]
|
|
146
|
-
])('should return error for names with invalid characters: "%s"', (datasetName, expected)=>{
|
|
147
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
148
|
-
});
|
|
149
|
-
test.each([
|
|
150
|
-
[
|
|
151
|
-
'test-',
|
|
152
|
-
'Dataset name must not end with a dash or an underscore'
|
|
153
|
-
],
|
|
154
|
-
[
|
|
155
|
-
'test_',
|
|
156
|
-
'Dataset name must not end with a dash or an underscore'
|
|
157
|
-
],
|
|
158
|
-
[
|
|
159
|
-
'dataset123-',
|
|
160
|
-
'Dataset name must not end with a dash or an underscore'
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
'dataset123_',
|
|
164
|
-
'Dataset name must not end with a dash or an underscore'
|
|
165
|
-
]
|
|
166
|
-
])('should return error for names ending with dash or underscore: "%s"', (datasetName, expected)=>{
|
|
167
|
-
expect(validateDatasetName(datasetName)).toBe(expected);
|
|
168
|
-
});
|
|
169
|
-
test('should handle edge case: exactly 64 characters', ()=>{
|
|
170
|
-
// Test exactly 64 characters - should be valid
|
|
171
|
-
const maxLengthName = 'a'.repeat(64);
|
|
172
|
-
expect(validateDatasetName(maxLengthName)).toBe(false);
|
|
173
|
-
});
|
|
174
|
-
test('should handle edge case: 2 characters starting with number', ()=>{
|
|
175
|
-
expect(validateDatasetName('1a')).toBe(false);
|
|
176
|
-
});
|
|
177
|
-
test('should handle edge case: 2 characters starting with letter', ()=>{
|
|
178
|
-
expect(validateDatasetName('a1')).toBe(false);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
//# sourceMappingURL=validateDatasetName.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/dataset/__tests__/validateDatasetName.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {validateDatasetName} from '../validateDatasetName'\n\ndescribe('validateDatasetName', () => {\n test.each([\n ['abc', false],\n ['test-dataset', false],\n ['test_dataset', false],\n ['dataset123', false],\n ['a1', false],\n ['1a', false],\n ['ab', false],\n ['test-123_dataset', false],\n // 64 character name (max length)\n ['abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01', false],\n ])('should return false for valid dataset name: \"%s\"', (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n })\n\n test.each([\n ['', 'Dataset name is missing'],\n [null as unknown as string, 'Dataset name is missing'],\n [undefined as unknown as string, 'Dataset name is missing'],\n ])('should return error for missing dataset name: %s', (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n })\n\n test.each([\n ['Test', 'Dataset name must be all lowercase characters'],\n ['TEST', 'Dataset name must be all lowercase characters'],\n ['tEst', 'Dataset name must be all lowercase characters'],\n ['test-Dataset', 'Dataset name must be all lowercase characters'],\n ])('should return error for non-lowercase names: \"%s\"', (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n })\n\n test.each([\n ['a', 'Dataset name must be at least two characters long'],\n ['1', 'Dataset name must be at least two characters long'],\n ['-', 'Dataset name must be at least two characters long'],\n ])('should return error for names shorter than 2 characters: \"%s\"', (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n })\n\n test('should return error for names longer than 64 characters', () => {\n const longName = 'a'.repeat(65)\n expect(validateDatasetName(longName)).toBe('Dataset name must be at most 64 characters')\n })\n\n test.each([\n ['-abc', 'Dataset name must start with a letter or a number'],\n ['_abc', 'Dataset name must start with a letter or a number'],\n ['-123', 'Dataset name must start with a letter or a number'],\n ['_test', 'Dataset name must start with a letter or a number'],\n ])(\n 'should return error for names not starting with letter or number: \"%s\"',\n (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n },\n )\n\n test.each([\n ['test!', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ['test@name', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ['test name', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ['test.name', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ['test#123', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ['test$', 'Dataset name must only contain letters, numbers, dashes and underscores'],\n ])('should return error for names with invalid characters: \"%s\"', (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n })\n\n test.each([\n ['test-', 'Dataset name must not end with a dash or an underscore'],\n ['test_', 'Dataset name must not end with a dash or an underscore'],\n ['dataset123-', 'Dataset name must not end with a dash or an underscore'],\n ['dataset123_', 'Dataset name must not end with a dash or an underscore'],\n ])(\n 'should return error for names ending with dash or underscore: \"%s\"',\n (datasetName, expected) => {\n expect(validateDatasetName(datasetName)).toBe(expected)\n },\n )\n\n test('should handle edge case: exactly 64 characters', () => {\n // Test exactly 64 characters - should be valid\n const maxLengthName = 'a'.repeat(64)\n expect(validateDatasetName(maxLengthName)).toBe(false)\n })\n\n test('should handle edge case: 2 characters starting with number', () => {\n expect(validateDatasetName('1a')).toBe(false)\n })\n\n test('should handle edge case: 2 characters starting with letter', () => {\n expect(validateDatasetName('a1')).toBe(false)\n })\n})\n"],"names":["describe","expect","test","validateDatasetName","each","datasetName","expected","toBe","undefined","longName","repeat","maxLengthName"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,mBAAmB,QAAO,yBAAwB;AAE1DH,SAAS,uBAAuB;IAC9BE,KAAKE,IAAI,CAAC;QACR;YAAC;YAAO;SAAM;QACd;YAAC;YAAgB;SAAM;QACvB;YAAC;YAAgB;SAAM;QACvB;YAAC;YAAc;SAAM;QACrB;YAAC;YAAM;SAAM;QACb;YAAC;YAAM;SAAM;QACb;YAAC;YAAM;SAAM;QACb;YAAC;YAAoB;SAAM;QAC3B,iCAAiC;QACjC;YAAC;YAAoE;SAAM;KAC5E,EAAE,oDAAoD,CAACC,aAAaC;QACnEL,OAAOE,oBAAoBE,cAAcE,IAA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AAC;YAAS;SAAyD;QACnE;YAAC;YAAS;SAAyD;QACnE;YAAC;YAAe;SAAyD;QACzE;YAAC;YAAe;SAAyD;KAC1E,EACC,sEACA,CAACC,aAAaC;QACZL,OAAOE,oBAAoBE,cAAcE,IAAI,CAACD;IAChD;IAGFJ,KAAK,kDAAkD;QACrD,+CAA+C;QAC/C,MAAMS,gBAAgB,IAAID,MAAM,CAAC;QACjCT,OAAOE,oBAAoBQ,gBAAgBJ,IAAI,CAAC;IAClD;IAEAL,KAAK,8DAA8D;QACjED,OAAOE,oBAAoB,OAAOI,IAAI,CAAC;IACzC;IAEAL,KAAK,8DAA8D;QACjED,OAAOE,oBAAoB,OAAOI,IAAI,CAAC;IACzC;AACF"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { stat } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
4
|
-
import { checkDir } from '../checkDir.js';
|
|
5
|
-
vi.mock('node:fs/promises', ()=>({
|
|
6
|
-
stat: vi.fn()
|
|
7
|
-
}));
|
|
8
|
-
const mockStat = vi.mocked(stat);
|
|
9
|
-
describe('#checkDir', ()=>{
|
|
10
|
-
const testDir = '/test/directory';
|
|
11
|
-
afterEach(()=>{
|
|
12
|
-
vi.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
test('should pass when directory exists and contains index.html', async ()=>{
|
|
15
|
-
// Mock directory exists and is a directory
|
|
16
|
-
mockStat.mockResolvedValueOnce({
|
|
17
|
-
isDirectory: ()=>true
|
|
18
|
-
});
|
|
19
|
-
// Mock index.html exists
|
|
20
|
-
mockStat.mockResolvedValueOnce({});
|
|
21
|
-
await expect(checkDir(testDir)).resolves.toBeUndefined();
|
|
22
|
-
expect(mockStat).toHaveBeenCalledTimes(2);
|
|
23
|
-
expect(mockStat).toHaveBeenNthCalledWith(1, testDir);
|
|
24
|
-
expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'));
|
|
25
|
-
});
|
|
26
|
-
test('should throw error when directory does not exist', async ()=>{
|
|
27
|
-
const enoentError = new Error('ENOENT');
|
|
28
|
-
enoentError.code = 'ENOENT';
|
|
29
|
-
mockStat.mockRejectedValueOnce(enoentError);
|
|
30
|
-
await expect(checkDir(testDir)).rejects.toThrow(`Directory "${testDir}" does not exist`);
|
|
31
|
-
expect(mockStat).toHaveBeenCalledTimes(1);
|
|
32
|
-
expect(mockStat).toHaveBeenCalledWith(testDir);
|
|
33
|
-
});
|
|
34
|
-
test('should throw error when path exists but is not a directory', async ()=>{
|
|
35
|
-
// Mock path exists but is not a directory
|
|
36
|
-
mockStat.mockResolvedValueOnce({
|
|
37
|
-
isDirectory: ()=>false
|
|
38
|
-
});
|
|
39
|
-
await expect(checkDir(testDir)).rejects.toThrow(`Directory ${testDir} is not a directory`);
|
|
40
|
-
expect(mockStat).toHaveBeenCalledTimes(1);
|
|
41
|
-
expect(mockStat).toHaveBeenCalledWith(testDir);
|
|
42
|
-
});
|
|
43
|
-
test('should re-throw non-ENOENT errors when checking directory', async ()=>{
|
|
44
|
-
const permissionError = new Error('Permission denied');
|
|
45
|
-
permissionError.code = 'EACCES';
|
|
46
|
-
mockStat.mockRejectedValueOnce(permissionError);
|
|
47
|
-
await expect(checkDir(testDir)).rejects.toThrow('Permission denied');
|
|
48
|
-
expect(mockStat).toHaveBeenCalledTimes(1);
|
|
49
|
-
expect(mockStat).toHaveBeenCalledWith(testDir);
|
|
50
|
-
});
|
|
51
|
-
test('should throw error when index.html does not exist', async ()=>{
|
|
52
|
-
// Mock directory exists and is a directory
|
|
53
|
-
mockStat.mockResolvedValueOnce({
|
|
54
|
-
isDirectory: ()=>true
|
|
55
|
-
});
|
|
56
|
-
// Mock index.html does not exist
|
|
57
|
-
const enoentError = new Error('ENOENT');
|
|
58
|
-
enoentError.code = 'ENOENT';
|
|
59
|
-
mockStat.mockRejectedValueOnce(enoentError);
|
|
60
|
-
const expectedError = [
|
|
61
|
-
`"${testDir}/index.html" does not exist -`,
|
|
62
|
-
'[SOURCE_DIR] must be a directory containing',
|
|
63
|
-
'a Sanity studio built using "sanity build"'
|
|
64
|
-
].join(' ');
|
|
65
|
-
await expect(checkDir(testDir)).rejects.toThrow(expectedError);
|
|
66
|
-
expect(mockStat).toHaveBeenCalledTimes(2);
|
|
67
|
-
expect(mockStat).toHaveBeenNthCalledWith(1, testDir);
|
|
68
|
-
expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'));
|
|
69
|
-
});
|
|
70
|
-
test('should re-throw non-ENOENT errors when checking index.html', async ()=>{
|
|
71
|
-
// Mock directory exists and is a directory
|
|
72
|
-
mockStat.mockResolvedValueOnce({
|
|
73
|
-
isDirectory: ()=>true
|
|
74
|
-
});
|
|
75
|
-
// Mock permission error when checking index.html
|
|
76
|
-
const permissionError = new Error('Permission denied');
|
|
77
|
-
permissionError.code = 'EACCES';
|
|
78
|
-
mockStat.mockRejectedValueOnce(permissionError);
|
|
79
|
-
await expect(checkDir(testDir)).rejects.toThrow('Permission denied');
|
|
80
|
-
expect(mockStat).toHaveBeenCalledTimes(2);
|
|
81
|
-
expect(mockStat).toHaveBeenNthCalledWith(1, testDir);
|
|
82
|
-
expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'));
|
|
83
|
-
});
|
|
84
|
-
test('should handle relative paths correctly', async ()=>{
|
|
85
|
-
const relativeDir = './relative/path';
|
|
86
|
-
// Mock directory exists and is a directory
|
|
87
|
-
mockStat.mockResolvedValueOnce({
|
|
88
|
-
isDirectory: ()=>true
|
|
89
|
-
});
|
|
90
|
-
// Mock index.html exists
|
|
91
|
-
mockStat.mockResolvedValueOnce({});
|
|
92
|
-
await expect(checkDir(relativeDir)).resolves.toBeUndefined();
|
|
93
|
-
expect(mockStat).toHaveBeenCalledTimes(2);
|
|
94
|
-
expect(mockStat).toHaveBeenNthCalledWith(1, relativeDir);
|
|
95
|
-
expect(mockStat).toHaveBeenNthCalledWith(2, join(relativeDir, 'index.html'));
|
|
96
|
-
});
|
|
97
|
-
test('should handle errors without code property', async ()=>{
|
|
98
|
-
// Mock error without code property when checking directory
|
|
99
|
-
const genericError = new Error('Generic error');
|
|
100
|
-
mockStat.mockRejectedValueOnce(genericError);
|
|
101
|
-
await expect(checkDir(testDir)).rejects.toThrow('Generic error');
|
|
102
|
-
expect(mockStat).toHaveBeenCalledTimes(1);
|
|
103
|
-
expect(mockStat).toHaveBeenCalledWith(testDir);
|
|
104
|
-
});
|
|
105
|
-
test('should handle errors without code property when checking index.html', async ()=>{
|
|
106
|
-
// Mock directory exists and is a directory
|
|
107
|
-
mockStat.mockResolvedValueOnce({
|
|
108
|
-
isDirectory: ()=>true
|
|
109
|
-
});
|
|
110
|
-
// Mock error without code property when checking index.html
|
|
111
|
-
const genericError = new Error('Generic error');
|
|
112
|
-
mockStat.mockRejectedValueOnce(genericError);
|
|
113
|
-
await expect(checkDir(testDir)).rejects.toThrow('Generic error');
|
|
114
|
-
expect(mockStat).toHaveBeenCalledTimes(2);
|
|
115
|
-
expect(mockStat).toHaveBeenNthCalledWith(1, testDir);
|
|
116
|
-
expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
//# sourceMappingURL=checkDir.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/deploy/__tests__/checkDir.test.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {join} from 'node:path'\n\nimport {afterEach, describe, expect, test, vi} from 'vitest'\n\nimport {checkDir} from '../checkDir.js'\n\nvi.mock('node:fs/promises', () => ({\n stat: vi.fn(),\n}))\n\nconst mockStat = vi.mocked(stat)\n\ndescribe('#checkDir', () => {\n const testDir = '/test/directory'\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n test('should pass when directory exists and contains index.html', async () => {\n // Mock directory exists and is a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => true,\n } as never)\n\n // Mock index.html exists\n mockStat.mockResolvedValueOnce({} as never)\n\n await expect(checkDir(testDir)).resolves.toBeUndefined()\n\n expect(mockStat).toHaveBeenCalledTimes(2)\n expect(mockStat).toHaveBeenNthCalledWith(1, testDir)\n expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'))\n })\n\n test('should throw error when directory does not exist', async () => {\n const enoentError = new Error('ENOENT') as NodeJS.ErrnoException\n enoentError.code = 'ENOENT'\n\n mockStat.mockRejectedValueOnce(enoentError)\n\n await expect(checkDir(testDir)).rejects.toThrow(`Directory \"${testDir}\" does not exist`)\n\n expect(mockStat).toHaveBeenCalledTimes(1)\n expect(mockStat).toHaveBeenCalledWith(testDir)\n })\n\n test('should throw error when path exists but is not a directory', async () => {\n // Mock path exists but is not a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => false,\n } as never)\n\n await expect(checkDir(testDir)).rejects.toThrow(`Directory ${testDir} is not a directory`)\n\n expect(mockStat).toHaveBeenCalledTimes(1)\n expect(mockStat).toHaveBeenCalledWith(testDir)\n })\n\n test('should re-throw non-ENOENT errors when checking directory', async () => {\n const permissionError = new Error('Permission denied') as NodeJS.ErrnoException\n permissionError.code = 'EACCES'\n\n mockStat.mockRejectedValueOnce(permissionError)\n\n await expect(checkDir(testDir)).rejects.toThrow('Permission denied')\n\n expect(mockStat).toHaveBeenCalledTimes(1)\n expect(mockStat).toHaveBeenCalledWith(testDir)\n })\n\n test('should throw error when index.html does not exist', async () => {\n // Mock directory exists and is a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => true,\n } as never)\n\n // Mock index.html does not exist\n const enoentError = new Error('ENOENT') as NodeJS.ErrnoException\n enoentError.code = 'ENOENT'\n mockStat.mockRejectedValueOnce(enoentError)\n\n const expectedError = [\n `\"${testDir}/index.html\" does not exist -`,\n '[SOURCE_DIR] must be a directory containing',\n 'a Sanity studio built using \"sanity build\"',\n ].join(' ')\n\n await expect(checkDir(testDir)).rejects.toThrow(expectedError)\n\n expect(mockStat).toHaveBeenCalledTimes(2)\n expect(mockStat).toHaveBeenNthCalledWith(1, testDir)\n expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'))\n })\n\n test('should re-throw non-ENOENT errors when checking index.html', async () => {\n // Mock directory exists and is a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => true,\n } as never)\n\n // Mock permission error when checking index.html\n const permissionError = new Error('Permission denied') as NodeJS.ErrnoException\n permissionError.code = 'EACCES'\n mockStat.mockRejectedValueOnce(permissionError)\n\n await expect(checkDir(testDir)).rejects.toThrow('Permission denied')\n\n expect(mockStat).toHaveBeenCalledTimes(2)\n expect(mockStat).toHaveBeenNthCalledWith(1, testDir)\n expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'))\n })\n\n test('should handle relative paths correctly', async () => {\n const relativeDir = './relative/path'\n\n // Mock directory exists and is a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => true,\n } as never)\n\n // Mock index.html exists\n mockStat.mockResolvedValueOnce({} as never)\n\n await expect(checkDir(relativeDir)).resolves.toBeUndefined()\n\n expect(mockStat).toHaveBeenCalledTimes(2)\n expect(mockStat).toHaveBeenNthCalledWith(1, relativeDir)\n expect(mockStat).toHaveBeenNthCalledWith(2, join(relativeDir, 'index.html'))\n })\n\n test('should handle errors without code property', async () => {\n // Mock error without code property when checking directory\n const genericError = new Error('Generic error')\n mockStat.mockRejectedValueOnce(genericError)\n\n await expect(checkDir(testDir)).rejects.toThrow('Generic error')\n\n expect(mockStat).toHaveBeenCalledTimes(1)\n expect(mockStat).toHaveBeenCalledWith(testDir)\n })\n\n test('should handle errors without code property when checking index.html', async () => {\n // Mock directory exists and is a directory\n mockStat.mockResolvedValueOnce({\n isDirectory: () => true,\n } as never)\n\n // Mock error without code property when checking index.html\n const genericError = new Error('Generic error')\n mockStat.mockRejectedValueOnce(genericError)\n\n await expect(checkDir(testDir)).rejects.toThrow('Generic error')\n\n expect(mockStat).toHaveBeenCalledTimes(2)\n expect(mockStat).toHaveBeenNthCalledWith(1, testDir)\n expect(mockStat).toHaveBeenNthCalledWith(2, join(testDir, 'index.html'))\n })\n})\n"],"names":["stat","join","afterEach","describe","expect","test","vi","checkDir","mock","fn","mockStat","mocked","testDir","clearAllMocks","mockResolvedValueOnce","isDirectory","resolves","toBeUndefined","toHaveBeenCalledTimes","toHaveBeenNthCalledWith","enoentError","Error","code","mockRejectedValueOnce","rejects","toThrow","toHaveBeenCalledWith","permissionError","expectedError","relativeDir","genericError"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAE5D,SAAQC,QAAQ,QAAO,iBAAgB;AAEvCD,GAAGE,IAAI,CAAC,oBAAoB,IAAO,CAAA;QACjCR,MAAMM,GAAGG,EAAE;IACb,CAAA;AAEA,MAAMC,WAAWJ,GAAGK,MAAM,CAACX;AAE3BG,SAAS,aAAa;IACpB,MAAMS,UAAU;IAEhBV,UAAU;QACRI,GAAGO,aAAa;IAClB;IAEAR,KAAK,6DAA6D;QAChE,2CAA2C;QAC3CK,SAASI,qBAAqB,CAAC;YAC7BC,aAAa,IAAM;QACrB;QAEA,yBAAyB;QACzBL,SAASI,qBAAqB,CAAC,CAAC;QAEhC,MAAMV,OAAOG,SAASK,UAAUI,QAAQ,CAACC,aAAa;QAEtDb,OAAOM,UAAUQ,qBAAqB,CAAC;QACvCd,OAAOM,UAAUS,uBAAuB,CAAC,GAAGP;QAC5CR,OAAOM,UAAUS,uBAAuB,CAAC,GAAGlB,KAAKW,SAAS;IAC5D;IAEAP,KAAK,oDAAoD;QACvD,MAAMe,cAAc,IAAIC,MAAM;QAC9BD,YAAYE,IAAI,GAAG;QAEnBZ,SAASa,qBAAqB,CAACH;QAE/B,MAAMhB,OAAOG,SAASK,U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UQ,qBAAqB,CAAC;QACvCd,OAAOM,UAAUS,uBAAuB,CAAC,GAAGP;QAC5CR,OAAOM,UAAUS,uBAAuB,CAAC,GAAGlB,KAAKW,SAAS;IAC5D;AACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { normalizeDocsPath } from '../normalizeDocsPath.js';
|
|
3
|
-
describe('#normalizeDocsPath', ()=>{
|
|
4
|
-
test('normalizes full Sanity URLs', ()=>{
|
|
5
|
-
expect(normalizeDocsPath('https://www.sanity.io/docs/studio/installation')).toBe('/docs/studio/installation');
|
|
6
|
-
});
|
|
7
|
-
test('leaves paths unchanged', ()=>{
|
|
8
|
-
expect(normalizeDocsPath('/docs/studio/installation')).toBe('/docs/studio/installation');
|
|
9
|
-
});
|
|
10
|
-
test('handles root paths', ()=>{
|
|
11
|
-
expect(normalizeDocsPath('https://www.sanity.io/')).toBe('/');
|
|
12
|
-
expect(normalizeDocsPath('/')).toBe('/');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=normalizeDocsPath.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/docs/__tests__/normalizeDocsPath.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {normalizeDocsPath} from '../normalizeDocsPath.js'\n\ndescribe('#normalizeDocsPath', () => {\n test('normalizes full Sanity URLs', () => {\n expect(normalizeDocsPath('https://www.sanity.io/docs/studio/installation')).toBe(\n '/docs/studio/installation',\n )\n })\n\n test('leaves paths unchanged', () => {\n expect(normalizeDocsPath('/docs/studio/installation')).toBe('/docs/studio/installation')\n })\n\n test('handles root paths', () => {\n expect(normalizeDocsPath('https://www.sanity.io/')).toBe('/')\n expect(normalizeDocsPath('/')).toBe('/')\n })\n})\n"],"names":["describe","expect","test","normalizeDocsPath","toBe"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,iBAAiB,QAAO,0BAAyB;AAEzDH,SAAS,sBAAsB;IAC7BE,KAAK,+BAA+B;QAClCD,OAAOE,kBAAkB,mDAAmDC,IAAI,CAC9E;IAEJ;IAEAF,KAAK,0BAA0B;QAC7BD,OAAOE,kBAAkB,8BAA8BC,IAAI,CAAC;IAC9D;IAEAF,KAAK,sBAAsB;QACzBD,OAAOE,kBAAkB,2BAA2BC,IAAI,CAAC;QACzDH,OAAOE,kBAAkB,MAAMC,IAAI,CAAC;IACtC;AACF"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { formatDocumentValidation } from '../formatDocumentValidation';
|
|
3
|
-
// disables some terminal specific things that are typically auto detected
|
|
4
|
-
vi.mock(import('node:tty'), async (importOriginal)=>{
|
|
5
|
-
const actual = await importOriginal();
|
|
6
|
-
return {
|
|
7
|
-
...actual,
|
|
8
|
-
isatty: ()=>false
|
|
9
|
-
};
|
|
10
|
-
});
|
|
11
|
-
describe('formatDocumentValidation', ()=>{
|
|
12
|
-
it('formats a set of markers in to a printed tree, sorting markers, and adding spacing', ()=>{
|
|
13
|
-
const result = formatDocumentValidation({
|
|
14
|
-
documentId: 'my-document-id',
|
|
15
|
-
documentType: 'person',
|
|
16
|
-
level: 'error',
|
|
17
|
-
markers: [
|
|
18
|
-
{
|
|
19
|
-
level: 'error',
|
|
20
|
-
message: 'Top-level marker',
|
|
21
|
-
path: []
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
level: 'error',
|
|
25
|
-
message: '2nd top-level marker',
|
|
26
|
-
path: []
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
level: 'error',
|
|
30
|
-
message: 'Property marker',
|
|
31
|
-
path: [
|
|
32
|
-
'foo'
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
level: 'error',
|
|
37
|
-
message: 'Nested marker',
|
|
38
|
-
path: [
|
|
39
|
-
'bar',
|
|
40
|
-
'title'
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
level: 'error',
|
|
45
|
-
message: '2nd nested marker',
|
|
46
|
-
path: [
|
|
47
|
-
'bar',
|
|
48
|
-
'title'
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
level: 'error',
|
|
53
|
-
message: '2nd property marker',
|
|
54
|
-
path: [
|
|
55
|
-
'baz'
|
|
56
|
-
]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
level: 'warning',
|
|
60
|
-
message: 'Warning',
|
|
61
|
-
path: [
|
|
62
|
-
'beep',
|
|
63
|
-
'boop'
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
level: 'error',
|
|
68
|
-
message: 'Errors sorted first',
|
|
69
|
-
path: [
|
|
70
|
-
'beep',
|
|
71
|
-
'boop'
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
revision: 'rev'
|
|
76
|
-
});
|
|
77
|
-
expect(result).toMatchInlineSnapshot(`
|
|
78
|
-
"[ERROR] [person] my-document-id
|
|
79
|
-
│ (root) ........................ [31m✖[39m Top-level marker
|
|
80
|
-
│ [31m✖[39m 2nd top-level marker
|
|
81
|
-
├─ foo ........................... [31m✖[39m Property marker
|
|
82
|
-
├─ bar
|
|
83
|
-
│ └─ title ....................... [31m✖[39m Nested marker
|
|
84
|
-
│ [31m✖[39m 2nd nested marker
|
|
85
|
-
├─ baz ........................... [31m✖[39m 2nd property marker
|
|
86
|
-
└─ beep
|
|
87
|
-
└─ boop ........................ [31m✖[39m Errors sorted first
|
|
88
|
-
[33m⚠[39m Warning"
|
|
89
|
-
`);
|
|
90
|
-
});
|
|
91
|
-
it('formats a set of top-level markers only (should have an elbow at first message)', ()=>{
|
|
92
|
-
const result = formatDocumentValidation({
|
|
93
|
-
documentId: 'my-document-id',
|
|
94
|
-
documentType: 'person',
|
|
95
|
-
level: 'error',
|
|
96
|
-
markers: [
|
|
97
|
-
{
|
|
98
|
-
level: 'info',
|
|
99
|
-
message: '2nd top-level marker (should come last)',
|
|
100
|
-
path: []
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
level: 'error',
|
|
104
|
-
message: 'Lone top-level marker (should get elbow)',
|
|
105
|
-
path: []
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
level: 'warning',
|
|
109
|
-
message: 'Warning, should come second',
|
|
110
|
-
path: []
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
revision: 'rev'
|
|
114
|
-
});
|
|
115
|
-
expect(result).toMatchInlineSnapshot(`
|
|
116
|
-
"[ERROR] [person] my-document-id
|
|
117
|
-
└─ (root) ........................ [31m✖[39m Lone top-level marker (should get elbow)
|
|
118
|
-
[33m⚠[39m Warning, should come second
|
|
119
|
-
[34mℹ[39m 2nd top-level marker (should come last)"
|
|
120
|
-
`);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
//# sourceMappingURL=formatDocumentValidation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/actions/documents/validation/reporters/prettyReporter/__tests__/formatDocumentValidation.test.ts"],"sourcesContent":["import {describe, expect, it, vi} from 'vitest'\n\nimport {formatDocumentValidation} from '../formatDocumentValidation'\n\n// disables some terminal specific things that are typically auto detected\nvi.mock(import('node:tty'), async (importOriginal) => {\n const actual = await importOriginal()\n return {\n ...actual,\n isatty: () => false,\n }\n})\n\ndescribe('formatDocumentValidation', () => {\n it('formats a set of markers in to a printed tree, sorting markers, and adding spacing', () => {\n const result = formatDocumentValidation({\n documentId: 'my-document-id',\n documentType: 'person',\n level: 'error',\n markers: [\n {level: 'error', message: 'Top-level marker', path: []},\n {level: 'error', message: '2nd top-level marker', path: []},\n {level: 'error', message: 'Property marker', path: ['foo']},\n {level: 'error', message: 'Nested marker', path: ['bar', 'title']},\n {level: 'error', message: '2nd nested marker', path: ['bar', 'title']},\n {level: 'error', message: '2nd property marker', path: ['baz']},\n {level: 'warning', message: 'Warning', path: ['beep', 'boop']},\n {level: 'error', message: 'Errors sorted first', path: ['beep', 'boop']},\n ],\n revision: 'rev',\n })\n\n expect(result).toMatchInlineSnapshot(\n `\n \"[ERROR] [person] my-document-id\n │ (root) ........................ \u001b[31m✖\u001b[39m Top-level marker\n │ \u001b[31m✖\u001b[39m 2nd top-level marker\n ├─ foo ........................... \u001b[31m✖\u001b[39m Property marker\n ├─ bar\n │ └─ title ....................... \u001b[31m✖\u001b[39m Nested marker\n │ \u001b[31m✖\u001b[39m 2nd nested marker\n ├─ baz ........................... \u001b[31m✖\u001b[39m 2nd property marker\n └─ beep\n └─ boop ........................ \u001b[31m✖\u001b[39m Errors sorted first\n \u001b[33m⚠\u001b[39m Warning\"\n `,\n )\n })\n\n it('formats a set of top-level markers only (should have an elbow at first message)', () => {\n const result = formatDocumentValidation({\n documentId: 'my-document-id',\n documentType: 'person',\n level: 'error',\n markers: [\n {level: 'info', message: '2nd top-level marker (should come last)', path: []},\n {level: 'error', message: 'Lone top-level marker (should get elbow)', path: []},\n {level: 'warning', message: 'Warning, should come second', path: []},\n ],\n revision: 'rev',\n })\n\n expect(result).toMatchInlineSnapshot(\n `\n \"[ERROR] [person] my-document-id\n └─ (root) ........................ \u001b[31m✖\u001b[39m Lone top-level marker (should get elbow)\n \u001b[33m⚠\u001b[39m Warning, should come second\n \u001b[34mℹ\u001b[39m 2nd top-level marker (should come last)\"\n `,\n )\n })\n})\n"],"names":["describe","expect","it","vi","formatDocumentValidation","mock","importOriginal","actual","isatty","result","documentId","documentType","level","markers","message","path","revision","toMatchInlineSnapshot"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAO,SAAQ;AAE/C,SAAQC,wBAAwB,QAAO,8BAA6B;AAEpE,0EAA0E;A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