sanity-plugin-media 4.3.0 → 4.3.2

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.
Files changed (145) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +12 -12
  3. package/dist/index.d.mts +263 -195
  4. package/dist/index.d.ts +263 -195
  5. package/dist/index.js +83 -203
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +84 -203
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +42 -64
  10. package/src/__tests__/fixtures/createEpicTestStore.ts +5 -4
  11. package/src/__tests__/fixtures/mockSanityClient.ts +8 -8
  12. package/src/__tests__/fixtures/renderWithProviders.tsx +8 -7
  13. package/src/__tests__/fixtures/rootState.ts +4 -4
  14. package/src/components/AssetGridVirtualized/index.tsx +8 -7
  15. package/src/components/AssetMetadata/index.tsx +6 -5
  16. package/src/components/AssetTableVirtualized/index.tsx +7 -6
  17. package/src/components/AutoTagInputWrapper/index.tsx +9 -4
  18. package/src/components/Browser/Browser.test.tsx +9 -8
  19. package/src/components/Browser/index.tsx +2 -1
  20. package/src/components/Browser/useBrowserInit.ts +9 -9
  21. package/src/components/ButtonAssetCopy/index.tsx +1 -0
  22. package/src/components/ButtonViewGroup/index.tsx +4 -3
  23. package/src/components/CardAsset/CardAsset.test.tsx +53 -52
  24. package/src/components/CardAsset/index.tsx +52 -49
  25. package/src/components/CardUpload/index.tsx +7 -6
  26. package/src/components/Controls/index.tsx +7 -6
  27. package/src/components/DebugControls/index.tsx +5 -4
  28. package/src/components/DialogAssetEdit/Details.tsx +3 -2
  29. package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +28 -27
  30. package/src/components/DialogAssetEdit/index.tsx +37 -37
  31. package/src/components/DialogConfirm/index.tsx +2 -1
  32. package/src/components/DialogSearchFacets/index.tsx +3 -2
  33. package/src/components/DialogTagCreate/DialogTagCreate.test.tsx +16 -15
  34. package/src/components/DialogTagCreate/index.tsx +11 -10
  35. package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +28 -27
  36. package/src/components/DialogTagEdit/index.tsx +17 -16
  37. package/src/components/DialogTags/index.tsx +4 -3
  38. package/src/components/Dialogs/index.tsx +2 -3
  39. package/src/components/DocumentList/index.tsx +2 -3
  40. package/src/components/FileAssetPreview/index.tsx +2 -2
  41. package/src/components/FormBuilderTool/FormBuilderTool.test.tsx +12 -11
  42. package/src/components/FormBuilderTool/index.tsx +2 -1
  43. package/src/components/FormFieldInputLabel/index.tsx +1 -2
  44. package/src/components/FormFieldInputTags/index.tsx +4 -3
  45. package/src/components/FormSubmitButton/index.tsx +1 -1
  46. package/src/components/Header/index.tsx +3 -3
  47. package/src/components/Image/index.tsx +10 -4
  48. package/src/components/Items/index.tsx +5 -4
  49. package/src/components/Notifications/index.tsx +3 -2
  50. package/src/components/OrderSelect/index.tsx +4 -3
  51. package/src/components/PickedBar/index.tsx +2 -1
  52. package/src/components/Progress/index.tsx +3 -3
  53. package/src/components/ReduxProvider/index.tsx +15 -12
  54. package/src/components/SearchFacet/index.tsx +3 -2
  55. package/src/components/SearchFacetNumber/index.tsx +8 -8
  56. package/src/components/SearchFacetSelect/index.tsx +7 -8
  57. package/src/components/SearchFacetString/index.tsx +1 -1
  58. package/src/components/SearchFacetTags/index.tsx +13 -12
  59. package/src/components/SearchFacets/index.tsx +2 -3
  60. package/src/components/SearchFacetsControl/index.tsx +13 -12
  61. package/src/components/TableHeader/index.tsx +18 -17
  62. package/src/components/TableHeaderItem/index.tsx +4 -4
  63. package/src/components/TableRowAsset/index.tsx +37 -36
  64. package/src/components/TableRowUpload/index.tsx +7 -6
  65. package/src/components/Tag/index.tsx +8 -7
  66. package/src/components/TagView/index.tsx +2 -2
  67. package/src/components/TagViewHeader/index.tsx +5 -4
  68. package/src/components/TagsPanel/index.tsx +3 -3
  69. package/src/components/TagsVirtualized/index.tsx +25 -24
  70. package/src/components/TextInputSearch/index.tsx +3 -2
  71. package/src/components/UploadDropzone/UploadDropzone.test.tsx +8 -7
  72. package/src/components/UploadDropzone/index.tsx +14 -13
  73. package/src/config/orders.ts +6 -6
  74. package/src/config/searchFacets.ts +56 -55
  75. package/src/constants.ts +15 -14
  76. package/src/contexts/AssetSourceDispatchContext.tsx +1 -1
  77. package/src/contexts/ToolOptionsContext.tsx +6 -5
  78. package/src/formSchema/index.test.ts +6 -5
  79. package/src/formSchema/index.ts +5 -5
  80. package/src/hooks/useBreakpointIndex.ts +6 -6
  81. package/src/hooks/useKeyPress.ts +2 -2
  82. package/src/hooks/usePortalPopoverProps.ts +1 -1
  83. package/src/modules/assets/actions.ts +8 -7
  84. package/src/modules/assets/deleteAndUpdateEpics.test.ts +18 -17
  85. package/src/modules/assets/fetchEpic.test.ts +12 -11
  86. package/src/modules/assets/index.ts +134 -133
  87. package/src/modules/assets/reducer.test.ts +9 -8
  88. package/src/modules/assets/tagsAndListenerEpics.test.ts +36 -35
  89. package/src/modules/debug/index.ts +3 -3
  90. package/src/modules/dialog/actions.ts +2 -2
  91. package/src/modules/dialog/epics.test.ts +29 -28
  92. package/src/modules/dialog/index.ts +36 -35
  93. package/src/modules/dialog/reducer.test.ts +31 -30
  94. package/src/modules/index.ts +9 -9
  95. package/src/modules/notifications/epics.test.ts +71 -70
  96. package/src/modules/notifications/index.ts +50 -49
  97. package/src/modules/notifications/reducer.test.ts +8 -7
  98. package/src/modules/search/index.test.ts +2 -1
  99. package/src/modules/search/index.ts +22 -22
  100. package/src/modules/selected/index.ts +2 -2
  101. package/src/modules/selectors.test.ts +4 -3
  102. package/src/modules/selectors.ts +5 -5
  103. package/src/modules/tags/epics.test.ts +16 -15
  104. package/src/modules/tags/index.test.ts +2 -1
  105. package/src/modules/tags/index.ts +82 -81
  106. package/src/modules/uploads/actions.ts +3 -3
  107. package/src/modules/uploads/epics.test.ts +13 -12
  108. package/src/modules/uploads/index.test.ts +8 -7
  109. package/src/modules/uploads/index.ts +48 -47
  110. package/src/operators/checkTagName.test.ts +7 -6
  111. package/src/operators/checkTagName.ts +6 -5
  112. package/src/operators/debugThrottle.ts +4 -4
  113. package/src/plugin.tsx +18 -18
  114. package/src/schemas/tag.ts +7 -7
  115. package/src/styled/react-select/creatable.tsx +40 -39
  116. package/src/styled/react-select/single.tsx +39 -38
  117. package/src/types/index.ts +4 -3
  118. package/src/utils/applyMediaTags.ts +11 -10
  119. package/src/utils/blocksToText.test.ts +5 -4
  120. package/src/utils/blocksToText.ts +2 -2
  121. package/src/utils/constructFilter.test.ts +15 -14
  122. package/src/utils/constructFilter.ts +7 -7
  123. package/src/utils/generatePreviewBlobUrl.test.ts +6 -5
  124. package/src/utils/generatePreviewBlobUrl.ts +2 -2
  125. package/src/utils/getAssetResolution.test.ts +3 -2
  126. package/src/utils/getDocumentAssetIds.test.ts +7 -6
  127. package/src/utils/getDocumentAssetIds.ts +2 -2
  128. package/src/utils/getSchemeColor.test.ts +1 -0
  129. package/src/utils/getSchemeColor.ts +9 -9
  130. package/src/utils/getTagSelectOptions.test.ts +6 -5
  131. package/src/utils/getTagSelectOptions.ts +1 -1
  132. package/src/utils/getUniqueDocuments.test.ts +4 -3
  133. package/src/utils/getUniqueDocuments.ts +2 -2
  134. package/src/utils/imageDprUrl.test.ts +4 -3
  135. package/src/utils/imageDprUrl.ts +1 -1
  136. package/src/utils/isSupportedAssetType.test.ts +1 -0
  137. package/src/utils/mediaField.ts +4 -3
  138. package/src/utils/sanitizeFormData.test.ts +14 -13
  139. package/src/utils/typeGuards.test.ts +2 -1
  140. package/src/utils/uploadSanityAsset.test.ts +5 -4
  141. package/src/utils/uploadSanityAsset.ts +17 -16
  142. package/src/utils/withMaxConcurrency.test.ts +5 -4
  143. package/src/utils/withMaxConcurrency.ts +4 -4
  144. package/src/utils/zodFormResolver.ts +17 -0
  145. package/v2-incompatible.js +2 -2
@@ -1,13 +1,14 @@
1
1
  // @vitest-environment node
2
2
 
3
3
  import {describe, expect, it} from 'vitest'
4
- import {DIALOG_ACTIONS} from './actions'
5
- import dialogReducer, {dialogActions} from './index'
4
+
5
+ import {createTestRootState} from '../../__tests__/fixtures/rootState'
6
+ import type {AssetItem, ImageAsset, Tag} from '../../types'
6
7
  import {assetsActions} from '../assets'
7
8
  import {ASSETS_ACTIONS} from '../assets/actions'
8
9
  import {tagsActions} from '../tags'
9
- import type {AssetItem, ImageAsset, Tag} from '../../types'
10
- import {createTestRootState} from '../../__tests__/fixtures/rootState'
10
+ import {DIALOG_ACTIONS} from './actions'
11
+ import dialogReducer, {dialogActions} from './index'
11
12
 
12
13
  const sampleAsset = {
13
14
  _id: 'a1',
@@ -18,7 +19,7 @@ const sampleAsset = {
18
19
  originalFilename: 'x.png',
19
20
  size: 1,
20
21
  mimeType: 'image/png',
21
- url: 'https://example.com/x.png'
22
+ url: 'https://example.com/x.png',
22
23
  } as ImageAsset
23
24
 
24
25
  const sampleTag: Tag = {
@@ -27,14 +28,14 @@ const sampleTag: Tag = {
27
28
  _createdAt: '',
28
29
  _updatedAt: '',
29
30
  _rev: 'tr',
30
- name: {_type: 'slug', current: 'alpha'}
31
+ name: {_type: 'slug', current: 'alpha'},
31
32
  }
32
33
 
33
34
  const assetItem = (asset: ImageAsset = sampleAsset): AssetItem => ({
34
35
  _type: 'asset',
35
36
  asset,
36
37
  picked: false,
37
- updating: false
38
+ updating: false,
38
39
  })
39
40
 
40
41
  function dialogState() {
@@ -45,7 +46,7 @@ describe('dialog slice reducers', () => {
45
46
  it('clear removes all items', () => {
46
47
  const state = dialogReducer(
47
48
  {...dialogState(), items: [{id: 'x', type: 'tags'}]},
48
- dialogActions.clear()
49
+ dialogActions.clear(),
49
50
  )
50
51
  expect(state.items).toEqual([])
51
52
  })
@@ -56,10 +57,10 @@ describe('dialog slice reducers', () => {
56
57
  ...dialogState(),
57
58
  items: [
58
59
  {id: 'a', type: 'tags'},
59
- {id: 'b', type: 'searchFacets'}
60
- ]
60
+ {id: 'b', type: 'searchFacets'},
61
+ ],
61
62
  },
62
- dialogActions.remove({id: 'a'})
63
+ dialogActions.remove({id: 'a'}),
63
64
  )
64
65
  expect(state.items).toEqual([{id: 'b', type: 'searchFacets'}])
65
66
  })
@@ -74,7 +75,7 @@ describe('dialog slice reducers', () => {
74
75
  state = dialogReducer(state, dialogActions.showTags())
75
76
  expect(state.items).toEqual([
76
77
  {id: 'searchFacets', type: 'searchFacets'},
77
- {id: 'tags', type: 'tags'}
78
+ {id: 'tags', type: 'tags'},
78
79
  ])
79
80
  })
80
81
 
@@ -84,16 +85,16 @@ describe('dialog slice reducers', () => {
84
85
  ...dialogState(),
85
86
  items: [
86
87
  {id: 'a1', type: 'assetEdit', assetId: 'a1'},
87
- {id: 'a2', type: 'assetEdit', assetId: 'a2'}
88
- ]
88
+ {id: 'a2', type: 'assetEdit', assetId: 'a2'},
89
+ ],
89
90
  },
90
- dialogActions.inlineTagCreate({assetId: 'a1', tag: sampleTag})
91
+ dialogActions.inlineTagCreate({assetId: 'a1', tag: sampleTag}),
91
92
  )
92
- const a1 = state.items.find(i => i.type === 'assetEdit' && i.assetId === 'a1')
93
- const a2 = state.items.find(i => i.type === 'assetEdit' && i.assetId === 'a2')
93
+ const a1 = state.items.find((i) => i.type === 'assetEdit' && i.assetId === 'a1')
94
+ const a2 = state.items.find((i) => i.type === 'assetEdit' && i.assetId === 'a2')
94
95
  expect(a1 && 'lastCreatedTag' in a1 && a1.lastCreatedTag).toEqual({
95
96
  label: 'alpha',
96
- value: 't1'
97
+ value: 't1',
97
98
  })
98
99
  expect(a2).toBeDefined()
99
100
  expect(Object.prototype.hasOwnProperty.call(a2, 'lastCreatedTag')).toBe(false)
@@ -105,14 +106,14 @@ describe('dialog slice reducers', () => {
105
106
  ...dialogState(),
106
107
  items: [
107
108
  {id: 'a1', type: 'assetEdit', assetId: 'a1'},
108
- {id: 'tags', type: 'tags'}
109
- ]
109
+ {id: 'tags', type: 'tags'},
110
+ ],
110
111
  },
111
- dialogActions.inlineTagRemove({tagIds: ['x', 'y']})
112
+ dialogActions.inlineTagRemove({tagIds: ['x', 'y']}),
112
113
  )
113
- const edit = state.items.find(i => i.type === 'assetEdit')
114
+ const edit = state.items.find((i) => i.type === 'assetEdit')
114
115
  expect(edit && 'lastRemovedTagIds' in edit && edit.lastRemovedTagIds).toEqual(['x', 'y'])
115
- const tagsPanel = state.items.find(i => i.type === 'tags')
116
+ const tagsPanel = state.items.find((i) => i.type === 'tags')
116
117
  expect(tagsPanel && 'lastRemovedTagIds' in tagsPanel).toBeFalsy()
117
118
  })
118
119
 
@@ -120,7 +121,7 @@ describe('dialog slice reducers', () => {
120
121
  const item = assetItem()
121
122
  const state = dialogReducer(
122
123
  dialogState(),
123
- dialogActions.showConfirmDeleteAssets({assets: [item], closeDialogId: 'a1'})
124
+ dialogActions.showConfirmDeleteAssets({assets: [item], closeDialogId: 'a1'}),
124
125
  )
125
126
  const confirm = state.items[0]
126
127
  expect(confirm?.type).toBe('confirm')
@@ -132,7 +133,7 @@ describe('dialog slice reducers', () => {
132
133
  it('showConfirmDeleteTag pushes a confirm dialog wired to tags deleteRequest', () => {
133
134
  const state = dialogReducer(
134
135
  dialogState(),
135
- dialogActions.showConfirmDeleteTag({closeDialogId: 't1', tag: sampleTag})
136
+ dialogActions.showConfirmDeleteTag({closeDialogId: 't1', tag: sampleTag}),
136
137
  )
137
138
  const confirm = state.items[0]
138
139
  expect(confirm?.type).toBe('confirm')
@@ -147,14 +148,14 @@ describe('dialog slice reducers', () => {
147
148
  dialogState(),
148
149
  dialogActions.showConfirmAssetsTagAdd({
149
150
  assetsPicked: [assetItem(), assetItem(a2)],
150
- tag: sampleTag
151
- })
151
+ tag: sampleTag,
152
+ }),
152
153
  )
153
154
  const confirm = state.items[0]
154
155
  expect(confirm && 'title' in confirm && confirm.title).toContain('2 assets')
155
156
  const cb = confirm && 'confirmCallbackAction' in confirm ? confirm.confirmCallbackAction : null
156
157
  expect(cb).toEqual(
157
- ASSETS_ACTIONS.tagsAddRequest({assets: [assetItem(), assetItem(a2)], tag: sampleTag})
158
+ ASSETS_ACTIONS.tagsAddRequest({assets: [assetItem(), assetItem(a2)], tag: sampleTag}),
158
159
  )
159
160
  })
160
161
 
@@ -163,8 +164,8 @@ describe('dialog slice reducers', () => {
163
164
  dialogState(),
164
165
  dialogActions.showConfirmAssetsTagRemove({
165
166
  assetsPicked: [assetItem()],
166
- tag: sampleTag
167
- })
167
+ tag: sampleTag,
168
+ }),
168
169
  )
169
170
  const confirm = state.items[0]
170
171
  expect(confirm && 'tone' in confirm && confirm.tone).toBe('critical')
@@ -2,7 +2,7 @@ import {
2
2
  type ActionFromReducersMapObject,
3
3
  type Reducer,
4
4
  type StateFromReducersMapObject,
5
- combineReducers
5
+ combineReducers,
6
6
  } from '@reduxjs/toolkit'
7
7
  import {combineEpics} from 'redux-observable'
8
8
 
@@ -21,15 +21,14 @@ import assetsReducer, {
21
21
  assetsTagsAddEpic,
22
22
  assetsTagsRemoveEpic,
23
23
  assetsUnpickEpic,
24
- assetsUpdateEpic
24
+ assetsUpdateEpic,
25
25
  } from './assets'
26
26
  import debugReducer from './debug'
27
27
  import dialogReducer, {
28
28
  dialogClearOnAssetUpdateEpic,
29
29
  dialogTagCreateEpic,
30
- dialogTagDeleteEpic
30
+ dialogTagDeleteEpic,
31
31
  } from './dialog'
32
- import selectedReducer from './selected'
33
32
  import notificationsReducer, {
34
33
  notificationsAssetsDeleteErrorEpic,
35
34
  notificationsAssetsDeleteCompleteEpic,
@@ -39,9 +38,10 @@ import notificationsReducer, {
39
38
  notificationsGenericErrorEpic,
40
39
  notificationsTagCreateCompleteEpic,
41
40
  notificationsTagDeleteCompleteEpic,
42
- notificationsTagUpdateCompleteEpic
41
+ notificationsTagUpdateCompleteEpic,
43
42
  } from './notifications'
44
43
  import searchReducer, {searchFacetTagUpdateEpic} from './search'
44
+ import selectedReducer from './selected'
45
45
  import tagsReducer, {
46
46
  tagsCreateEpic,
47
47
  tagsDeleteEpic,
@@ -50,13 +50,13 @@ import tagsReducer, {
50
50
  tagsListenerDeleteQueueEpic,
51
51
  tagsListenerUpdateQueueEpic,
52
52
  tagsSortEpic,
53
- tagsUpdateEpic
53
+ tagsUpdateEpic,
54
54
  } from './tags'
55
55
  import uploadsReducer, {
56
56
  uploadsAssetStartEpic,
57
57
  uploadsAssetUploadEpic,
58
58
  uploadsCheckRequestEpic,
59
- uploadsCompleteQueueEpic
59
+ uploadsCompleteQueueEpic,
60
60
  } from './uploads'
61
61
 
62
62
  export const rootEpic = combineEpics(
@@ -99,7 +99,7 @@ export const rootEpic = combineEpics(
99
99
  uploadsAssetStartEpic,
100
100
  uploadsAssetUploadEpic,
101
101
  uploadsCheckRequestEpic,
102
- uploadsCompleteQueueEpic
102
+ uploadsCompleteQueueEpic,
103
103
  )
104
104
 
105
105
  const reducers = {
@@ -110,7 +110,7 @@ const reducers = {
110
110
  search: searchReducer,
111
111
  selected: selectedReducer,
112
112
  tags: tagsReducer,
113
- uploads: uploadsReducer
113
+ uploads: uploadsReducer,
114
114
  }
115
115
 
116
116
  type ReducersMapObject = typeof reducers
@@ -1,6 +1,14 @@
1
1
  // @vitest-environment node
2
2
 
3
3
  import {describe, expect, it, vi} from 'vitest'
4
+
5
+ import {createEpicTestStore} from '../../__tests__/fixtures/createEpicTestStore'
6
+ import {createMockSanityClient} from '../../__tests__/fixtures/mockSanityClient'
7
+ import type {AssetItem, AssetType, ImageAsset, Tag} from '../../types'
8
+ import {assetsActions, initialState as assetsInitialState} from '../assets'
9
+ import {ASSETS_ACTIONS} from '../assets/actions'
10
+ import {tagsActions} from '../tags'
11
+ import {uploadsActions} from '../uploads'
4
12
  import {
5
13
  notificationsAssetsDeleteCompleteEpic,
6
14
  notificationsAssetsDeleteErrorEpic,
@@ -11,15 +19,8 @@ import {
11
19
  notificationsGenericErrorEpic,
12
20
  notificationsTagCreateCompleteEpic,
13
21
  notificationsTagDeleteCompleteEpic,
14
- notificationsTagUpdateCompleteEpic
22
+ notificationsTagUpdateCompleteEpic,
15
23
  } from './index'
16
- import {assetsActions, initialState as assetsInitialState} from '../assets'
17
- import {ASSETS_ACTIONS} from '../assets/actions'
18
- import {tagsActions} from '../tags'
19
- import {uploadsActions} from '../uploads'
20
- import {createEpicTestStore} from '../../__tests__/fixtures/createEpicTestStore'
21
- import {createMockSanityClient} from '../../__tests__/fixtures/mockSanityClient'
22
- import type {AssetItem, AssetType, ImageAsset, Tag} from '../../types'
23
24
 
24
25
  const sampleAsset = {
25
26
  _id: 'a1',
@@ -30,12 +31,12 @@ const sampleAsset = {
30
31
  originalFilename: 'x.png',
31
32
  size: 1,
32
33
  mimeType: 'image/png',
33
- url: 'https://example.com/x.png'
34
+ url: 'https://example.com/x.png',
34
35
  } as ImageAsset
35
36
 
36
37
  const sampleAsset2 = {
37
38
  ...sampleAsset,
38
- _id: 'a2'
39
+ _id: 'a2',
39
40
  } as ImageAsset
40
41
 
41
42
  const sampleTag: Tag = {
@@ -44,14 +45,14 @@ const sampleTag: Tag = {
44
45
  _createdAt: '',
45
46
  _updatedAt: '',
46
47
  _rev: 'tr',
47
- name: {_type: 'slug', current: 'alpha'}
48
+ name: {_type: 'slug', current: 'alpha'},
48
49
  }
49
50
 
50
51
  const assetItem = (asset: ImageAsset): AssetItem => ({
51
52
  _type: 'asset',
52
53
  asset,
53
54
  picked: false,
54
- updating: false
55
+ updating: false,
55
56
  })
56
57
 
57
58
  function assetsWithRows(rows: Record<string, AssetItem>) {
@@ -59,7 +60,7 @@ function assetsWithRows(rows: Record<string, AssetItem>) {
59
60
  ...assetsInitialState,
60
61
  assetTypes: ['image'] as AssetType[],
61
62
  allIds: Object.keys(rows),
62
- byIds: rows
63
+ byIds: rows,
63
64
  }
64
65
  }
65
66
 
@@ -68,12 +69,12 @@ describe('notificationsAssetsDeleteCompleteEpic', () => {
68
69
  const store = createEpicTestStore(
69
70
  notificationsAssetsDeleteCompleteEpic,
70
71
  createMockSanityClient({}),
71
- {}
72
+ {},
72
73
  )
73
74
  store.dispatch(assetsActions.deleteComplete({assetIds: ['x', 'y']}))
74
75
  await vi.waitFor(() => {
75
76
  expect(store.getState().notifications.items).toEqual([
76
- {asset: undefined, status: 'info', title: '2 assets deleted'}
77
+ {asset: undefined, status: 'info', title: '2 assets deleted'},
77
78
  ])
78
79
  })
79
80
  })
@@ -86,16 +87,16 @@ describe('notificationsAssetsDeleteErrorEpic', () => {
86
87
  createMockSanityClient({}),
87
88
  {
88
89
  assets: assetsWithRows({
89
- a1: {...assetItem(sampleAsset), updating: true}
90
- })
91
- }
90
+ a1: {...assetItem(sampleAsset), updating: true},
91
+ }),
92
+ },
92
93
  )
93
94
  store.dispatch(assetsActions.deleteError({assetIds: ['a1'], error: {} as any}))
94
95
  await vi.waitFor(() => {
95
96
  const [n] = store.getState().notifications.items
96
97
  expect(n.status).toBe('error')
97
98
  expect(n.title).toBe(
98
- 'Unable to delete 1 asset. Please review any asset errors and try again.'
99
+ 'Unable to delete 1 asset. Please review any asset errors and try again.',
99
100
  )
100
101
  })
101
102
  })
@@ -106,16 +107,16 @@ describe('notificationsAssetsUploadCompleteEpic', () => {
106
107
  const store = createEpicTestStore(
107
108
  notificationsAssetsUploadCompleteEpic,
108
109
  createMockSanityClient({}),
109
- {}
110
+ {},
110
111
  )
111
112
  store.dispatch(
112
113
  uploadsActions.checkComplete({
113
- results: {h1: 'id1', h2: null}
114
- })
114
+ results: {h1: 'id1', h2: null},
115
+ }),
115
116
  )
116
117
  await vi.waitFor(() => {
117
118
  expect(store.getState().notifications.items).toEqual([
118
- {asset: undefined, status: 'info', title: 'Uploaded 2 assets'}
119
+ {asset: undefined, status: 'info', title: 'Uploaded 2 assets'},
119
120
  ])
120
121
  })
121
122
  })
@@ -124,12 +125,12 @@ describe('notificationsAssetsUploadCompleteEpic', () => {
124
125
  const tagsWithTagUpdating = {
125
126
  allIds: ['t1'],
126
127
  byIds: {
127
- t1: {_type: 'tag' as const, tag: sampleTag, picked: false, updating: true}
128
+ t1: {_type: 'tag' as const, tag: sampleTag, picked: false, updating: true},
128
129
  },
129
130
  creating: false,
130
131
  fetchCount: -1,
131
132
  fetching: false,
132
- panelVisible: true
133
+ panelVisible: true,
133
134
  }
134
135
 
135
136
  describe('notificationsAssetsTagsAddCompleteEpic', () => {
@@ -140,20 +141,20 @@ describe('notificationsAssetsTagsAddCompleteEpic', () => {
140
141
  {
141
142
  assets: assetsWithRows({
142
143
  a1: {...assetItem(sampleAsset), updating: true},
143
- a2: {...assetItem(sampleAsset2), updating: true}
144
+ a2: {...assetItem(sampleAsset2), updating: true},
144
145
  }),
145
- tags: tagsWithTagUpdating
146
- }
146
+ tags: tagsWithTagUpdating,
147
+ },
147
148
  )
148
149
  store.dispatch(
149
150
  ASSETS_ACTIONS.tagsAddComplete({
150
151
  assets: [assetItem(sampleAsset), assetItem(sampleAsset2)],
151
- tag: sampleTag
152
- })
152
+ tag: sampleTag,
153
+ }),
153
154
  )
154
155
  await vi.waitFor(() => {
155
156
  expect(store.getState().notifications.items).toEqual([
156
- {asset: undefined, status: 'info', title: 'Tag added to 2 assets'}
157
+ {asset: undefined, status: 'info', title: 'Tag added to 2 assets'},
157
158
  ])
158
159
  })
159
160
  })
@@ -166,20 +167,20 @@ describe('notificationsAssetsTagsRemoveCompleteEpic', () => {
166
167
  createMockSanityClient({}),
167
168
  {
168
169
  assets: assetsWithRows({
169
- a1: {...assetItem(sampleAsset), updating: true}
170
+ a1: {...assetItem(sampleAsset), updating: true},
170
171
  }),
171
- tags: tagsWithTagUpdating
172
- }
172
+ tags: tagsWithTagUpdating,
173
+ },
173
174
  )
174
175
  store.dispatch(
175
176
  ASSETS_ACTIONS.tagsRemoveComplete({
176
177
  assets: [assetItem(sampleAsset)],
177
- tag: sampleTag
178
- })
178
+ tag: sampleTag,
179
+ }),
179
180
  )
180
181
  await vi.waitFor(() => {
181
182
  expect(store.getState().notifications.items).toEqual([
182
- {asset: undefined, status: 'info', title: 'Tag removed from 1 asset'}
183
+ {asset: undefined, status: 'info', title: 'Tag removed from 1 asset'},
183
184
  ])
184
185
  })
185
186
  })
@@ -194,9 +195,9 @@ describe('notificationsAssetsUpdateCompleteEpic', () => {
194
195
  {
195
196
  assets: assetsWithRows({
196
197
  a1: {...assetItem(sampleAsset), updating: true},
197
- a2: {...assetItem(sampleAsset2), updating: true}
198
- })
199
- }
198
+ a2: {...assetItem(sampleAsset2), updating: true},
199
+ }),
200
+ },
200
201
  )
201
202
 
202
203
  store.dispatch(assetsActions.updateComplete({asset: sampleAsset}))
@@ -204,7 +205,7 @@ describe('notificationsAssetsUpdateCompleteEpic', () => {
204
205
  await vi.advanceTimersByTimeAsync(2000)
205
206
 
206
207
  expect(store.getState().notifications.items).toEqual([
207
- {asset: undefined, status: 'info', title: '2 assets updated'}
208
+ {asset: undefined, status: 'info', title: '2 assets updated'},
208
209
  ])
209
210
  vi.useRealTimers()
210
211
  })
@@ -217,9 +218,9 @@ describe('notificationsAssetsUpdateCompleteEpic', () => {
217
218
  {
218
219
  assets: assetsWithRows({
219
220
  a1: {...assetItem(sampleAsset), updating: true},
220
- a2: {...assetItem(sampleAsset2), updating: true}
221
- })
222
- }
221
+ a2: {...assetItem(sampleAsset2), updating: true},
222
+ }),
223
+ },
223
224
  )
224
225
 
225
226
  store.dispatch(assetsActions.updateComplete({asset: sampleAsset}))
@@ -229,7 +230,7 @@ describe('notificationsAssetsUpdateCompleteEpic', () => {
229
230
 
230
231
  expect(store.getState().notifications.items).toEqual([
231
232
  {asset: undefined, status: 'info', title: '1 asset updated'},
232
- {asset: undefined, status: 'info', title: '1 asset updated'}
233
+ {asset: undefined, status: 'info', title: '1 asset updated'},
233
234
  ])
234
235
  vi.useRealTimers()
235
236
  })
@@ -239,18 +240,18 @@ describe('notificationsGenericErrorEpic', () => {
239
240
  it('maps assets.updateError to error notification title', async () => {
240
241
  const store = createEpicTestStore(notificationsGenericErrorEpic, createMockSanityClient({}), {
241
242
  assets: assetsWithRows({
242
- a1: {...assetItem(sampleAsset), updating: true}
243
- })
243
+ a1: {...assetItem(sampleAsset), updating: true},
244
+ }),
244
245
  })
245
246
  store.dispatch(
246
247
  assetsActions.updateError({
247
248
  asset: sampleAsset,
248
- error: {message: 'patch failed', statusCode: 500}
249
- })
249
+ error: {message: 'patch failed', statusCode: 500},
250
+ }),
250
251
  )
251
252
  await vi.waitFor(() => {
252
253
  expect(store.getState().notifications.items).toEqual([
253
- {asset: undefined, status: 'error', title: 'An error occurred: patch failed'}
254
+ {asset: undefined, status: 'error', title: 'An error occurred: patch failed'},
254
255
  ])
255
256
  })
256
257
  })
@@ -260,14 +261,14 @@ describe('notificationsGenericErrorEpic', () => {
260
261
  assets: {
261
262
  ...assetsInitialState,
262
263
  assetTypes: ['image'] as AssetType[],
263
- fetching: true
264
- }
264
+ fetching: true,
265
+ },
265
266
  })
266
267
  store.dispatch(
267
268
  assetsActions.fetchError({
268
269
  message: 'fetch failed',
269
- statusCode: 503
270
- })
270
+ statusCode: 503,
271
+ }),
271
272
  )
272
273
  await vi.waitFor(() => {
273
274
  expect(store.getState().notifications.items[0].title).toBe('An error occurred: fetch failed')
@@ -283,14 +284,14 @@ describe('notificationsGenericErrorEpic', () => {
283
284
  byIds: {},
284
285
  fetchCount: -1,
285
286
  fetching: false,
286
- panelVisible: true
287
- } as any
287
+ panelVisible: true,
288
+ } as any,
288
289
  })
289
290
  store.dispatch(
290
291
  tagsActions.createError({
291
292
  name: 'n',
292
- error: {message: 'tag create', statusCode: 400}
293
- })
293
+ error: {message: 'tag create', statusCode: 400},
294
+ }),
294
295
  )
295
296
  await vi.waitFor(() => {
296
297
  expect(store.getState().notifications.items[0].title).toBe('An error occurred: tag create')
@@ -299,13 +300,13 @@ describe('notificationsGenericErrorEpic', () => {
299
300
 
300
301
  it('maps uploads.uploadError to error notification title', async () => {
301
302
  const store = createEpicTestStore(notificationsGenericErrorEpic, createMockSanityClient({}), {
302
- uploads: {allIds: ['h'], byIds: {h: {} as any}}
303
+ uploads: {allIds: ['h'], byIds: {h: {} as any}},
303
304
  })
304
305
  store.dispatch(
305
306
  uploadsActions.uploadError({
306
307
  hash: 'h',
307
- error: {message: 'upload bad', statusCode: 413}
308
- })
308
+ error: {message: 'upload bad', statusCode: 413},
309
+ }),
309
310
  )
310
311
  await vi.waitFor(() => {
311
312
  expect(store.getState().notifications.items[0].title).toBe('An error occurred: upload bad')
@@ -318,12 +319,12 @@ describe('notificationsTagCreateCompleteEpic', () => {
318
319
  const store = createEpicTestStore(
319
320
  notificationsTagCreateCompleteEpic,
320
321
  createMockSanityClient({}),
321
- {}
322
+ {},
322
323
  )
323
324
  store.dispatch(tagsActions.createComplete({tag: sampleTag}))
324
325
  await vi.waitFor(() => {
325
326
  expect(store.getState().notifications.items).toEqual([
326
- {asset: undefined, status: 'info', title: 'Tag created'}
327
+ {asset: undefined, status: 'info', title: 'Tag created'},
327
328
  ])
328
329
  })
329
330
  })
@@ -334,12 +335,12 @@ describe('notificationsTagDeleteCompleteEpic', () => {
334
335
  const store = createEpicTestStore(
335
336
  notificationsTagDeleteCompleteEpic,
336
337
  createMockSanityClient({}),
337
- {}
338
+ {},
338
339
  )
339
340
  store.dispatch(tagsActions.deleteComplete({tagId: 't1'}))
340
341
  await vi.waitFor(() => {
341
342
  expect(store.getState().notifications.items).toEqual([
342
- {asset: undefined, status: 'info', title: 'Tag deleted'}
343
+ {asset: undefined, status: 'info', title: 'Tag deleted'},
343
344
  ])
344
345
  })
345
346
  })
@@ -354,19 +355,19 @@ describe('notificationsTagUpdateCompleteEpic', () => {
354
355
  tags: {
355
356
  allIds: ['t1'],
356
357
  byIds: {
357
- t1: {_type: 'tag', tag: sampleTag, picked: false, updating: true}
358
+ t1: {_type: 'tag', tag: sampleTag, picked: false, updating: true},
358
359
  },
359
360
  creating: false,
360
361
  fetchCount: -1,
361
362
  fetching: false,
362
- panelVisible: true
363
- }
364
- }
363
+ panelVisible: true,
364
+ },
365
+ },
365
366
  )
366
367
  store.dispatch(tagsActions.updateComplete({tag: sampleTag}))
367
368
  await vi.waitFor(() => {
368
369
  expect(store.getState().notifications.items).toEqual([
369
- {asset: undefined, status: 'info', title: 'Tag updated'}
370
+ {asset: undefined, status: 'info', title: 'Tag updated'},
370
371
  ])
371
372
  })
372
373
  })