@payloadcms/ui 4.0.0-canary.34 → 4.0.0-canary.36
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/dist/css/app.css +1 -0
- package/dist/css/preflight.css +1 -0
- package/dist/css/spacing.css +3 -0
- package/dist/elements/AppHeader/index.css +3 -0
- package/dist/elements/BulkUpload/ActionsBar/index.css +1 -0
- package/dist/elements/BulkUpload/AddingFilesView/index.css +2 -4
- package/dist/elements/BulkUpload/FileSidebar/index.css +1 -0
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +12 -7
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/BulkUpload/index.css +2 -0
- package/dist/elements/Collapsible/index.css +1 -0
- package/dist/elements/DatePicker/index.css +2 -0
- package/dist/elements/Dialog/index.css +1 -0
- package/dist/elements/DocumentControls/index.css +1 -0
- package/dist/elements/DocumentFields/index.css +2 -0
- package/dist/elements/DocumentHeader/Tabs/index.css +1 -0
- package/dist/elements/DocumentHeader/index.css +1 -0
- package/dist/elements/EditUpload/index.css +1 -1
- package/dist/elements/FieldDiffContainer/index.css +1 -0
- package/dist/elements/FieldDiffLabel/index.css +1 -0
- package/dist/elements/FileDetails/StaticFileDetails/index.css +2 -0
- package/dist/elements/HTMLDiff/index.css +1 -0
- package/dist/elements/ItemsDrawer/index.css +3 -0
- package/dist/elements/ListControls/index.css +1 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +7 -1
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/types.d.ts +3 -1
- package/dist/elements/ListControls/types.d.ts.map +1 -1
- package/dist/elements/ListControls/types.js.map +1 -1
- package/dist/elements/ListControlsBar/index.css +1 -0
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js +1 -1
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.css +1 -0
- package/dist/elements/Nav/index.css +2 -0
- package/dist/elements/PageControls/index.css +1 -0
- package/dist/elements/PillSelector/index.css +1 -0
- package/dist/elements/PreviewSizes/index.css +2 -0
- package/dist/elements/PublishButton/index.css +1 -0
- package/dist/elements/QueryPresets/fields/Heading/index.css +1 -0
- package/dist/elements/RenderTitle/index.css +1 -0
- package/dist/elements/Table/index.css +1 -0
- package/dist/elements/TableSection/index.css +1 -0
- package/dist/elements/Tabs/index.css +1 -0
- package/dist/elements/Thumbnail/index.css +1 -0
- package/dist/elements/TimezonePicker/index.css +1 -0
- package/dist/elements/Tooltip/index.css +7 -0
- package/dist/elements/WhereBuilder/Condition/index.css +1 -0
- package/dist/elements/WhereBuilder/index.css +2 -0
- package/dist/fields/Array/index.css +1 -0
- package/dist/fields/Blocks/index.css +1 -0
- package/dist/fields/Group/index.css +1 -0
- package/dist/fields/Row/index.css +2 -0
- package/dist/fields/Tabs/index.css +1 -0
- package/dist/forms/RenderFields/index.css +1 -0
- package/dist/hooks/useControllableState.js +3 -3
- package/dist/hooks/useControllableState.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +30 -19
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +6 -7
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/styles.css +5 -1
- package/dist/templates/Default/Wrapper/index.css +2 -0
- package/dist/templates/Default/index.css +1 -0
- package/dist/utilities/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/handleAuthRedirect.js +4 -1
- package/dist/utilities/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/isPathMatchingRoute.d.ts.map +1 -1
- package/dist/utilities/isPathMatchingRoute.js +7 -5
- package/dist/utilities/isPathMatchingRoute.js.map +1 -1
- package/dist/views/API/index.css +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +2 -0
- package/dist/views/Edit/index.css +1 -0
- package/dist/views/HierarchyList/HierarchyTable/SlotTable.css +1 -0
- package/dist/views/HierarchyList/index.css +1 -0
- package/dist/views/List/ListHeader/index.css +1 -0
- package/dist/views/List/ListHeader/index.d.ts +0 -1
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +2 -6
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +3 -2
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +2 -0
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +26 -19
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Version/Default/index.css +2 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.css +8 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.css +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.css +1 -0
- package/dist/views/Version/RenderFieldsToDiff/index.css +2 -0
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +9 -6
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Versions/VersionPillLabel/index.css +1 -0
- package/dist/views/Versions/index.css +1 -0
- package/dist/widgets/CollectionCards/index.css +4 -0
- package/package.json +5 -5
- package/dist/elements/ClipboardAction/clipboardUtilities.spec.js +0 -120
- package/dist/elements/ClipboardAction/clipboardUtilities.spec.js.map +0 -1
- package/dist/elements/ClipboardAction/isClipboardDataValid.spec.js +0 -144
- package/dist/elements/ClipboardAction/isClipboardDataValid.spec.js.map +0 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js +0 -885
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js.map +0 -1
- package/dist/elements/ColumnSelection/matchesColumnSearch.spec.js +0 -87
- package/dist/elements/ColumnSelection/matchesColumnSearch.spec.js.map +0 -1
- package/dist/elements/CommandPalette/buildActions.spec.js +0 -158
- package/dist/elements/CommandPalette/buildActions.spec.js.map +0 -1
- package/dist/elements/CommandPalette/highlightLabel.spec.js +0 -78
- package/dist/elements/CommandPalette/highlightLabel.spec.js.map +0 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.spec.js +0 -143
- package/dist/elements/FieldSelect/reduceFieldOptions.spec.js.map +0 -1
- package/dist/elements/Toasts/fieldErrors.spec.js +0 -46
- package/dist/elements/Toasts/fieldErrors.spec.js.map +0 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/optionsReducer.spec.js +0 -152
- package/dist/elements/WhereBuilder/Condition/Relationship/optionsReducer.spec.js.map +0 -1
- package/dist/elements/WhereBuilder/conditionValue.spec.js +0 -65
- package/dist/elements/WhereBuilder/conditionValue.spec.js.map +0 -1
- package/dist/fields/Upload/Input.spec.js +0 -242
- package/dist/fields/Upload/Input.spec.js.map +0 -1
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.d.ts +0 -2
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.d.ts.map +0 -1
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.js +0 -67
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.js.map +0 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js +0 -150
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js.map +0 -1
- package/dist/layouts/Root/index.spec.js +0 -20
- package/dist/layouts/Root/index.spec.js.map +0 -1
- package/dist/providers/Auth/authSessionRequests.spec.js +0 -121
- package/dist/providers/Auth/authSessionRequests.spec.js.map +0 -1
- package/dist/providers/Auth/sessionActivity.spec.js +0 -44
- package/dist/providers/Auth/sessionActivity.spec.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/index.spec.js +0 -463
- package/dist/providers/Auth/tabSessionSync/index.spec.js.map +0 -1
- package/dist/providers/Auth/useAuthSessionTimers.spec.js +0 -311
- package/dist/providers/Auth/useAuthSessionTimers.spec.js.map +0 -1
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js +0 -44
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js.map +0 -1
- package/dist/providers/TableColumns/buildColumnState/index.spec.js +0 -40
- package/dist/providers/TableColumns/buildColumnState/index.spec.js.map +0 -1
- package/dist/utilities/appendCacheTag.spec.js +0 -34
- package/dist/utilities/appendCacheTag.spec.js.map +0 -1
- package/dist/utilities/formatAbsoluteURL.spec.js +0 -27
- package/dist/utilities/formatAbsoluteURL.spec.js.map +0 -1
- package/dist/utilities/formatMetadata.spec.js +0 -83
- package/dist/utilities/formatMetadata.spec.js.map +0 -1
- package/dist/utilities/fuzzyMatch.spec.js +0 -38
- package/dist/utilities/fuzzyMatch.spec.js.map +0 -1
- package/dist/utilities/initReq.spec.js +0 -226
- package/dist/utilities/initReq.spec.js.map +0 -1
- package/dist/utilities/isAbsoluteURL.spec.js +0 -11
- package/dist/utilities/isAbsoluteURL.spec.js.map +0 -1
- package/dist/utilities/isCustomAdminView.spec.js +0 -90
- package/dist/utilities/isCustomAdminView.spec.js.map +0 -1
- package/dist/utilities/isHttpURL.spec.js +0 -25
- package/dist/utilities/isHttpURL.spec.js.map +0 -1
- package/dist/utilities/isPathMatchingRoute.spec.js +0 -178
- package/dist/utilities/isPathMatchingRoute.spec.js.map +0 -1
- package/dist/utilities/isPublicAdminRoute.spec.js +0 -34
- package/dist/utilities/isPublicAdminRoute.spec.js.map +0 -1
- package/dist/utilities/normalizeRelationshipValue.spec.js +0 -373
- package/dist/utilities/normalizeRelationshipValue.spec.js.map +0 -1
- package/dist/utilities/recentlyViewed.spec.js +0 -92
- package/dist/utilities/recentlyViewed.spec.js.map +0 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.spec.js +0 -168
- package/dist/views/Root/getCustomCollectionViewByRoute.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js +0 -258
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +0 -915
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +0 -47
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +0 -125
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +0 -1
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js +0 -100
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeFormStateFromClipboard.spec.js","names":["ObjectIdImport","describe","expect","it","mergeFormStateFromClipboard","reduceFormStateByPath","ObjectId","default","copiedBlockID","toHexString","formState","layout","valid","value","initialValue","rows","clipboardData","type","path","blocks","data","rowIndex","result","dataFromClipboard","toBeDefined","not","toEqual","isValid","toBe","toHaveLength","id","copiedNestedBlockID","duplicate","copiedArrayItemID1","copiedArrayItemID2","copiedArrayItemID3","targetBlockID","ctas","blockType","isLoading","copiedArrayID","items","fields","copiedNestedArrayID","disableSort","children","Array","from","length","filtered","filteredKeys","Object","keys","sort","toBeUndefined","childrenOther","sourceID","sourceBlockID"],"sources":["../../../src/elements/ClipboardAction/mergeFormStateFromClipboard.spec.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { describe, expect, it } from 'vitest'\n\nimport {\n mergeFormStateFromClipboard,\n reduceFormStateByPath,\n} from './mergeFormStateFromClipboard.js'\nimport type { ClipboardPasteData } from './types.js'\n\nconst ObjectId = (\n 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n) as typeof ObjectIdImport\n\ndescribe('mergeFormStateFromClipboard', () => {\n describe('block ID regeneration', () => {\n it('should generate new IDs when pasting blocks to prevent duplicates', () => {\n const copiedBlockID = new ObjectId().toHexString()\n\n const formState: FormState = {\n layout: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'blocks',\n path: 'layout',\n blocks: [],\n data: {\n 'layout.0.id': {\n value: copiedBlockID,\n valid: true,\n },\n 'layout.0.blockType': {\n value: 'content',\n valid: true,\n },\n 'layout.0.text': {\n value: 'test content',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'layout',\n })\n\n // Check that a new ID was generated\n expect(result['layout.0.id']).toBeDefined()\n expect(result['layout.0.id'].value).toBeDefined()\n expect(result['layout.0.id'].value).not.toEqual(copiedBlockID)\n expect(ObjectId.isValid(result['layout.0.id'].value as string)).toBe(true)\n\n // Check that the row metadata also has the new ID\n expect(result.layout.rows).toHaveLength(1)\n expect(result.layout.rows?.[0]?.id).not.toEqual(copiedBlockID)\n expect(result.layout.rows?.[0]?.id).toEqual(result['layout.0.id'].value)\n })\n\n it('should generate new IDs for nested blocks', () => {\n const copiedBlockID = new ObjectId().toHexString()\n const copiedNestedBlockID = new ObjectId().toHexString()\n\n const formState: FormState = {\n layout: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'blocks',\n path: 'layout',\n blocks: [],\n data: {\n 'layout.0.id': {\n value: copiedBlockID,\n valid: true,\n },\n 'layout.0.blockType': {\n value: 'container',\n valid: true,\n },\n 'layout.0.subBlocks': {\n value: 1,\n valid: true,\n rows: [{ id: copiedNestedBlockID }],\n },\n 'layout.0.subBlocks.0.id': {\n value: copiedNestedBlockID,\n valid: true,\n },\n 'layout.0.subBlocks.0.blockType': {\n value: 'content',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'layout',\n })\n\n // Check that parent block got new ID\n expect(result['layout.0.id'].value).not.toEqual(copiedBlockID)\n expect(ObjectId.isValid(result['layout.0.id'].value as string)).toBe(true)\n\n // Check that nested block got new ID\n expect(result['layout.0.subBlocks.0.id'].value).not.toEqual(copiedNestedBlockID)\n expect(ObjectId.isValid(result['layout.0.subBlocks.0.id'].value as string)).toBe(true)\n\n // Check that parent and nested IDs are different\n expect(result['layout.0.id'].value).not.toEqual(result['layout.0.subBlocks.0.id'].value)\n\n // Check that parent row metadata has new ID\n expect(result.layout.rows?.[0]?.id).toEqual(result['layout.0.id'].value)\n\n // Check that nested row metadata has new ID\n expect(result['layout.0.subBlocks'].rows?.[0]?.id).toEqual(\n result['layout.0.subBlocks.0.id'].value,\n )\n })\n\n it('should preserve non-ID field values when pasting', () => {\n const copiedBlockID = new ObjectId().toHexString()\n\n const formState: FormState = {\n layout: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'blocks',\n path: 'layout',\n blocks: [],\n data: {\n 'layout.0.id': {\n value: copiedBlockID,\n valid: true,\n },\n 'layout.0.blockType': {\n value: 'content',\n valid: true,\n },\n 'layout.0.text': {\n value: 'preserved text content',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'layout',\n })\n\n // Non-ID fields should be preserved\n expect(result['layout.0.blockType'].value).toEqual('content')\n expect(result['layout.0.text'].value).toEqual('preserved text content')\n })\n\n it('should generate new ID when pasting from row to field', () => {\n const copiedBlockID = new ObjectId().toHexString()\n\n const formState: FormState = {\n duplicate: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n // Simulating copying from blocks.1 and pasting into duplicate field\n const clipboardData = {\n type: 'blocks' as const,\n path: 'blocks',\n blocks: [],\n data: {\n 'blocks.1.id': {\n value: copiedBlockID,\n valid: true,\n },\n 'blocks.1.blockType': {\n value: 'number',\n valid: true,\n },\n 'blocks.1.number': {\n value: 342,\n valid: true,\n },\n },\n rowIndex: 1,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'duplicate',\n })\n\n // Check that a new ID was generated\n expect(result['duplicate.0.id']).toBeDefined()\n expect(result['duplicate.0.id'].value).toBeDefined()\n expect(result['duplicate.0.id'].value).not.toEqual(copiedBlockID)\n expect(ObjectId.isValid(result['duplicate.0.id'].value as string)).toBe(true)\n\n // Check that the row metadata has the new ID (not the copied ID)\n expect(result.duplicate.rows).toBeDefined()\n expect(result.duplicate.rows).toHaveLength(1)\n expect(result.duplicate.rows![0].id).not.toEqual(copiedBlockID)\n expect(result.duplicate.rows![0].id).toEqual(result['duplicate.0.id'].value)\n\n // Check that other fields were preserved\n expect(result['duplicate.0.number'].value).toEqual(342)\n })\n })\n\n describe('block row paste with nested array', () => {\n it('should regenerate nested array item IDs when pasting a block row', () => {\n const copiedBlockID = new ObjectId().toHexString()\n const copiedArrayItemID1 = new ObjectId().toHexString()\n const copiedArrayItemID2 = new ObjectId().toHexString()\n const copiedArrayItemID3 = new ObjectId().toHexString()\n const targetBlockID = new ObjectId().toHexString()\n\n // Target form state: block at index 1 with empty buttons array\n const formState: FormState = {\n ctas: {\n valid: true,\n value: 2,\n initialValue: 2,\n rows: [\n { id: copiedBlockID, blockType: 'callToAction', isLoading: false },\n { id: targetBlockID, blockType: 'callToAction', isLoading: false },\n ],\n },\n 'ctas.0': { value: 'callToAction', valid: true },\n 'ctas.0.id': { value: copiedBlockID, valid: true },\n 'ctas.0.buttons': {\n valid: true,\n value: 3,\n rows: [\n { id: copiedArrayItemID1, isLoading: false },\n { id: copiedArrayItemID2, isLoading: false },\n { id: copiedArrayItemID3, isLoading: false },\n ],\n },\n 'ctas.0.buttons.0.id': { value: copiedArrayItemID1, valid: true },\n 'ctas.0.buttons.1.id': { value: copiedArrayItemID2, valid: true },\n 'ctas.0.buttons.2.id': { value: copiedArrayItemID3, valid: true },\n 'ctas.1': { value: 'callToAction', valid: true },\n 'ctas.1.id': { value: targetBlockID, valid: true },\n 'ctas.1.buttons': {\n valid: true,\n value: 0,\n rows: [],\n },\n }\n\n // Clipboard: block row 0 (source) with 3 buttons\n const clipboardData: ClipboardPasteData = {\n type: 'blocks',\n path: 'ctas',\n blocks: [],\n rowIndex: 0,\n data: {\n 'ctas.0': { value: 'callToAction', valid: true },\n 'ctas.0.id': { value: copiedBlockID, valid: true },\n 'ctas.0.buttons': {\n valid: true,\n value: 3,\n rows: [\n { id: copiedArrayItemID1, isLoading: false },\n { id: copiedArrayItemID2, isLoading: false },\n { id: copiedArrayItemID3, isLoading: false },\n ],\n },\n 'ctas.0.buttons.0.id': { value: copiedArrayItemID1, valid: true },\n 'ctas.0.buttons.0.label': { value: 'Button 1', valid: true },\n 'ctas.0.buttons.1.id': { value: copiedArrayItemID2, valid: true },\n 'ctas.0.buttons.1.label': { value: 'Button 2', valid: true },\n 'ctas.0.buttons.2.id': { value: copiedArrayItemID3, valid: true },\n 'ctas.0.buttons.2.label': { value: 'Button 3', valid: true },\n },\n }\n\n // Paste into block row 1 (target)\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'ctas',\n rowIndex: 1,\n })\n\n // Target block ID should NOT be overwritten\n expect(result['ctas.1.id'].value).toEqual(targetBlockID)\n\n // Nested array items should have NEW IDs (not the source IDs)\n expect(result['ctas.1.buttons.0.id']).toBeDefined()\n expect(result['ctas.1.buttons.0.id'].value).not.toEqual(copiedArrayItemID1)\n expect(ObjectId.isValid(result['ctas.1.buttons.0.id'].value as string)).toBe(true)\n\n expect(result['ctas.1.buttons.1.id']).toBeDefined()\n expect(result['ctas.1.buttons.1.id'].value).not.toEqual(copiedArrayItemID2)\n\n expect(result['ctas.1.buttons.2.id']).toBeDefined()\n expect(result['ctas.1.buttons.2.id'].value).not.toEqual(copiedArrayItemID3)\n\n // The rows metadata in ctas.1.buttons should have the new IDs\n expect(result['ctas.1.buttons'].rows).toHaveLength(3)\n expect(result['ctas.1.buttons'].rows![0].id).toEqual(result['ctas.1.buttons.0.id'].value)\n expect(result['ctas.1.buttons'].rows![1].id).toEqual(result['ctas.1.buttons.1.id'].value)\n expect(result['ctas.1.buttons'].rows![2].id).toEqual(result['ctas.1.buttons.2.id'].value)\n\n // Field values should be copied\n expect(result['ctas.1.buttons.0.label'].value).toEqual('Button 1')\n expect(result['ctas.1.buttons.1.label'].value).toEqual('Button 2')\n expect(result['ctas.1.buttons.2.label'].value).toEqual('Button 3')\n\n // Source block should be untouched\n expect(result['ctas.0.id'].value).toEqual(copiedBlockID)\n expect(result['ctas.0.buttons'].rows).toHaveLength(3)\n })\n })\n\n describe('array ID regeneration', () => {\n it('should generate new IDs when pasting arrays to prevent duplicates', () => {\n const copiedArrayID = new ObjectId().toHexString()\n\n const formState: FormState = {\n items: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'array',\n path: 'items',\n fields: [],\n data: {\n 'items.0.id': {\n value: copiedArrayID,\n valid: true,\n },\n 'items.0.text': {\n value: 'test content',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'items',\n })\n\n // Check that a new ID was generated\n expect(result['items.0.id']).toBeDefined()\n expect(result['items.0.id'].value).toBeDefined()\n expect(result['items.0.id'].value).not.toEqual(copiedArrayID)\n expect(ObjectId.isValid(result['items.0.id'].value as string)).toBe(true)\n\n // Check that the row metadata also has the new ID\n expect(result.items.rows).toHaveLength(1)\n expect(result.items.rows?.[0]?.id).not.toEqual(copiedArrayID)\n expect(result.items.rows?.[0]?.id).toEqual(result['items.0.id'].value)\n })\n\n it('should generate new IDs for nested arrays', () => {\n const copiedArrayID = new ObjectId().toHexString()\n const copiedNestedArrayID = new ObjectId().toHexString()\n\n const formState: FormState = {\n items: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'array',\n path: 'items',\n fields: [],\n data: {\n 'items.0.id': {\n value: copiedArrayID,\n valid: true,\n },\n 'items.0.text': {\n value: 'parent array',\n valid: true,\n },\n 'items.0.subArray': {\n value: 1,\n valid: true,\n rows: [{ id: copiedNestedArrayID }],\n },\n 'items.0.subArray.0.id': {\n value: copiedNestedArrayID,\n valid: true,\n },\n 'items.0.subArray.0.text': {\n value: 'nested array',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'items',\n })\n\n // Check that parent array got new ID\n expect(result['items.0.id'].value).not.toEqual(copiedArrayID)\n expect(ObjectId.isValid(result['items.0.id'].value as string)).toBe(true)\n\n // Check that nested array got new ID\n expect(result['items.0.subArray.0.id'].value).not.toEqual(copiedNestedArrayID)\n expect(ObjectId.isValid(result['items.0.subArray.0.id'].value as string)).toBe(true)\n\n // Check that parent and nested IDs are different\n expect(result['items.0.id'].value).not.toEqual(result['items.0.subArray.0.id'].value)\n\n // Check that parent row metadata has new ID\n expect(result.items.rows?.[0]?.id).toEqual(result['items.0.id'].value)\n\n // Check that nested row metadata has new ID\n expect(result['items.0.subArray'].rows?.[0]?.id).toEqual(\n result['items.0.subArray.0.id'].value,\n )\n })\n\n it('should preserve non-ID field values when pasting arrays', () => {\n const copiedArrayID = new ObjectId().toHexString()\n\n const formState: FormState = {\n items: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'array',\n path: 'items',\n fields: [],\n data: {\n 'items.0.id': {\n value: copiedArrayID,\n valid: true,\n },\n 'items.0.text': {\n value: 'preserved array text',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'items',\n })\n\n // Non-ID fields should be preserved\n expect(result['items.0.text'].value).toEqual('preserved array text')\n })\n\n it('should generate new ID when pasting from array row to field', () => {\n const copiedArrayID = new ObjectId().toHexString()\n\n const formState: FormState = {\n disableSort: {\n valid: true,\n value: 0,\n initialValue: 0,\n rows: [],\n },\n }\n\n // Simulating copying from items.0 and pasting into disableSort field\n const clipboardData = {\n type: 'array' as const,\n path: 'items',\n fields: [],\n data: {\n 'items.0.id': {\n value: copiedArrayID,\n valid: true,\n },\n 'items.0.text': {\n value: 'row one',\n valid: true,\n },\n },\n rowIndex: 0,\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'disableSort',\n })\n\n // Check that a new ID was generated\n expect(result['disableSort.0.id']).toBeDefined()\n expect(result['disableSort.0.id'].value).toBeDefined()\n expect(result['disableSort.0.id'].value).not.toEqual(copiedArrayID)\n expect(ObjectId.isValid(result['disableSort.0.id'].value as string)).toBe(true)\n\n // Check that the row metadata has the new ID (not the copied ID)\n expect(result.disableSort.rows).toBeDefined()\n expect(result.disableSort.rows).toHaveLength(1)\n expect(result.disableSort.rows![0].id).not.toEqual(copiedArrayID)\n expect(result.disableSort.rows![0].id).toEqual(result['disableSort.0.id'].value)\n\n // Check that other fields were preserved\n expect(result['disableSort.0.text'].value).toEqual('row one')\n })\n })\n\n describe('prefix collision with multi-digit sibling indices', () => {\n it('reduceFormStateByPath should not leak siblings whose indices share a digit prefix', () => {\n // Array with 13 rows. Copying row 1 must filter out rows 10/11/12, whose\n // paths all begin with the substring `children.1`.\n const formState: FormState = {\n children: {\n valid: true,\n value: 13,\n rows: Array.from({ length: 13 }, () => ({ isLoading: false })),\n },\n 'children.1.id': { value: 'id-1', valid: true },\n 'children.1.title': { value: 'Row 1', valid: true },\n 'children.10.id': { value: 'id-10', valid: true },\n 'children.10.title': { value: 'Row 10', valid: true },\n 'children.11.id': { value: 'id-11', valid: true },\n 'children.11.title': { value: 'Row 11', valid: true },\n 'children.12.id': { value: 'id-12', valid: true },\n 'children.12.title': { value: 'Row 12', valid: true },\n }\n\n const filtered = reduceFormStateByPath({\n formState,\n path: 'children',\n rowIndex: 1,\n })\n\n const filteredKeys = Object.keys(filtered).sort()\n expect(filteredKeys).toEqual(['children.1.id', 'children.1.title'])\n expect(filtered['children.10.id']).toBeUndefined()\n expect(filtered['children.11.id']).toBeUndefined()\n expect(filtered['children.12.id']).toBeUndefined()\n })\n\n it('reduceFormStateByPath should not leak field-name siblings sharing a textual prefix', () => {\n // `children` vs `childrenOther`: loose prefix matching pulls the wrong field's state.\n const formState: FormState = {\n children: { valid: true, value: 1, rows: [{ isLoading: false }] },\n 'children.0.id': { value: 'children-row', valid: true },\n childrenOther: { valid: true, value: 1, rows: [{ isLoading: false }] },\n 'childrenOther.0.id': { value: 'other-row', valid: true },\n }\n\n const filtered = reduceFormStateByPath({ formState, path: 'children' })\n\n // The field's own key carries `rows` and `value`, so it must survive the filter.\n expect(filtered.children).toBeDefined()\n expect(filtered['children.0.id']).toBeDefined()\n expect(filtered.childrenOther).toBeUndefined()\n expect(filtered['childrenOther.0.id']).toBeUndefined()\n })\n\n it('paste should not create out-of-bounds rows from a leaked clipboard payload', () => {\n // Simulates the end-to-end Copy/Paste flow against an array with 13 rows. Even if a\n // pre-fix clipboard leaked sibling rows (.10/.11/.12) when copying row 1, the merge\n // filter must drop them rather than rewriting them to .50/.51/.52 when pasting into\n // row 5.\n const formState: FormState = {\n children: {\n valid: true,\n value: 13,\n rows: Array.from({ length: 13 }, () => ({\n id: new ObjectId().toHexString(),\n isLoading: false,\n })),\n },\n 'children.5.id': { value: new ObjectId().toHexString(), valid: true },\n }\n\n const sourceID = new ObjectId().toHexString()\n const clipboardData: ClipboardPasteData = {\n type: 'array',\n path: 'children',\n fields: [],\n rowIndex: 1,\n data: {\n 'children.1.id': { value: sourceID, valid: true },\n 'children.1.title': { value: 'Row 1 title', valid: true },\n // Leaked siblings — these must be dropped, not rewritten to .50/.51/.52.\n 'children.10.id': { value: new ObjectId().toHexString(), valid: true },\n 'children.10.title': { value: 'Leaked Row 10', valid: true },\n 'children.11.id': { value: new ObjectId().toHexString(), valid: true },\n 'children.11.title': { value: 'Leaked Row 11', valid: true },\n 'children.12.id': { value: new ObjectId().toHexString(), valid: true },\n 'children.12.title': { value: 'Leaked Row 12', valid: true },\n },\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'children',\n rowIndex: 5,\n })\n\n // Target row populated from the source row.\n expect(result['children.5.title']?.value).toEqual('Row 1 title')\n\n // No phantom out-of-bounds rows. These would correspond to `.10`/`.11`/`.12` being\n // rewritten through `String.replace('children.1', 'children.5')`.\n expect(result['children.50']).toBeUndefined()\n expect(result['children.51']).toBeUndefined()\n expect(result['children.52']).toBeUndefined()\n expect(result['children.50.id']).toBeUndefined()\n expect(result['children.51.id']).toBeUndefined()\n expect(result['children.52.id']).toBeUndefined()\n expect(result['children.50.title']).toBeUndefined()\n expect(result['children.51.title']).toBeUndefined()\n expect(result['children.52.title']).toBeUndefined()\n })\n\n it('row-to-field cleanup should not delete unrelated fields with a textual prefix collision', () => {\n // `path` = 'children', `lastRenderedPath` = 'children.0'. A sibling field\n // `childrenOther.0.title` must NOT be deleted by the cleanup loop.\n const formState: FormState = {\n children: { valid: true, value: 0, rows: [{ isLoading: false }] },\n 'children.0.id': { value: new ObjectId().toHexString(), valid: true },\n childrenOther: { valid: true, value: 1, rows: [{ isLoading: false }] },\n 'childrenOther.0.id': { value: new ObjectId().toHexString(), valid: true },\n 'childrenOther.0.title': { value: 'Unrelated field', valid: true },\n }\n\n const sourceID = new ObjectId().toHexString()\n const clipboardData: ClipboardPasteData = {\n type: 'array',\n path: 'someOtherArray',\n fields: [],\n rowIndex: 0,\n data: {\n 'someOtherArray.0.id': { value: sourceID, valid: true },\n 'someOtherArray.0.title': { value: 'Pasted row', valid: true },\n },\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'children',\n })\n\n // Unrelated `childrenOther.*` paths survive the cleanup.\n expect(result.childrenOther).toBeDefined()\n expect(result['childrenOther.0.id']).toBeDefined()\n expect(result['childrenOther.0.title']?.value).toEqual('Unrelated field')\n })\n })\n\n describe('exact path matches', () => {\n // Blocks store the block type under the row key itself (`ctas.1`), with no trailing\n // segment. Tightening the prefix check must keep matching that exact key, otherwise\n // copy drops the block type and paste never restores it.\n it('reduceFormStateByPath should keep the exact row key while filtering digit-prefix siblings', () => {\n const formState: FormState = {\n ctas: {\n valid: true,\n value: 13,\n rows: Array.from({ length: 13 }, () => ({\n blockType: 'callToAction',\n isLoading: false,\n })),\n },\n 'ctas.1': { value: 'callToAction', valid: true },\n 'ctas.1.id': { value: 'id-1', valid: true },\n 'ctas.10': { value: 'callToAction', valid: true },\n 'ctas.10.id': { value: 'id-10', valid: true },\n 'ctas.11': { value: 'callToAction', valid: true },\n 'ctas.11.id': { value: 'id-11', valid: true },\n }\n\n const filtered = reduceFormStateByPath({ formState, path: 'ctas', rowIndex: 1 })\n\n const filteredKeys = Object.keys(filtered).sort()\n expect(filteredKeys).toEqual(['ctas.1', 'ctas.1.id'])\n expect(filtered['ctas.1']?.value).toEqual('callToAction')\n })\n\n it('paste should copy the exact row key across to the target row', () => {\n const sourceBlockID = new ObjectId().toHexString()\n const targetBlockID = new ObjectId().toHexString()\n\n const formState: FormState = {\n ctas: {\n valid: true,\n value: 2,\n initialValue: 2,\n rows: [\n { id: sourceBlockID, blockType: 'callToAction', isLoading: false },\n { id: targetBlockID, blockType: 'content', isLoading: false },\n ],\n },\n 'ctas.1': { value: 'content', valid: true },\n 'ctas.1.id': { value: targetBlockID, valid: true },\n }\n\n const clipboardData: ClipboardPasteData = {\n type: 'blocks',\n path: 'ctas',\n blocks: [],\n rowIndex: 0,\n data: {\n 'ctas.0': { value: 'callToAction', valid: true },\n 'ctas.0.id': { value: sourceBlockID, valid: true },\n 'ctas.0.label': { value: 'Source label', valid: true },\n },\n }\n\n const result = mergeFormStateFromClipboard({\n dataFromClipboard: clipboardData,\n formState,\n path: 'ctas',\n rowIndex: 1,\n })\n\n // The block type lives at the exact row key, so pasting must overwrite it.\n expect(result['ctas.1']?.value).toEqual('callToAction')\n expect(result['ctas.1.label']?.value).toEqual('Source label')\n })\n })\n})\n"],"mappings":"AAEA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SACEC,2BAA2B,EAC3BC,qBAAqB,QAChB;AAGP,MAAMC,QAAA,GACJ,aAAaN,cAAA,GAAiBA,cAAA,CAAeO,OAAO,GAAGP,cAAA;AAGzDC,QAAA,CAAS,+BAA+B;EACtCA,QAAA,CAAS,yBAAyB;IAChCE,EAAA,CAAG,qEAAqE;MACtE,MAAMK,aAAA,GAAgB,IAAIF,QAAA,GAAWG,WAAW;MAEhD,MAAMC,SAAA,GAAuB;QAC3BC,MAAA,EAAQ;UACNC,KAAA,EAAO;UACPC,KAAA,EAAO;UACPC,YAAA,EAAc;UACdC,IAAA,EAAM;QACR;MACF;MAEA,MAAMC,aAAA,GAAoC;QACxCC,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQ,EAAE;QACVC,IAAA,EAAM;UACJ,eAAe;YACbP,KAAA,EAAOL,aAAA;YACPI,KAAA,EAAO;UACT;UACA,sBAAsB;YACpBC,KAAA,EAAO;YACPD,KAAA,EAAO;UACT;UACA,iBAAiB;YACfC,KAAA,EAAO;YACPD,KAAA,EAAO;UACT;QACF;QACAS,QAAA,EAAU;MACZ;MAEA,MAAMC,MAAA,GAASlB,2BAAA,CAA4B;QACzCmB,iBAAA,EAAmBP,aAAA;QACnBN,SAAA;QACAQ,IAAA,EAAM;MACR;MAEA;MACAhB,MAAA,CAAOoB,MAAM,CAAC,cAAc,EAAEE,WAAW;MACzCtB,MAAA,CAAOoB,MAAM,CAAC,cAAc,CAACT,KAAK,EAA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EAAA,EAAIM,aAAA;YAAeE,SAAA,EAAW;YAAWC,SAAA,EAAW;UAAM;QAEhE;QACA,UAAU;UAAE1B,KAAA,EAAO;UAAWD,KAAA,EAAO;QAAK;QAC1C,aAAa;UAAEC,KAAA,EAAOuB,aAAA;UAAexB,KAAA,EAAO;QAAK;MACnD;MAEA,MAAMI,aAAA,GAAoC;QACxCC,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQ,EAAE;QACVE,QAAA,EAAU;QACVD,IAAA,EAAM;UACJ,UAAU;YAAEP,KAAA,EAAO;YAAgBD,KAAA,EAAO;UAAK;UAC/C,aAAa;YAAEC,KAAA,EAAO4C,aAAA;YAAe7C,KAAA,EAAO;UAAK;UACjD,gBAAgB;YAAEC,KAAA,EAAO;YAAgBD,KAAA,EAAO;UAAK;QACvD;MACF;MAEA,MAAMU,MAAA,GAASlB,2BAAA,CAA4B;QACzCmB,iBAAA,EAAmBP,aAAA;QACnBN,SAAA;QACAQ,IAAA,EAAM;QACNG,QAAA,EAAU;MACZ;MAEA;MACAnB,MAAA,CAAOoB,MAAM,CAAC,SAAS,EAAET,KAAA,EAAOa,OAAO,CAAC;MACxCxB,MAAA,CAAOoB,MAAM,CAAC,eAAe,EAAET,KAAA,EAAOa,OAAO,CAAC;IAChD;EACF;AACF","ignoreList":[]}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { matchesColumnSearch } from './matchesColumnSearch.js';
|
|
3
|
-
describe('matchesColumnSearch', () => {
|
|
4
|
-
it('matches everything when the query is empty', () => {
|
|
5
|
-
expect(matchesColumnSearch({
|
|
6
|
-
labelText: 'Published Date',
|
|
7
|
-
query: ''
|
|
8
|
-
})).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
it('matches everything when the query is only whitespace', () => {
|
|
11
|
-
expect(matchesColumnSearch({
|
|
12
|
-
labelText: 'Published Date',
|
|
13
|
-
query: ' '
|
|
14
|
-
})).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
describe('single-character queries', () => {
|
|
17
|
-
it('matches the start of the label', () => {
|
|
18
|
-
expect(matchesColumnSearch({
|
|
19
|
-
labelText: 'Published Date',
|
|
20
|
-
query: 'p'
|
|
21
|
-
})).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
it('matches the start of a later word', () => {
|
|
24
|
-
expect(matchesColumnSearch({
|
|
25
|
-
labelText: 'Published Date',
|
|
26
|
-
query: 'd'
|
|
27
|
-
})).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
it('matches the start of a word after a nested-label separator', () => {
|
|
30
|
-
expect(matchesColumnSearch({
|
|
31
|
-
labelText: 'Meta > Title',
|
|
32
|
-
query: 't'
|
|
33
|
-
})).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
it('is case-insensitive', () => {
|
|
36
|
-
expect(matchesColumnSearch({
|
|
37
|
-
labelText: 'Published Date',
|
|
38
|
-
query: 'P'
|
|
39
|
-
})).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
it('does not match a character in the middle of a word', () => {
|
|
42
|
-
expect(matchesColumnSearch({
|
|
43
|
-
labelText: 'Published Date',
|
|
44
|
-
query: 'u'
|
|
45
|
-
})).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it('returns false when no word starts with the character', () => {
|
|
48
|
-
expect(matchesColumnSearch({
|
|
49
|
-
labelText: 'Published Date',
|
|
50
|
-
query: 'z'
|
|
51
|
-
})).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
it('matches the start of a non-Latin label', () => {
|
|
54
|
-
expect(matchesColumnSearch({
|
|
55
|
-
labelText: 'Пользователь',
|
|
56
|
-
query: 'п'
|
|
57
|
-
})).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('multi-character queries', () => {
|
|
61
|
-
it('matches a substring in the middle of the label', () => {
|
|
62
|
-
expect(matchesColumnSearch({
|
|
63
|
-
labelText: 'Published Date',
|
|
64
|
-
query: 'ish'
|
|
65
|
-
})).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('matches across a word boundary', () => {
|
|
68
|
-
expect(matchesColumnSearch({
|
|
69
|
-
labelText: 'Published Date',
|
|
70
|
-
query: 'd da'
|
|
71
|
-
})).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
it('is case-insensitive', () => {
|
|
74
|
-
expect(matchesColumnSearch({
|
|
75
|
-
labelText: 'Published Date',
|
|
76
|
-
query: 'DATE'
|
|
77
|
-
})).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
it('returns false when the substring is not present', () => {
|
|
80
|
-
expect(matchesColumnSearch({
|
|
81
|
-
labelText: 'Published Date',
|
|
82
|
-
query: 'zzz'
|
|
83
|
-
})).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
//# sourceMappingURL=matchesColumnSearch.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchesColumnSearch.spec.js","names":["describe","expect","it","matchesColumnSearch","labelText","query","toBe"],"sources":["../../../src/elements/ColumnSelection/matchesColumnSearch.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { matchesColumnSearch } from './matchesColumnSearch.js'\n\ndescribe('matchesColumnSearch', () => {\n it('matches everything when the query is empty', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: '' })).toBe(true)\n })\n\n it('matches everything when the query is only whitespace', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: ' ' })).toBe(true)\n })\n\n describe('single-character queries', () => {\n it('matches the start of the label', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'p' })).toBe(true)\n })\n\n it('matches the start of a later word', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'd' })).toBe(true)\n })\n\n it('matches the start of a word after a nested-label separator', () => {\n expect(matchesColumnSearch({ labelText: 'Meta > Title', query: 't' })).toBe(true)\n })\n\n it('is case-insensitive', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'P' })).toBe(true)\n })\n\n it('does not match a character in the middle of a word', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'u' })).toBe(false)\n })\n\n it('returns false when no word starts with the character', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'z' })).toBe(false)\n })\n\n it('matches the start of a non-Latin label', () => {\n expect(matchesColumnSearch({ labelText: 'Пользователь', query: 'п' })).toBe(true)\n })\n })\n\n describe('multi-character queries', () => {\n it('matches a substring in the middle of the label', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'ish' })).toBe(true)\n })\n\n it('matches across a word boundary', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'd da' })).toBe(true)\n })\n\n it('is case-insensitive', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'DATE' })).toBe(true)\n })\n\n it('returns false when the substring is not present', () => {\n expect(matchesColumnSearch({ labelText: 'Published Date', query: 'zzz' })).toBe(false)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpCH,QAAA,CAAS,uBAAuB;EAC9BE,EAAA,CAAG,8CAA8C;IAC/CD,MAAA,CAAOE,mBAAA,CAAoB;MAAEC,SAAA,EAAW;MAAkBC,KAAA,EAAO;IAAG,IAAIC,IAAI,CAAC;EAC/E;EAEAJ,EAAA,CAAG,wDAAwD;IACzDD,MAAA,CAAOE,mBAAA,CAAoB;MAAEC,SAAA,EAAW;MAAkBC,KAAA,EAAO;IAAM,IAAIC,IAAI,CAAC;EAClF;EAEAN,QAAA,CAAS,4BAA4B;IACnCE,EAAA,CAAG,kCAAkC;MACnCD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,SAAA,EAAW;QAAkBC,KAAA,EAAO;MAAI,IAAIC,IAAI,CAAC;IAChF;IAEAJ,EAAA,CAAG,qCAAqC;MACtCD,MAAA,CAAOE,mBAAA,CAAoB;Q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,mBAAA,CAAoB;QAAEC,SAAA,EAAW;QAAkBC,KAAA,EAAO;MAAM,IAAIC,IAAI,CAAC;IAClF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { buildActions } from './buildActions.js';
|
|
3
|
-
import { filterActions } from './filterActions.js';
|
|
4
|
-
// getTranslation returns string labels as-is, and i18n.t echoes the key — enough for these tests.
|
|
5
|
-
const i18n = {
|
|
6
|
-
language: 'en',
|
|
7
|
-
t: key => key,
|
|
8
|
-
translations: {}
|
|
9
|
-
};
|
|
10
|
-
const makeCollection = slug => ({
|
|
11
|
-
admin: {},
|
|
12
|
-
labels: {
|
|
13
|
-
plural: slug,
|
|
14
|
-
singular: slug
|
|
15
|
-
},
|
|
16
|
-
slug
|
|
17
|
-
});
|
|
18
|
-
const makeGlobal = slug => ({
|
|
19
|
-
admin: {},
|
|
20
|
-
label: slug,
|
|
21
|
-
slug
|
|
22
|
-
});
|
|
23
|
-
const args = (permissions, visibleEntities = {
|
|
24
|
-
collections: ['posts', 'pages', 'media'],
|
|
25
|
-
globals: ['settings']
|
|
26
|
-
}) => ({
|
|
27
|
-
adminRoute: '/admin',
|
|
28
|
-
collections: [makeCollection('posts'), makeCollection('pages'), makeCollection('media')],
|
|
29
|
-
globals: [makeGlobal('settings')],
|
|
30
|
-
i18n,
|
|
31
|
-
permissions,
|
|
32
|
-
visibleEntities
|
|
33
|
-
});
|
|
34
|
-
describe('buildActions', () => {
|
|
35
|
-
it('includes only readable entities and adds createHref only with create permission', () => {
|
|
36
|
-
const groups = buildActions(args({
|
|
37
|
-
collections: {
|
|
38
|
-
media: {
|
|
39
|
-
read: true
|
|
40
|
-
},
|
|
41
|
-
pages: {
|
|
42
|
-
create: true,
|
|
43
|
-
read: true
|
|
44
|
-
},
|
|
45
|
-
posts: {
|
|
46
|
-
read: true
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
globals: {
|
|
50
|
-
settings: {
|
|
51
|
-
read: true
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}));
|
|
55
|
-
expect(groups.map(g => g.label)).toEqual(['general:collections', 'general:globals']);
|
|
56
|
-
const collections = groups[0].actions;
|
|
57
|
-
expect(collections.map(a => a.id)).toEqual(['collection-posts', 'collection-pages', 'collection-media']);
|
|
58
|
-
expect(collections.find(a => a.id === 'collection-pages')?.createHref).toBe('/admin/collections/pages/create');
|
|
59
|
-
expect(collections.find(a => a.id === 'collection-posts')?.createHref).toBeUndefined();
|
|
60
|
-
const globals = groups[1].actions;
|
|
61
|
-
expect(globals[0]).toMatchObject({
|
|
62
|
-
href: '/admin/globals/settings',
|
|
63
|
-
id: 'global-settings'
|
|
64
|
-
});
|
|
65
|
-
expect(globals[0].createHref).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
it('omits entities without read permission and omits empty groups', () => {
|
|
68
|
-
const groups = buildActions(args({
|
|
69
|
-
collections: {
|
|
70
|
-
posts: {
|
|
71
|
-
read: true
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
expect(groups).toHaveLength(1);
|
|
76
|
-
expect(groups[0].actions.map(a => a.id)).toEqual(['collection-posts']);
|
|
77
|
-
});
|
|
78
|
-
it('excludes entities with admin.group === false', () => {
|
|
79
|
-
const hidden = {
|
|
80
|
-
admin: {
|
|
81
|
-
group: false
|
|
82
|
-
},
|
|
83
|
-
labels: {
|
|
84
|
-
plural: 'secret',
|
|
85
|
-
singular: 'secret'
|
|
86
|
-
},
|
|
87
|
-
slug: 'secret'
|
|
88
|
-
};
|
|
89
|
-
const groups = buildActions({
|
|
90
|
-
adminRoute: '/admin',
|
|
91
|
-
collections: [hidden],
|
|
92
|
-
globals: [],
|
|
93
|
-
i18n,
|
|
94
|
-
permissions: {
|
|
95
|
-
collections: {
|
|
96
|
-
secret: {
|
|
97
|
-
read: true
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
visibleEntities: {
|
|
102
|
-
collections: ['secret'],
|
|
103
|
-
globals: []
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
expect(groups).toHaveLength(0);
|
|
107
|
-
});
|
|
108
|
-
it('excludes entities not in visibleEntities even when read permission is granted', () => {
|
|
109
|
-
const groups = buildActions(args({
|
|
110
|
-
collections: {
|
|
111
|
-
posts: {
|
|
112
|
-
read: true
|
|
113
|
-
},
|
|
114
|
-
pages: {
|
|
115
|
-
read: true
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
globals: {
|
|
119
|
-
settings: {
|
|
120
|
-
read: true
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
collections: [],
|
|
125
|
-
globals: []
|
|
126
|
-
}));
|
|
127
|
-
expect(groups).toHaveLength(0);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
describe('filterActions', () => {
|
|
131
|
-
const groups = buildActions(args({
|
|
132
|
-
collections: {
|
|
133
|
-
media: {
|
|
134
|
-
read: true
|
|
135
|
-
},
|
|
136
|
-
pages: {
|
|
137
|
-
read: true
|
|
138
|
-
},
|
|
139
|
-
posts: {
|
|
140
|
-
read: true
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
globals: {
|
|
144
|
-
settings: {
|
|
145
|
-
read: true
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}));
|
|
149
|
-
it('returns groups unchanged for an empty query', () => {
|
|
150
|
-
expect(filterActions(groups, '')).toEqual(groups);
|
|
151
|
-
});
|
|
152
|
-
it('filters non-matches and removes emptied groups', () => {
|
|
153
|
-
const filtered = filterActions(groups, 'pa');
|
|
154
|
-
expect(filtered).toHaveLength(1);
|
|
155
|
-
expect(filtered[0].actions.map(a => a.id)).toEqual(['collection-pages']);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
//# sourceMappingURL=buildActions.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildActions.spec.js","names":["describe","expect","it","buildActions","filterActions","i18n","language","t","key","translations","makeCollection","slug","admin","labels","plural","singular","makeGlobal","label","args","permissions","visibleEntities","collections","globals","adminRoute","groups","media","read","pages","create","posts","settings","map","g","toEqual","actions","a","id","find","createHref","toBe","toBeUndefined","toMatchObject","href","toHaveLength","hidden","group","secret","filtered"],"sources":["../../../src/elements/CommandPalette/buildActions.spec.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientGlobalConfig,\n SanitizedPermissions,\n VisibleEntities,\n} from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { buildActions } from './buildActions.js'\nimport { filterActions } from './filterActions.js'\n\n// getTranslation returns string labels as-is, and i18n.t echoes the key — enough for these tests.\nconst i18n = { language: 'en', t: (key: string) => key, translations: {} } as unknown as I18nClient\n\nconst makeCollection = (slug: string) =>\n ({\n admin: {},\n labels: { plural: slug, singular: slug },\n slug,\n }) as unknown as ClientCollectionConfig\n\nconst makeGlobal = (slug: string) =>\n ({ admin: {}, label: slug, slug }) as unknown as ClientGlobalConfig\n\nconst args = (\n permissions: SanitizedPermissions,\n visibleEntities: VisibleEntities = {\n collections: ['posts', 'pages', 'media'],\n globals: ['settings'],\n },\n) => ({\n adminRoute: '/admin',\n collections: [makeCollection('posts'), makeCollection('pages'), makeCollection('media')],\n globals: [makeGlobal('settings')],\n i18n,\n permissions,\n visibleEntities,\n})\n\ndescribe('buildActions', () => {\n it('includes only readable entities and adds createHref only with create permission', () => {\n const groups = buildActions(\n args({\n collections: {\n media: { read: true },\n pages: { create: true, read: true },\n posts: { read: true },\n },\n globals: { settings: { read: true } },\n } as unknown as SanitizedPermissions),\n )\n\n expect(groups.map((g) => g.label)).toEqual(['general:collections', 'general:globals'])\n\n const collections = groups[0].actions\n expect(collections.map((a) => a.id)).toEqual([\n 'collection-posts',\n 'collection-pages',\n 'collection-media',\n ])\n expect(collections.find((a) => a.id === 'collection-pages')?.createHref).toBe(\n '/admin/collections/pages/create',\n )\n expect(collections.find((a) => a.id === 'collection-posts')?.createHref).toBeUndefined()\n\n const globals = groups[1].actions\n expect(globals[0]).toMatchObject({ href: '/admin/globals/settings', id: 'global-settings' })\n expect(globals[0].createHref).toBeUndefined()\n })\n\n it('omits entities without read permission and omits empty groups', () => {\n const groups = buildActions(\n args({ collections: { posts: { read: true } } } as unknown as SanitizedPermissions),\n )\n expect(groups).toHaveLength(1)\n expect(groups[0].actions.map((a) => a.id)).toEqual(['collection-posts'])\n })\n\n it('excludes entities with admin.group === false', () => {\n const hidden = {\n admin: { group: false },\n labels: { plural: 'secret', singular: 'secret' },\n slug: 'secret',\n } as unknown as ClientCollectionConfig\n const groups = buildActions({\n adminRoute: '/admin',\n collections: [hidden],\n globals: [],\n i18n,\n permissions: { collections: { secret: { read: true } } } as unknown as SanitizedPermissions,\n visibleEntities: { collections: ['secret'], globals: [] },\n })\n expect(groups).toHaveLength(0)\n })\n\n it('excludes entities not in visibleEntities even when read permission is granted', () => {\n const groups = buildActions(\n args(\n {\n collections: { posts: { read: true }, pages: { read: true } },\n globals: { settings: { read: true } },\n } as unknown as SanitizedPermissions,\n { collections: [], globals: [] },\n ),\n )\n expect(groups).toHaveLength(0)\n })\n})\n\ndescribe('filterActions', () => {\n const groups = buildActions(\n args({\n collections: { media: { read: true }, pages: { read: true }, posts: { read: true } },\n globals: { settings: { read: true } },\n } as unknown as SanitizedPermissions),\n )\n\n it('returns groups unchanged for an empty query', () => {\n expect(filterActions(groups, '')).toEqual(groups)\n })\n\n it('filters non-matches and removes emptied groups', () => {\n const filtered = filterActions(groups, 'pa')\n expect(filtered).toHaveLength(1)\n expect(filtered[0].actions.map((a) => a.id)).toEqual(['collection-pages'])\n })\n})\n"],"mappings":"AAQA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,YAAY,QAAQ;AAC7B,SAASC,aAAa,QAAQ;AAE9B;AACA,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AUJ,YAAY,CAAC;IAC9B1C,MAAA,CAAO8C,QAAQ,CAAC,EAAE,CAACb,OAAO,CAACH,GAAG,CAAEI,CAAA,IAAMA,CAAA,CAAEC,EAAE,GAAGH,OAAO,CAAC,CAAC,mBAAmB;EAC3E;AACF","ignoreList":[]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { splitLabelByMatches } from './highlightLabel.js';
|
|
3
|
-
describe('splitLabelByMatches', () => {
|
|
4
|
-
it('returns a single unmatched segment when no indices are provided', () => {
|
|
5
|
-
expect(splitLabelByMatches('Posts')).toEqual([{
|
|
6
|
-
isMatch: false,
|
|
7
|
-
text: 'Posts'
|
|
8
|
-
}]);
|
|
9
|
-
});
|
|
10
|
-
it('returns a single unmatched segment for an empty indices array', () => {
|
|
11
|
-
expect(splitLabelByMatches('Posts', [])).toEqual([{
|
|
12
|
-
isMatch: false,
|
|
13
|
-
text: 'Posts'
|
|
14
|
-
}]);
|
|
15
|
-
});
|
|
16
|
-
it('returns empty array for an empty label', () => {
|
|
17
|
-
expect(splitLabelByMatches('')).toEqual([]);
|
|
18
|
-
});
|
|
19
|
-
it('returns empty array for an empty label even with indices', () => {
|
|
20
|
-
expect(splitLabelByMatches('', [0])).toEqual([]);
|
|
21
|
-
});
|
|
22
|
-
it('groups leading consecutive matches into a single matched segment', () => {
|
|
23
|
-
// indices [0,1] on "Posts" → matched "Po", unmatched "sts"
|
|
24
|
-
expect(splitLabelByMatches('Posts', [0, 1])).toEqual([{
|
|
25
|
-
isMatch: true,
|
|
26
|
-
text: 'Po'
|
|
27
|
-
}, {
|
|
28
|
-
isMatch: false,
|
|
29
|
-
text: 'sts'
|
|
30
|
-
}]);
|
|
31
|
-
});
|
|
32
|
-
it('handles non-contiguous indices as alternating segments', () => {
|
|
33
|
-
// indices [0,2] on "Posts" → matched "P", unmatched "o", matched "s", unmatched "ts"
|
|
34
|
-
expect(splitLabelByMatches('Posts', [0, 2])).toEqual([{
|
|
35
|
-
isMatch: true,
|
|
36
|
-
text: 'P'
|
|
37
|
-
}, {
|
|
38
|
-
isMatch: false,
|
|
39
|
-
text: 'o'
|
|
40
|
-
}, {
|
|
41
|
-
isMatch: true,
|
|
42
|
-
text: 's'
|
|
43
|
-
}, {
|
|
44
|
-
isMatch: false,
|
|
45
|
-
text: 'ts'
|
|
46
|
-
}]);
|
|
47
|
-
});
|
|
48
|
-
it('handles a match at the end of the label', () => {
|
|
49
|
-
// indices [4] on "Posts" → unmatched "Post", matched "s"
|
|
50
|
-
expect(splitLabelByMatches('Posts', [4])).toEqual([{
|
|
51
|
-
isMatch: false,
|
|
52
|
-
text: 'Post'
|
|
53
|
-
}, {
|
|
54
|
-
isMatch: true,
|
|
55
|
-
text: 's'
|
|
56
|
-
}]);
|
|
57
|
-
});
|
|
58
|
-
it('handles all characters matched', () => {
|
|
59
|
-
expect(splitLabelByMatches('ab', [0, 1])).toEqual([{
|
|
60
|
-
isMatch: true,
|
|
61
|
-
text: 'ab'
|
|
62
|
-
}]);
|
|
63
|
-
});
|
|
64
|
-
it('handles a single character match in the middle', () => {
|
|
65
|
-
// indices [2] on "Posts" → unmatched "Po", matched "s", unmatched "ts"
|
|
66
|
-
expect(splitLabelByMatches('Posts', [2])).toEqual([{
|
|
67
|
-
isMatch: false,
|
|
68
|
-
text: 'Po'
|
|
69
|
-
}, {
|
|
70
|
-
isMatch: true,
|
|
71
|
-
text: 's'
|
|
72
|
-
}, {
|
|
73
|
-
isMatch: false,
|
|
74
|
-
text: 'ts'
|
|
75
|
-
}]);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=highlightLabel.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"highlightLabel.spec.js","names":["describe","expect","it","splitLabelByMatches","toEqual","isMatch","text"],"sources":["../../../src/elements/CommandPalette/highlightLabel.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { splitLabelByMatches } from './highlightLabel.js'\n\ndescribe('splitLabelByMatches', () => {\n it('returns a single unmatched segment when no indices are provided', () => {\n expect(splitLabelByMatches('Posts')).toEqual([{ isMatch: false, text: 'Posts' }])\n })\n\n it('returns a single unmatched segment for an empty indices array', () => {\n expect(splitLabelByMatches('Posts', [])).toEqual([{ isMatch: false, text: 'Posts' }])\n })\n\n it('returns empty array for an empty label', () => {\n expect(splitLabelByMatches('')).toEqual([])\n })\n\n it('returns empty array for an empty label even with indices', () => {\n expect(splitLabelByMatches('', [0])).toEqual([])\n })\n\n it('groups leading consecutive matches into a single matched segment', () => {\n // indices [0,1] on \"Posts\" → matched \"Po\", unmatched \"sts\"\n expect(splitLabelByMatches('Posts', [0, 1])).toEqual([\n { isMatch: true, text: 'Po' },\n { isMatch: false, text: 'sts' },\n ])\n })\n\n it('handles non-contiguous indices as alternating segments', () => {\n // indices [0,2] on \"Posts\" → matched \"P\", unmatched \"o\", matched \"s\", unmatched \"ts\"\n expect(splitLabelByMatches('Posts', [0, 2])).toEqual([\n { isMatch: true, text: 'P' },\n { isMatch: false, text: 'o' },\n { isMatch: true, text: 's' },\n { isMatch: false, text: 'ts' },\n ])\n })\n\n it('handles a match at the end of the label', () => {\n // indices [4] on \"Posts\" → unmatched \"Post\", matched \"s\"\n expect(splitLabelByMatches('Posts', [4])).toEqual([\n { isMatch: false, text: 'Post' },\n { isMatch: true, text: 's' },\n ])\n })\n\n it('handles all characters matched', () => {\n expect(splitLabelByMatches('ab', [0, 1])).toEqual([{ isMatch: true, text: 'ab' }])\n })\n\n it('handles a single character match in the middle', () => {\n // indices [2] on \"Posts\" → unmatched \"Po\", matched \"s\", unmatched \"ts\"\n expect(splitLabelByMatches('Posts', [2])).toEqual([\n { isMatch: false, text: 'Po' },\n { isMatch: true, text: 's' },\n { isMatch: false, text: 'ts' },\n ])\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBA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EAAS;MAAOC,IAAA,EAAM;IAAO,GAC/B;MAAED,OAAA,EAAS;MAAMC,IAAA,EAAM;IAAI,EAC5B;EACH;EAEAJ,EAAA,CAAG,kCAAkC;IACnCD,MAAA,CAAOE,mBAAA,CAAoB,MAAM,CAAC,GAAG,EAAE,GAAGC,OAAO,CAAC,CAAC;MAAEC,OAAA,EAAS;MAAMC,IAAA,EAAM;IAAK,EAAE;EACnF;EAEAJ,EAAA,CAAG,kDAAkD;IACnD;IACAD,MAAA,CAAOE,mBAAA,CAAoB,SAAS,CAAC,EAAE,GAAGC,OAAO,CAAC,CAChD;MAAEC,OAAA,EAAS;MAAOC,IAAA,EAAM;IAAK,GAC7B;MAAED,OAAA,EAAS;MAAMC,IAAA,EAAM;IAAI,GAC3B;MAAED,OAAA,EAAS;MAAOC,IAAA,EAAM;IAAK,EAC9B;EACH;AACF","ignoreList":[]}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
// Mock the JSX label builder: irrelevant to permission logic and avoids needing a React runtime here.
|
|
3
|
-
vi.mock('../../utilities/combineFieldLabel.js', () => ({
|
|
4
|
-
combineFieldLabel: () => null
|
|
5
|
-
}));
|
|
6
|
-
import { reduceFieldOptions } from './reduceFieldOptions.js';
|
|
7
|
-
const text = name => ({
|
|
8
|
-
name,
|
|
9
|
-
type: 'text'
|
|
10
|
-
});
|
|
11
|
-
const namesOf = options => options.map(option => 'name' in option.value.field ? option.value.field.name : undefined);
|
|
12
|
-
const optionsFor = (fields, permissions) => reduceFieldOptions({
|
|
13
|
-
fields,
|
|
14
|
-
permissions: permissions
|
|
15
|
-
});
|
|
16
|
-
// Granted sets the operation to `true`; denied omits the key, mirroring `populateFieldPermissions`.
|
|
17
|
-
const granted = {
|
|
18
|
-
create: true,
|
|
19
|
-
read: true,
|
|
20
|
-
update: true
|
|
21
|
-
};
|
|
22
|
-
const readOnly = {
|
|
23
|
-
create: true,
|
|
24
|
-
read: true
|
|
25
|
-
};
|
|
26
|
-
describe('reduceFieldOptions', () => {
|
|
27
|
-
it('excludes a restricted field inside a named tab while keeping its clean siblings', () => {
|
|
28
|
-
const fields = [{
|
|
29
|
-
type: 'tabs',
|
|
30
|
-
tabs: [{
|
|
31
|
-
name: 'namedTab',
|
|
32
|
-
fields: [text('okInTab'), text('restrictedInTab')]
|
|
33
|
-
}]
|
|
34
|
-
}];
|
|
35
|
-
const permissions = {
|
|
36
|
-
namedTab: {
|
|
37
|
-
...granted,
|
|
38
|
-
fields: {
|
|
39
|
-
okInTab: granted,
|
|
40
|
-
restrictedInTab: readOnly
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const options = optionsFor(fields, permissions);
|
|
45
|
-
const names = namesOf(options);
|
|
46
|
-
expect(names).toContain('okInTab');
|
|
47
|
-
expect(names).not.toContain('restrictedInTab');
|
|
48
|
-
});
|
|
49
|
-
it('excludes a restricted field inside a nested named tab', () => {
|
|
50
|
-
const fields = [{
|
|
51
|
-
type: 'tabs',
|
|
52
|
-
tabs: [{
|
|
53
|
-
name: 'outerTab',
|
|
54
|
-
fields: [{
|
|
55
|
-
type: 'tabs',
|
|
56
|
-
tabs: [{
|
|
57
|
-
name: 'innerTab',
|
|
58
|
-
fields: [text('deepOk'), text('deepRestricted')]
|
|
59
|
-
}]
|
|
60
|
-
}]
|
|
61
|
-
}]
|
|
62
|
-
}];
|
|
63
|
-
const permissions = {
|
|
64
|
-
outerTab: {
|
|
65
|
-
...granted,
|
|
66
|
-
fields: {
|
|
67
|
-
innerTab: {
|
|
68
|
-
...granted,
|
|
69
|
-
fields: {
|
|
70
|
-
deepOk: granted,
|
|
71
|
-
deepRestricted: readOnly
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const options = optionsFor(fields, permissions);
|
|
78
|
-
const names = namesOf(options);
|
|
79
|
-
expect(names).toContain('deepOk');
|
|
80
|
-
expect(names).not.toContain('deepRestricted');
|
|
81
|
-
});
|
|
82
|
-
it('only affects the named tab that contains the restricted field', () => {
|
|
83
|
-
const fields = [{
|
|
84
|
-
type: 'tabs',
|
|
85
|
-
tabs: [{
|
|
86
|
-
name: 'cleanTab',
|
|
87
|
-
fields: [text('cleanField')]
|
|
88
|
-
}, {
|
|
89
|
-
name: 'restrictedHostTab',
|
|
90
|
-
fields: [text('restrictedField')]
|
|
91
|
-
}]
|
|
92
|
-
}];
|
|
93
|
-
const permissions = {
|
|
94
|
-
cleanTab: {
|
|
95
|
-
...granted,
|
|
96
|
-
fields: {
|
|
97
|
-
cleanField: granted
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
restrictedHostTab: {
|
|
101
|
-
...granted,
|
|
102
|
-
fields: {
|
|
103
|
-
restrictedField: readOnly
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const options = optionsFor(fields, permissions);
|
|
108
|
-
const names = namesOf(options);
|
|
109
|
-
expect(names).toContain('cleanField');
|
|
110
|
-
expect(names).not.toContain('restrictedField');
|
|
111
|
-
});
|
|
112
|
-
it('includes every named-tab field when permissions are fully granted', () => {
|
|
113
|
-
const fields = [{
|
|
114
|
-
type: 'tabs',
|
|
115
|
-
tabs: [{
|
|
116
|
-
name: 'namedTab',
|
|
117
|
-
fields: [text('a'), text('b')]
|
|
118
|
-
}]
|
|
119
|
-
}];
|
|
120
|
-
const options = optionsFor(fields, true);
|
|
121
|
-
const names = namesOf(options);
|
|
122
|
-
expect(names).toEqual(expect.arrayContaining(['a', 'b']));
|
|
123
|
-
});
|
|
124
|
-
it('applies parent permissions to an unnamed tab and excludes its restricted fields', () => {
|
|
125
|
-
const fields = [{
|
|
126
|
-
type: 'tabs',
|
|
127
|
-
tabs: [{
|
|
128
|
-
label: 'Unnamed',
|
|
129
|
-
fields: [text('okAtRoot'), text('restrictedAtRoot')]
|
|
130
|
-
}]
|
|
131
|
-
}];
|
|
132
|
-
// Unnamed tabs share the parent's permission map, so subfields resolve at the parent level.
|
|
133
|
-
const permissions = {
|
|
134
|
-
okAtRoot: granted,
|
|
135
|
-
restrictedAtRoot: readOnly
|
|
136
|
-
};
|
|
137
|
-
const options = optionsFor(fields, permissions);
|
|
138
|
-
const names = namesOf(options);
|
|
139
|
-
expect(names).toContain('okAtRoot');
|
|
140
|
-
expect(names).not.toContain('restrictedAtRoot');
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
//# sourceMappingURL=reduceFieldOptions.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reduceFieldOptions.spec.js","names":["describe","expect","it","vi","mock","combineFieldLabel","reduceFieldOptions","text","name","type","namesOf","options","map","option","value","field","undefined","optionsFor","fields","permissions","granted","create","read","update","readOnly","tabs","namedTab","okInTab","restrictedInTab","names","toContain","not","outerTab","innerTab","deepOk","deepRestricted","cleanTab","cleanField","restrictedHostTab","restrictedField","toEqual","arrayContaining","label","okAtRoot","restrictedAtRoot"],"sources":["../../../src/elements/FieldSelect/reduceFieldOptions.spec.ts"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { describe, expect, it, vi } from 'vitest'\n\nimport type { FieldOption } from './reduceFieldOptions.js'\n\n// Mock the JSX label builder: irrelevant to permission logic and avoids needing a React runtime here.\nvi.mock('../../utilities/combineFieldLabel.js', () => ({\n combineFieldLabel: () => null,\n}))\n\nimport { reduceFieldOptions } from './reduceFieldOptions.js'\n\nconst text = (name: string): ClientField => ({ name, type: 'text' }) as ClientField\n\nconst namesOf = (options: FieldOption[]): (string | undefined)[] =>\n options.map((option) => ('name' in option.value.field ? option.value.field.name : undefined))\n\n// A denied field omits the operation key at runtime, which `SanitizedFieldPermissions` can't express — cast at the boundary.\ntype Permissions = Parameters<typeof reduceFieldOptions>[0]['permissions']\nconst optionsFor = (fields: ClientField[], permissions: unknown): FieldOption[] =>\n reduceFieldOptions({ fields, permissions: permissions as Permissions })\n\n// Granted sets the operation to `true`; denied omits the key, mirroring `populateFieldPermissions`.\nconst granted = { create: true, read: true, update: true }\nconst readOnly = { create: true, read: true }\n\ndescribe('reduceFieldOptions', () => {\n it('excludes a restricted field inside a named tab while keeping its clean siblings', () => {\n const fields: ClientField[] = [\n {\n type: 'tabs',\n tabs: [{ name: 'namedTab', fields: [text('okInTab'), text('restrictedInTab')] }],\n } as ClientField,\n ]\n\n const permissions = {\n namedTab: {\n ...granted,\n fields: {\n okInTab: granted,\n restrictedInTab: readOnly,\n },\n },\n }\n\n const options = optionsFor(fields, permissions)\n const names = namesOf(options)\n\n expect(names).toContain('okInTab')\n expect(names).not.toContain('restrictedInTab')\n })\n\n it('excludes a restricted field inside a nested named tab', () => {\n const fields: ClientField[] = [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'outerTab',\n fields: [\n {\n type: 'tabs',\n tabs: [{ name: 'innerTab', fields: [text('deepOk'), text('deepRestricted')] }],\n },\n ],\n },\n ],\n } as ClientField,\n ]\n\n const permissions = {\n outerTab: {\n ...granted,\n fields: {\n innerTab: {\n ...granted,\n fields: {\n deepOk: granted,\n deepRestricted: readOnly,\n },\n },\n },\n },\n }\n\n const options = optionsFor(fields, permissions)\n const names = namesOf(options)\n\n expect(names).toContain('deepOk')\n expect(names).not.toContain('deepRestricted')\n })\n\n it('only affects the named tab that contains the restricted field', () => {\n const fields: ClientField[] = [\n {\n type: 'tabs',\n tabs: [\n { name: 'cleanTab', fields: [text('cleanField')] },\n { name: 'restrictedHostTab', fields: [text('restrictedField')] },\n ],\n } as ClientField,\n ]\n\n const permissions = {\n cleanTab: { ...granted, fields: { cleanField: granted } },\n restrictedHostTab: { ...granted, fields: { restrictedField: readOnly } },\n }\n\n const options = optionsFor(fields, permissions)\n const names = namesOf(options)\n\n expect(names).toContain('cleanField')\n expect(names).not.toContain('restrictedField')\n })\n\n it('includes every named-tab field when permissions are fully granted', () => {\n const fields: ClientField[] = [\n {\n type: 'tabs',\n tabs: [{ name: 'namedTab', fields: [text('a'), text('b')] }],\n } as ClientField,\n ]\n\n const options = optionsFor(fields, true)\n const names = namesOf(options)\n\n expect(names).toEqual(expect.arrayContaining(['a', 'b']))\n })\n\n it('applies parent permissions to an unnamed tab and excludes its restricted fields', () => {\n const fields: ClientField[] = [\n {\n type: 'tabs',\n tabs: [{ label: 'Unnamed', fields: [text('okAtRoot'), text('restrictedAtRoot')] }],\n } as ClientField,\n ]\n\n // Unnamed tabs share the parent's permission map, so subfields resolve at the parent level.\n const permissions = {\n okAtRoot: granted,\n restrictedAtRoot: readOnly,\n }\n\n const options = optionsFor(fields, permissions)\n const names = namesOf(options)\n\n expect(names).toContain('okAtRoot')\n expect(names).not.toContain('restrictedAtRoot')\n })\n})\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ;AAIzC;AACAA,EAAA,CAAGC,IAAI,CAAC,wCAAwC,OAAO;EACrDC,iBAAA,EAAmBA,CAAA,KAAM;AAC3B;AAEA,SAASC,kBAAkB,QAAQ;AAEnC,MAAMC,IAAA,GAAQC,IAAA,KAA+B;EAAEA,IAAA;EAAMC,IAAA,EAAM;AAAO;AAElE,MAAMC,OAAA,GAAWC,OAAA,IACfA,OAAA,CAAQC,GAAG,CAAEC,MAAA,IAAY,UAAUA,MAAA,CAAOC,KAAK,CAACC,KAAK,GAAGF,MAAA,CAAOC,KAAK,CAACC,KAAK,CAACP,IAAI,GAAGQ,SAAA;AAIpF,MAAMC,UAAA,GAAaA,CAACC,MAAA,EAAuBC,WAAA,KACzCb,kBAAA,CAAmB;EAAEY,MAAA;EAAQC,WAAA,EAAaA;AAA2B;AAEvE;AACA,MAAMC,OAAA,GAAU;EAAEC,MAAA,EAAQ;EAAMC,IAAA,EAAM;EAAMC,MAAA,EAAQ;AAAK;AACzD,MAAMC,QAAA,GAAW;EAAEH,MAAA,EAAQ;EAAMC,IAAA,EAAM;AAAK;AAE5CtB,QAAA,CAAS,sBAAsB;EAC7BE,EAAA,C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