slice-machine-ui 1.22.3-beta.1 → 1.22.3-beta.3
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/components/DeleteVariationModal/index.tsx +12 -11
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +2 -5
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +9 -5
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +12 -11
- package/components/ItemHeader/index.tsx +1 -0
- package/components/ListItem/index.tsx +5 -2
- package/components/ScreenshotChangesModal/VariationDropZone.tsx +31 -9
- package/components/ScreenshotChangesModal/index.tsx +3 -0
- package/components/ScreenshotChangesModal/useCustomScreenshot.tsx +5 -5
- package/components/Simulator/index.tsx +9 -3
- package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +2 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +2 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -20
- package/lib/builders/CustomTypeBuilder/TabModal/update.tsx +3 -1
- package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +119 -52
- package/lib/builders/CustomTypeBuilder/index.tsx +39 -42
- package/lib/builders/SliceBuilder/FieldZones/index.tsx +81 -56
- package/lib/builders/SliceBuilder/Sidebar/AddVariationModal.tsx +24 -16
- package/lib/builders/SliceBuilder/Sidebar/index.tsx +44 -46
- package/lib/builders/SliceBuilder/SimulatorButton/index.tsx +4 -28
- package/lib/builders/SliceBuilder/index.tsx +10 -96
- package/lib/builders/common/Zone/Card/components/Hints/CodeBlock.tsx +5 -1
- package/lib/builders/common/Zone/Card/components/NewField.tsx +16 -15
- package/lib/builders/common/Zone/Card/index.jsx +2 -0
- package/lib/builders/common/Zone/index.jsx +3 -1
- package/lib/models/common/ComponentUI.ts +0 -14
- package/lib/models/common/CustomType/sliceZone.ts +0 -29
- package/lib/models/common/CustomType/tab.ts +10 -142
- package/lib/models/common/widgets/Group/ListItem/index.jsx +61 -23
- package/out/404.html +1 -1
- package/out/_next/static/chunks/065a3ddb-9a38ca0d60f0bf2f.js +1 -0
- package/out/_next/static/chunks/183-4feb6bb3eddbc768.js +1 -0
- package/out/_next/static/chunks/18539003-7b2711e6c51d6fac.js +97 -0
- package/out/_next/static/chunks/1cc2734a-2c5b6c0367fcde86.js +1 -0
- package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +1 -0
- package/out/_next/static/chunks/318-541db69860d31138.js +1 -0
- package/out/_next/static/chunks/{505-3f1cf09a086dcba8.js → 376-0ed5822f8afcaa7c.js} +3 -3
- package/out/_next/static/chunks/4c744e84-e3161d754618373f.js +1 -0
- package/out/_next/static/chunks/50-cfc2514205b86001.js +1 -0
- package/out/_next/static/chunks/543-f8766685f7f451e2.js +1 -0
- package/out/_next/static/chunks/59b4e022-7a3b5554b806349f.js +1 -0
- package/out/_next/static/chunks/696-b12edad30a3617e5.js +31 -0
- package/out/_next/static/chunks/727-15cf3f2fea9a37e5.js +1 -0
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +1 -0
- package/out/_next/static/chunks/787-727e3aef5d2a10a8.js +1 -0
- package/out/_next/static/chunks/904-ccd8ca3368ce29fc.js +1 -0
- package/out/_next/static/chunks/{918-38d08f1e885b222d.js → 918-5bb55fb464e34768.js} +1 -1
- package/out/_next/static/chunks/f36c6662-03bb5e9d9aa0b0aa.js +1 -0
- package/out/_next/static/chunks/pages/_app-20876abeebe0fda7.js +430 -0
- package/out/_next/static/chunks/pages/changelog-68d115a14f1423d7.js +1 -0
- package/out/_next/static/chunks/pages/changes-6f62ae7b6243a1c7.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3a37eb3373bb8823.js → [customTypeId]-3f862ad6111a1fc0.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-2f5664d9492b13fb.js → custom-types-94b8f8dbf7727412.js} +1 -1
- package/out/_next/static/chunks/pages/{index-d8e3a2c0d712904f.js → index-64cfb8b0948ba8ef.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-733f3890c0466a05.js → [pageTypeId]-d1ffca11c42f2603.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-e89e2e6f772a3454.js +1 -0
- package/out/_next/static/chunks/pages/slices-9628f8aa54968d6a.js +1 -0
- package/out/_next/static/css/{1bbf650dfd37ce69.css → 1aa04669758c24f4.css} +1 -1
- package/out/_next/static/j_voPTrYzsuLCERqtl3Hn/_buildManifest.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +6 -6
- package/pages/slices/[lib]/[sliceName]/[variation]/index.tsx +25 -11
- package/pages/slices/[lib]/[sliceName]/[variation]/simulator.tsx +12 -9
- package/src/apiClient.ts +7 -6
- package/src/components/CodeBlock/CodeBlock.tsx +1 -0
- package/src/components/Window/Window.tsx +7 -1
- package/src/domain/__tests__/customType.test.ts +785 -0
- package/src/domain/customType.ts +519 -6
- package/src/domain/slice.ts +166 -1
- package/src/features/autoSave/AutoSaveStatusIndicator.tsx +43 -0
- package/src/features/autoSave/useAutoSave.tsx +177 -0
- package/src/features/customTypes/EditDropdown.tsx +3 -0
- package/src/features/customTypes/actions/convertCustomToPageType.ts +2 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +90 -0
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +46 -79
- package/src/features/customTypes/customTypesMessages.ts +4 -0
- package/src/features/slices/actions/addSlicesToSliceZone.ts +2 -7
- package/src/features/slices/actions/uploadSliceScreenshot.ts +45 -0
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +5 -5
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +4 -10
- package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +110 -0
- package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +8 -24
- package/src/features/slices/sliceBuilder/actions/renameVariation.ts +8 -24
- package/src/features/slices/sliceCards/SharedSliceCard.tsx +1 -0
- package/src/hooks/useCurrentSlice.tsx +4 -16
- package/src/hooks/useScreenshotChangesModal.ts +1 -0
- package/src/hooks/useServerState.ts +1 -58
- package/src/modules/availableCustomTypes/index.ts +8 -3
- package/src/modules/simulator/index.ts +0 -2
- package/src/modules/slices/index.ts +32 -25
- package/src/modules/slices/selector.ts +30 -0
- package/src/modules/useSliceMachineActions.ts +20 -270
- package/src/redux/reducer.ts +0 -4
- package/src/redux/saga.ts +0 -6
- package/src/redux/type.ts +0 -4
- package/test/src/modules/availableCustomTypes/index.test.ts +8 -10
- package/test/src/modules/simulator.test.ts +0 -2
- package/lib/models/common/CustomType/group.ts +0 -80
- package/lib/models/common/Variation.ts +0 -100
- package/out/_next/static/ZrWICkLApT4ZATA_akn-2/_buildManifest.js +0 -1
- package/out/_next/static/chunks/18539003-4460ccbfe3109578.js +0 -97
- package/out/_next/static/chunks/482-34cee2a2071c235f.js +0 -1
- package/out/_next/static/chunks/550-c80fd46fb64d1eef.js +0 -1
- package/out/_next/static/chunks/80-7b8a97d0122ff74a.js +0 -1
- package/out/_next/static/chunks/840-163f8a1040e6820d.js +0 -1
- package/out/_next/static/chunks/904-519dbf0f7e8c6243.js +0 -1
- package/out/_next/static/chunks/958-8aca174b80cb0c35.js +0 -1
- package/out/_next/static/chunks/pages/_app-132564608e9a9502.js +0 -458
- package/out/_next/static/chunks/pages/changelog-4d0f2f1222e403fe.js +0 -1
- package/out/_next/static/chunks/pages/changes-52c9d917808d1461.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-7b17cb59d0db03b5.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ef11594ce026b650.js +0 -1
- package/out/_next/static/chunks/pages/slices-884a936a9a062a65.js +0 -1
- package/src/domain/__tests__/CustomTypeModel.test.ts +0 -247
- package/src/layouts/WithSlice.tsx +0 -26
- package/src/modules/screenshots/actions.ts +0 -21
- package/src/modules/screenshots/sagas.ts +0 -70
- package/src/modules/selectedCustomType/actions.ts +0 -147
- package/src/modules/selectedCustomType/index.ts +0 -11
- package/src/modules/selectedCustomType/reducer.ts +0 -287
- package/src/modules/selectedCustomType/sagas.ts +0 -72
- package/src/modules/selectedCustomType/selectors.ts +0 -33
- package/src/modules/selectedCustomType/stateHelpers.ts +0 -42
- package/src/modules/selectedCustomType/types.ts +0 -9
- package/src/modules/selectedSlice/actions.ts +0 -106
- package/src/modules/selectedSlice/reducer.ts +0 -175
- package/src/modules/selectedSlice/sagas.ts +0 -72
- package/src/modules/selectedSlice/selectors.ts +0 -55
- package/src/modules/selectedSlice/types.ts +0 -3
- package/src/modules/toaster/utils.tsx +0 -23
- package/test/lib/models/common/CustomType/sliceZone.test.ts +0 -49
- package/test/pages/custom-types.test.tsx +0 -625
- package/test/src/modules/selectedCustomType/__fixtures__/model.json +0 -119
- package/test/src/modules/selectedCustomType/reducer.test.ts +0 -322
- package/test/src/modules/selectedCustomType/sagas.test.ts +0 -89
- package/test/src/modules/selectedCustomType/selectors.test.ts +0 -54
- package/test/src/modules/selectedSlice/__fixtures__/mocks.json +0 -171
- package/test/src/modules/selectedSlice/__fixtures__/model.json +0 -35
- package/test/src/modules/selectedSlice/__testutils__/getRefreshStateCreatorPayloadData.ts +0 -72
- package/test/src/modules/selectedSlice/__testutils__/getSelectedSliceDummyData.ts +0 -30
- package/test/src/modules/selectedSlice/reducer.test.ts +0 -170
- package/test/src/modules/selectedSlice/sagas.test.ts +0 -82
- package/test/src/modules/toaster/utils.test.ts +0 -50
- /package/out/_next/static/{ZrWICkLApT4ZATA_akn-2 → j_voPTrYzsuLCERqtl3Hn}/_ssgManifest.js +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"__TYPE__": "SharedSliceContent",
|
|
4
|
-
"variation": "default-slice",
|
|
5
|
-
"primary": {
|
|
6
|
-
"linkLabel": {
|
|
7
|
-
"__TYPE__": "FieldContent",
|
|
8
|
-
"value": "speed",
|
|
9
|
-
"type": "Text"
|
|
10
|
-
},
|
|
11
|
-
"title": {
|
|
12
|
-
"__TYPE__": "StructuredTextContent",
|
|
13
|
-
"value": [
|
|
14
|
-
{
|
|
15
|
-
"type": "heading1",
|
|
16
|
-
"content": {
|
|
17
|
-
"text": "Higher"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
"link": {
|
|
23
|
-
"__TYPE__": "LinkContent",
|
|
24
|
-
"value": {
|
|
25
|
-
"id": "mock_document_id",
|
|
26
|
-
"__TYPE__": "DocumentLink"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"imageLeft": {
|
|
30
|
-
"__TYPE__": "ImageContent",
|
|
31
|
-
"url": "https://images.unsplash.com/photo-1551739440-5dd934d3a94a?fit=crop&w=592&h=592",
|
|
32
|
-
"origin": {
|
|
33
|
-
"id": "main",
|
|
34
|
-
"url": "https://images.unsplash.com/photo-1551739440-5dd934d3a94a",
|
|
35
|
-
"width": 592,
|
|
36
|
-
"height": 592
|
|
37
|
-
},
|
|
38
|
-
"width": 592,
|
|
39
|
-
"height": 592,
|
|
40
|
-
"edit": {
|
|
41
|
-
"zoom": 1,
|
|
42
|
-
"crop": {
|
|
43
|
-
"x": 0,
|
|
44
|
-
"y": 0
|
|
45
|
-
},
|
|
46
|
-
"background": "transparent"
|
|
47
|
-
},
|
|
48
|
-
"thumbnails": {
|
|
49
|
-
"mobile": {
|
|
50
|
-
"url": "https://images.unsplash.com/photo-1515378791036-0648a3ef77b2?fit=crop&w=560&h=280",
|
|
51
|
-
"origin": {
|
|
52
|
-
"id": "mobile",
|
|
53
|
-
"url": "https://images.unsplash.com/photo-1515378791036-0648a3ef77b2",
|
|
54
|
-
"width": 560,
|
|
55
|
-
"height": 280
|
|
56
|
-
},
|
|
57
|
-
"width": 560,
|
|
58
|
-
"height": 280,
|
|
59
|
-
"edit": {
|
|
60
|
-
"zoom": 1,
|
|
61
|
-
"crop": {
|
|
62
|
-
"x": 0,
|
|
63
|
-
"y": 0
|
|
64
|
-
},
|
|
65
|
-
"background": "transparent"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"imageLeftTitle": {
|
|
71
|
-
"__TYPE__": "FieldContent",
|
|
72
|
-
"value": "rate",
|
|
73
|
-
"type": "Text"
|
|
74
|
-
},
|
|
75
|
-
"imageLeftCta": {
|
|
76
|
-
"__TYPE__": "FieldContent",
|
|
77
|
-
"value": "funny",
|
|
78
|
-
"type": "Text"
|
|
79
|
-
},
|
|
80
|
-
"leftImageLink": {
|
|
81
|
-
"__TYPE__": "LinkContent",
|
|
82
|
-
"value": {
|
|
83
|
-
"id": "mock_document_id",
|
|
84
|
-
"__TYPE__": "DocumentLink"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"imageTopRight": {
|
|
88
|
-
"__TYPE__": "ImageContent",
|
|
89
|
-
"url": "https://images.unsplash.com/photo-1600861194802-a2b11076bc51?fit=crop&w=592&h=280",
|
|
90
|
-
"origin": {
|
|
91
|
-
"id": "main",
|
|
92
|
-
"url": "https://images.unsplash.com/photo-1600861194802-a2b11076bc51",
|
|
93
|
-
"width": 592,
|
|
94
|
-
"height": 280
|
|
95
|
-
},
|
|
96
|
-
"width": 592,
|
|
97
|
-
"height": 280,
|
|
98
|
-
"edit": {
|
|
99
|
-
"zoom": 1,
|
|
100
|
-
"crop": {
|
|
101
|
-
"x": 0,
|
|
102
|
-
"y": 0
|
|
103
|
-
},
|
|
104
|
-
"background": "transparent"
|
|
105
|
-
},
|
|
106
|
-
"thumbnails": {}
|
|
107
|
-
},
|
|
108
|
-
"imageTopRightTitle": {
|
|
109
|
-
"__TYPE__": "FieldContent",
|
|
110
|
-
"value": "soil",
|
|
111
|
-
"type": "Text"
|
|
112
|
-
},
|
|
113
|
-
"imageTopRightCta": {
|
|
114
|
-
"__TYPE__": "FieldContent",
|
|
115
|
-
"value": "printed",
|
|
116
|
-
"type": "Text"
|
|
117
|
-
},
|
|
118
|
-
"topRightImageLink": {
|
|
119
|
-
"__TYPE__": "LinkContent",
|
|
120
|
-
"value": {
|
|
121
|
-
"id": "mock_document_id",
|
|
122
|
-
"__TYPE__": "DocumentLink"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
"imageBottomRight": {
|
|
126
|
-
"__TYPE__": "ImageContent",
|
|
127
|
-
"url": "https://images.unsplash.com/photo-1607582278043-57198ac8da43?fit=crop&w=592&h=280",
|
|
128
|
-
"origin": {
|
|
129
|
-
"id": "main",
|
|
130
|
-
"url": "https://images.unsplash.com/photo-1607582278043-57198ac8da43",
|
|
131
|
-
"width": 592,
|
|
132
|
-
"height": 280
|
|
133
|
-
},
|
|
134
|
-
"width": 592,
|
|
135
|
-
"height": 280,
|
|
136
|
-
"edit": {
|
|
137
|
-
"zoom": 1,
|
|
138
|
-
"crop": {
|
|
139
|
-
"x": 0,
|
|
140
|
-
"y": 0
|
|
141
|
-
},
|
|
142
|
-
"background": "transparent"
|
|
143
|
-
},
|
|
144
|
-
"thumbnails": {}
|
|
145
|
-
},
|
|
146
|
-
"imageBottomRightTitle": {
|
|
147
|
-
"__TYPE__": "FieldContent",
|
|
148
|
-
"value": "smile",
|
|
149
|
-
"type": "Text"
|
|
150
|
-
},
|
|
151
|
-
"imageBottomRightCta": {
|
|
152
|
-
"__TYPE__": "FieldContent",
|
|
153
|
-
"value": "exchange",
|
|
154
|
-
"type": "Text"
|
|
155
|
-
},
|
|
156
|
-
"bottomRightImageLink": {
|
|
157
|
-
"__TYPE__": "LinkContent",
|
|
158
|
-
"value": {
|
|
159
|
-
"id": "mock_document_id",
|
|
160
|
-
"__TYPE__": "DocumentLink"
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
"items": [
|
|
165
|
-
{
|
|
166
|
-
"__TYPE__": "GroupItemContent",
|
|
167
|
-
"value": []
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
]
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "dummy_slice",
|
|
3
|
-
"type": "SharedSlice",
|
|
4
|
-
"name": "DummySlice",
|
|
5
|
-
"description": "DummySlice",
|
|
6
|
-
"variations": [
|
|
7
|
-
{
|
|
8
|
-
"id": "default-slice",
|
|
9
|
-
"name": "Default slice",
|
|
10
|
-
"docURL": "...",
|
|
11
|
-
"version": "sktwi1xtmkfgx8626",
|
|
12
|
-
"description": "DummySlice",
|
|
13
|
-
"primary": {
|
|
14
|
-
"section_title": {
|
|
15
|
-
"config": {
|
|
16
|
-
"label": "Section Title",
|
|
17
|
-
"placeholder": ""
|
|
18
|
-
},
|
|
19
|
-
"type": "Text"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"items": {
|
|
23
|
-
"link": {
|
|
24
|
-
"config": {
|
|
25
|
-
"label": "Link",
|
|
26
|
-
"placeholder": "",
|
|
27
|
-
"select": "document",
|
|
28
|
-
"allowTargetBlank": false
|
|
29
|
-
},
|
|
30
|
-
"type": "Link"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { dummyServerState } from "../../__fixtures__/serverState";
|
|
2
|
-
import { LibraryUI } from "@lib/models/common/LibraryUI";
|
|
3
|
-
|
|
4
|
-
export const getRefreshStateCreatorPayloadData = (
|
|
5
|
-
libraryName: string,
|
|
6
|
-
modelId: string,
|
|
7
|
-
) => {
|
|
8
|
-
const MOCK_UPDATED_LIBRARY: LibraryUI[] = [
|
|
9
|
-
{
|
|
10
|
-
path: "../../e2e-projects/next/slices/ecommerce",
|
|
11
|
-
isLocal: true,
|
|
12
|
-
name: libraryName,
|
|
13
|
-
components: [
|
|
14
|
-
{
|
|
15
|
-
from: "slices/ecommerce",
|
|
16
|
-
href: "slices--ecommerce",
|
|
17
|
-
pathToSlice: "./slices/ecommerce",
|
|
18
|
-
fileName: "index",
|
|
19
|
-
extension: "js",
|
|
20
|
-
screenshots: {
|
|
21
|
-
"default-slice": {
|
|
22
|
-
hash: "f92c69c60df8fd8eb42902bfb6574776",
|
|
23
|
-
url: "http://localhost:9999/api/__preview?q=default-slice",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
mocks: [],
|
|
27
|
-
model: {
|
|
28
|
-
id: modelId,
|
|
29
|
-
type: "SharedSlice",
|
|
30
|
-
name: "CategoryPreviewWithImageBackgrounds",
|
|
31
|
-
description: "CategoryPreviewWithImageBackgrounds",
|
|
32
|
-
variations: [
|
|
33
|
-
{
|
|
34
|
-
id: "default-slice",
|
|
35
|
-
name: "Default slice",
|
|
36
|
-
docURL: "...",
|
|
37
|
-
version: "sktwi1xtmkfgx8626",
|
|
38
|
-
description: "MockSlice",
|
|
39
|
-
primary: [
|
|
40
|
-
{
|
|
41
|
-
key: "Title",
|
|
42
|
-
value: {
|
|
43
|
-
config: {
|
|
44
|
-
label: "Title",
|
|
45
|
-
placeholder: "My first Title...",
|
|
46
|
-
},
|
|
47
|
-
type: "Text",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
items: [],
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
meta: {
|
|
58
|
-
isNodeModule: false,
|
|
59
|
-
isDownloaded: false,
|
|
60
|
-
isManual: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
env: dummyServerState.env,
|
|
67
|
-
libraries: MOCK_UPDATED_LIBRARY,
|
|
68
|
-
localCustomTypes: [],
|
|
69
|
-
remoteCustomTypes: [],
|
|
70
|
-
remoteSlices: [],
|
|
71
|
-
};
|
|
72
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import jsonModel from "../__fixtures__/model.json";
|
|
2
|
-
import jsonMocks from "../__fixtures__/mocks.json";
|
|
3
|
-
|
|
4
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
5
|
-
import { Slices } from "@lib/models/common/Slice";
|
|
6
|
-
import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
7
|
-
import { ComponentInfo } from "@lib/models/common/Library";
|
|
8
|
-
|
|
9
|
-
export const getSelectedSliceDummyData = () => {
|
|
10
|
-
const dummyModel = Slices.toSM(jsonModel as unknown as SharedSlice);
|
|
11
|
-
|
|
12
|
-
const dummyModelVariationID = "default-slice";
|
|
13
|
-
|
|
14
|
-
const dummySliceState: ComponentUI = {
|
|
15
|
-
from: "slices/libName",
|
|
16
|
-
href: "slices--libName",
|
|
17
|
-
pathToSlice: "./slices/libName",
|
|
18
|
-
fileName: "index",
|
|
19
|
-
extension: "js",
|
|
20
|
-
model: dummyModel,
|
|
21
|
-
screenshots: {},
|
|
22
|
-
mocks: jsonMocks as ComponentInfo["mocks"],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
dummyModel,
|
|
27
|
-
dummyModelVariationID,
|
|
28
|
-
dummySliceState,
|
|
29
|
-
};
|
|
30
|
-
};
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { selectedSliceReducer } from "@src/modules/selectedSlice/reducer";
|
|
3
|
-
import {
|
|
4
|
-
addSliceWidgetCreator,
|
|
5
|
-
copyVariationSliceCreator,
|
|
6
|
-
initSliceStoreCreator,
|
|
7
|
-
removeSliceWidgetCreator,
|
|
8
|
-
replaceSliceWidgetCreator,
|
|
9
|
-
} from "@src/modules/selectedSlice/actions";
|
|
10
|
-
import { NestableWidget } from "@prismicio/types-internal/lib/customtypes";
|
|
11
|
-
import { getSelectedSliceDummyData } from "./__testutils__/getSelectedSliceDummyData";
|
|
12
|
-
import { getRefreshStateCreatorPayloadData } from "./__testutils__/getRefreshStateCreatorPayloadData";
|
|
13
|
-
import { refreshStateCreator } from "@src/modules/environment";
|
|
14
|
-
import { WidgetsArea } from "@lib/models/common/Slice";
|
|
15
|
-
|
|
16
|
-
const { dummyModelVariationID, dummySliceState } = getSelectedSliceDummyData();
|
|
17
|
-
|
|
18
|
-
describe("[Selected Slice module]", () => {
|
|
19
|
-
describe("[Reducer]", () => {
|
|
20
|
-
it("should return the initial state if no matching action", () => {
|
|
21
|
-
expect(
|
|
22
|
-
// @ts-expect-error the NO.MATCH is not a valid action type
|
|
23
|
-
selectedSliceReducer(dummySliceState, { type: "NO.MATCH" }),
|
|
24
|
-
).toEqual(dummySliceState);
|
|
25
|
-
expect(
|
|
26
|
-
// @ts-expect-error the NO.MATCH is not a valid action type
|
|
27
|
-
selectedSliceReducer(null, { type: "NO.MATCH" }),
|
|
28
|
-
).toEqual(null);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should update the selected slice state given SELECTED_SLICE/INIT action", () => {
|
|
32
|
-
expect(
|
|
33
|
-
selectedSliceReducer(null, initSliceStoreCreator(dummySliceState)),
|
|
34
|
-
).toEqual(dummySliceState);
|
|
35
|
-
});
|
|
36
|
-
it("should update the selected slice state given SLICE/ADD_WIDGET action", () => {
|
|
37
|
-
const primaryWidgetsInit =
|
|
38
|
-
dummySliceState.model.variations[0].primary || [];
|
|
39
|
-
|
|
40
|
-
const newWidget: { key: string; value: NestableWidget } = {
|
|
41
|
-
key: "new-widget-text",
|
|
42
|
-
value: {
|
|
43
|
-
type: "Text",
|
|
44
|
-
config: {
|
|
45
|
-
label: "newWidgetText",
|
|
46
|
-
placeholder: "",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const newState = selectedSliceReducer(
|
|
52
|
-
dummySliceState,
|
|
53
|
-
addSliceWidgetCreator({
|
|
54
|
-
variationId: dummyModelVariationID,
|
|
55
|
-
widgetsArea: WidgetsArea.Primary,
|
|
56
|
-
key: newWidget.key,
|
|
57
|
-
value: newWidget.value,
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
const primaryWidgets = newState?.model.variations[0].primary;
|
|
61
|
-
expect(primaryWidgets?.length).toEqual(primaryWidgetsInit.length + 1);
|
|
62
|
-
expect(primaryWidgets?.at(-1)?.key).toBe(newWidget.key);
|
|
63
|
-
expect(primaryWidgets?.at(-1)?.value).toBe(newWidget.value);
|
|
64
|
-
});
|
|
65
|
-
it("should update the selected slice state given SLICE/REPLACE_WIDGET action if the tab is found", () => {
|
|
66
|
-
const primaryWidgetsInit =
|
|
67
|
-
dummySliceState.model.variations[0].primary || [];
|
|
68
|
-
|
|
69
|
-
const widgetToReplace = primaryWidgetsInit[0];
|
|
70
|
-
|
|
71
|
-
const updatedWidget: { key: string; value: NestableWidget } = {
|
|
72
|
-
key: "new_key",
|
|
73
|
-
value: {
|
|
74
|
-
type: "Text",
|
|
75
|
-
config: {
|
|
76
|
-
label: "newWidgetText",
|
|
77
|
-
placeholder: "",
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const newState = selectedSliceReducer(
|
|
83
|
-
dummySliceState,
|
|
84
|
-
replaceSliceWidgetCreator({
|
|
85
|
-
variationId: dummyModelVariationID,
|
|
86
|
-
widgetsArea: WidgetsArea.Primary,
|
|
87
|
-
previousKey: widgetToReplace.key,
|
|
88
|
-
newKey: updatedWidget.key,
|
|
89
|
-
value: updatedWidget.value,
|
|
90
|
-
}),
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const primaryWidgets = newState?.model.variations[0].primary;
|
|
94
|
-
expect(primaryWidgets?.length).toEqual(primaryWidgetsInit.length);
|
|
95
|
-
const replacedWidget = primaryWidgets?.find(
|
|
96
|
-
(w) => w.key === updatedWidget.key,
|
|
97
|
-
);
|
|
98
|
-
expect(replacedWidget).toBeTruthy();
|
|
99
|
-
expect(replacedWidget?.value).toBe(updatedWidget.value);
|
|
100
|
-
});
|
|
101
|
-
it("should update the selected slice state given SLICE/REMOVE_WIDGET action", () => {
|
|
102
|
-
const primaryWidgetsInit =
|
|
103
|
-
dummySliceState.model.variations[0].primary || [];
|
|
104
|
-
|
|
105
|
-
const widgetToDelete = primaryWidgetsInit[0];
|
|
106
|
-
|
|
107
|
-
const newState = selectedSliceReducer(
|
|
108
|
-
dummySliceState,
|
|
109
|
-
removeSliceWidgetCreator({
|
|
110
|
-
variationId: dummyModelVariationID,
|
|
111
|
-
widgetsArea: WidgetsArea.Primary,
|
|
112
|
-
key: widgetToDelete.key,
|
|
113
|
-
}),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const primaryWidgets = newState?.model.variations[0].primary;
|
|
117
|
-
expect(primaryWidgets?.length).toEqual(0);
|
|
118
|
-
});
|
|
119
|
-
it("should update the selected slice state given SLICE/COPY_VARIATION action", () => {
|
|
120
|
-
const preVariations = dummySliceState?.model.variations;
|
|
121
|
-
|
|
122
|
-
const newState = selectedSliceReducer(
|
|
123
|
-
dummySliceState,
|
|
124
|
-
copyVariationSliceCreator({
|
|
125
|
-
key: "new-variation",
|
|
126
|
-
name: "New Variation",
|
|
127
|
-
copied: dummySliceState.model.variations[0],
|
|
128
|
-
}),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
const variations = newState?.model.variations;
|
|
132
|
-
|
|
133
|
-
expect(variations?.length).toEqual(preVariations.length + 1);
|
|
134
|
-
expect(variations?.at(-1)?.id).toEqual("new-variation");
|
|
135
|
-
expect(variations?.at(-1)?.name).toEqual("New Variation");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("should update the selected slice screenshots given STATE/REFRESH.RESPONSE action if the component is found", () => {
|
|
139
|
-
const action = refreshStateCreator(
|
|
140
|
-
getRefreshStateCreatorPayloadData(
|
|
141
|
-
dummySliceState.from,
|
|
142
|
-
dummySliceState.model.id,
|
|
143
|
-
),
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const newState = selectedSliceReducer(dummySliceState, action);
|
|
147
|
-
|
|
148
|
-
expect(newState?.screenshots).toEqual({
|
|
149
|
-
"default-slice": {
|
|
150
|
-
hash: "f92c69c60df8fd8eb42902bfb6574776",
|
|
151
|
-
url: "http://localhost:9999/api/__preview?q=default-slice",
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("should do nothing given STATE/REFRESH.RESPONSE action if the component is not found", () => {
|
|
157
|
-
const action = refreshStateCreator(
|
|
158
|
-
getRefreshStateCreatorPayloadData(
|
|
159
|
-
"unknown-livrary",
|
|
160
|
-
dummySliceState.model.id,
|
|
161
|
-
),
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const newState = selectedSliceReducer(dummySliceState, action);
|
|
165
|
-
|
|
166
|
-
expect(newState?.screenshots).toEqual({});
|
|
167
|
-
expect(newState).toEqual(dummySliceState);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import { updateSliceSaga } from "@src/modules/selectedSlice/sagas";
|
|
4
|
-
import { updateSliceCreator } from "@src/modules/selectedSlice/actions";
|
|
5
|
-
import { readSliceMocks, updateSlice } from "@src/apiClient";
|
|
6
|
-
import { openToasterCreator, ToasterType } from "@src/modules/toaster";
|
|
7
|
-
import { getSelectedSliceDummyData } from "./__testutils__/getSelectedSliceDummyData";
|
|
8
|
-
|
|
9
|
-
const { dummySliceState } = getSelectedSliceDummyData();
|
|
10
|
-
|
|
11
|
-
describe("[Selected Slice sagas]", () => {
|
|
12
|
-
describe("[updateSliceSaga]", () => {
|
|
13
|
-
it("should call the api and dispatch the success action", () => {
|
|
14
|
-
const mockSetSliceBuilderState = vi.fn<
|
|
15
|
-
{
|
|
16
|
-
error: boolean;
|
|
17
|
-
done: boolean;
|
|
18
|
-
loading: boolean;
|
|
19
|
-
message: {
|
|
20
|
-
props: {
|
|
21
|
-
message: string;
|
|
22
|
-
path: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}[]
|
|
26
|
-
>();
|
|
27
|
-
const saga = testSaga(
|
|
28
|
-
updateSliceSaga,
|
|
29
|
-
updateSliceCreator.request({
|
|
30
|
-
component: dummySliceState,
|
|
31
|
-
// @ts-expect-error - Issue with `message` type
|
|
32
|
-
setSliceBuilderState: mockSetSliceBuilderState,
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
saga.next().call(updateSlice, dummySliceState);
|
|
37
|
-
|
|
38
|
-
saga.next({ errors: [] }).call(readSliceMocks, {
|
|
39
|
-
libraryID: dummySliceState.from,
|
|
40
|
-
sliceID: dummySliceState.model.id,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
saga.next({ errors: [], mocks: [] }).put(
|
|
44
|
-
updateSliceCreator.success({
|
|
45
|
-
component: { ...dummySliceState, mocks: [] },
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
saga.next().isDone();
|
|
50
|
-
|
|
51
|
-
const mockSetSliceBuilderStateCalls =
|
|
52
|
-
mockSetSliceBuilderState.mock.lastCall?.[0];
|
|
53
|
-
expect(mockSetSliceBuilderStateCalls?.error).toBe(false);
|
|
54
|
-
expect(mockSetSliceBuilderStateCalls?.done).toBe(true);
|
|
55
|
-
expect(mockSetSliceBuilderStateCalls?.loading).toBe(false);
|
|
56
|
-
expect(mockSetSliceBuilderStateCalls?.message.props.message).toBe(
|
|
57
|
-
"Slice saved successfully at ",
|
|
58
|
-
);
|
|
59
|
-
expect(mockSetSliceBuilderStateCalls?.message.props.path).toBe(
|
|
60
|
-
"slices/libName/DummySlice/model.json",
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
it("should open a error toaster on internal error", () => {
|
|
64
|
-
const mockSetSliceBuilderState = vi.fn();
|
|
65
|
-
const saga = testSaga(
|
|
66
|
-
updateSliceSaga,
|
|
67
|
-
updateSliceCreator.request({
|
|
68
|
-
component: dummySliceState,
|
|
69
|
-
setSliceBuilderState: mockSetSliceBuilderState,
|
|
70
|
-
}),
|
|
71
|
-
).next();
|
|
72
|
-
|
|
73
|
-
saga.throw(new Error()).put(
|
|
74
|
-
openToasterCreator({
|
|
75
|
-
content: "Internal Error: Models & mocks not generated",
|
|
76
|
-
type: ToasterType.ERROR,
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
79
|
-
saga.next().isDone();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, afterEach, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { handleRemoteResponse, ToastPayload } from "@src/modules/toaster/utils";
|
|
4
|
-
import { ToasterType } from "@src/modules/toaster";
|
|
5
|
-
|
|
6
|
-
describe("[Toaster utils]", () => {
|
|
7
|
-
describe("[handleRemoteResponse]", () => {
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
vi.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should call addToast function on an success", () => {
|
|
13
|
-
const addToastFakeFunction = vi.fn();
|
|
14
|
-
const toastPayload: ToastPayload = {
|
|
15
|
-
done: true,
|
|
16
|
-
message: "message",
|
|
17
|
-
error: false,
|
|
18
|
-
};
|
|
19
|
-
handleRemoteResponse(addToastFakeFunction)(toastPayload);
|
|
20
|
-
|
|
21
|
-
expect(addToastFakeFunction).toHaveBeenCalledWith(
|
|
22
|
-
"message",
|
|
23
|
-
ToasterType.SUCCESS,
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("shouldn't call addToast function on an unfinished request", () => {
|
|
28
|
-
const addToastFakeFunction = vi.fn();
|
|
29
|
-
const toastPayload: ToastPayload = { done: false };
|
|
30
|
-
handleRemoteResponse(addToastFakeFunction)(toastPayload);
|
|
31
|
-
|
|
32
|
-
expect(addToastFakeFunction).toHaveBeenCalledTimes(0);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("shouldn't call addToast function on a request with errors", () => {
|
|
36
|
-
const addToastFakeFunction = vi.fn();
|
|
37
|
-
const toastPayload: ToastPayload = {
|
|
38
|
-
done: true,
|
|
39
|
-
message: "message",
|
|
40
|
-
error: true,
|
|
41
|
-
};
|
|
42
|
-
handleRemoteResponse(addToastFakeFunction)(toastPayload);
|
|
43
|
-
|
|
44
|
-
expect(addToastFakeFunction).toHaveBeenCalledWith(
|
|
45
|
-
"message",
|
|
46
|
-
ToasterType.ERROR,
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
File without changes
|