slice-machine-ui 1.23.1-beta.2 → 1.23.1-beta.4
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/CustomTypeTable/changesPage.tsx +1 -0
- package/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/index.tsx +0 -1
- package/components/SliceMachineDrawer/index.tsx +4 -6
- package/out/404.html +1 -1
- package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → N2MQkjqkeMvE9gtxiUiFA}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +1 -0
- package/out/_next/static/chunks/{727-15cf3f2fea9a37e5.js → 727-2016e98f80ea6a62.js} +1 -1
- package/out/_next/static/chunks/{904-ccd8ca3368ce29fc.js → 904-4c4d0a2183ae9a27.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-46cdcb7304fa805f.js → _app-6fc45ce12a6c566a.js} +2 -2
- package/out/_next/static/chunks/pages/{changelog-68d115a14f1423d7.js → changelog-afd18276fe018b24.js} +1 -1
- package/out/_next/static/chunks/pages/changes-898f58035cfafe03.js +1 -0
- package/out/_next/static/chunks/pages/{labs-526bb7d60a1b90f4.js → labs-ee206005948f8e87.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-73dd999915509965.js → [variation]-b2a9d773ce5d7739.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-7b09cb5130c63bb3.js → slices-e9c70c082ca3e3f9.js} +1 -1
- 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 +3 -3
- package/pages/changes.tsx +67 -28
- package/src/components/FieldSet/FieldSet.module.css +92 -0
- package/src/components/FieldSet/FieldSet.module.css.d.ts +18 -0
- package/src/components/FieldSet/FieldSet.stories.tsx +208 -0
- package/src/components/FieldSet/FieldSet.tsx +72 -0
- package/src/components/FieldSet/index.ts +9 -0
- package/src/features/changes/actions/pushChanges.ts +66 -0
- package/src/{modules/pushChangesSaga → features/changes/actions}/trackPushChangesSuccess.ts +16 -12
- package/src/icons/BitbucketIcon.tsx +19 -0
- package/src/icons/GitHubIcon.tsx +17 -0
- package/src/icons/GitLabIcon.tsx +19 -0
- package/src/modules/loading/types.ts +0 -1
- package/src/modules/modal/types.ts +0 -3
- package/src/modules/useSliceMachineActions.ts +3 -18
- package/src/modules/userContext/index.ts +6 -3
- package/src/redux/reducer.ts +0 -2
- package/src/redux/saga.ts +0 -2
- package/src/redux/type.ts +0 -2
- package/components/DeleteDocumentsDrawer/ReferencesErrorDrawer.tsx +0 -92
- package/lib/models/common/TransactionalPush.ts +0 -10
- package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +0 -1
- package/out/_next/static/chunks/pages/changes-6a24f50da1a00688.js +0 -1
- package/src/modules/pushChangesSaga/index.ts +0 -191
- package/test/src/modules/pushChangesSaga.test.ts +0 -261
- /package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → N2MQkjqkeMvE9gtxiUiFA}/_ssgManifest.js +0 -0
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { describe, test } from "vitest";
|
|
2
|
-
import { Analytics } from "@segment/analytics-node";
|
|
3
|
-
import "@testing-library/jest-dom";
|
|
4
|
-
import { TestApi, testSaga } from "redux-saga-test-plan";
|
|
5
|
-
import {
|
|
6
|
-
ChangesPushSagaPayload,
|
|
7
|
-
changesPushCreator,
|
|
8
|
-
changesPushSaga,
|
|
9
|
-
} from "../../../src/modules/pushChangesSaga";
|
|
10
|
-
|
|
11
|
-
import { refreshStateCreator } from "@src/modules/environment";
|
|
12
|
-
import { setupServer } from "msw/node";
|
|
13
|
-
import { getState, pushChanges } from "../../../src/apiClient";
|
|
14
|
-
import { modalOpenCreator } from "../../../src/modules/modal";
|
|
15
|
-
import { ModalKeysEnum } from "../../../src/modules/modal/types";
|
|
16
|
-
import { openToasterCreator, ToasterType } from "../../../src/modules/toaster";
|
|
17
|
-
import { dummyServerState } from "./__fixtures__/serverState";
|
|
18
|
-
import { ModelStatus } from "@lib/models/common/ModelStatus";
|
|
19
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
20
|
-
import { CustomTypeSM } from "@lib/models/common/CustomType";
|
|
21
|
-
|
|
22
|
-
enum LimitType {
|
|
23
|
-
SOFT = "SOFT",
|
|
24
|
-
HARD = "HARD",
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class CustomAxiosError extends Error {
|
|
28
|
-
isAxiosError: boolean;
|
|
29
|
-
response?: {
|
|
30
|
-
data: any;
|
|
31
|
-
status: number;
|
|
32
|
-
statusText?: string;
|
|
33
|
-
headers?: any;
|
|
34
|
-
config?: any;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
constructor(status: number) {
|
|
38
|
-
super();
|
|
39
|
-
this.isAxiosError = true;
|
|
40
|
-
this.response = { data: {}, status };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const server = setupServer();
|
|
45
|
-
beforeAll(() => server.listen());
|
|
46
|
-
afterEach(() => server.resetHandlers());
|
|
47
|
-
afterAll(() => server.close());
|
|
48
|
-
|
|
49
|
-
const changesPayload: ChangesPushSagaPayload = {
|
|
50
|
-
confirmDeleteDocuments: false,
|
|
51
|
-
changedSlices: [
|
|
52
|
-
{
|
|
53
|
-
slice: {
|
|
54
|
-
model: { id: "slice1", variations: [{ id: "var1" }] },
|
|
55
|
-
screenshots: { var1: { hash: "__HASH__" } },
|
|
56
|
-
from: "library1",
|
|
57
|
-
} as unknown as ComponentUI,
|
|
58
|
-
status: ModelStatus.New,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
changedCustomTypes: [
|
|
62
|
-
{
|
|
63
|
-
customType: { id: "customType1" } as CustomTypeSM,
|
|
64
|
-
status: ModelStatus.Modified,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const pushChangesApiPayload = {
|
|
70
|
-
confirmDeleteDocuments: false,
|
|
71
|
-
changes: [
|
|
72
|
-
{
|
|
73
|
-
id: "slice1",
|
|
74
|
-
status: ModelStatus.New,
|
|
75
|
-
libraryID: "library1",
|
|
76
|
-
type: "Slice",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "customType1",
|
|
80
|
-
status: ModelStatus.Modified,
|
|
81
|
-
type: "CustomType",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
describe("[pushChanges module]", () => {
|
|
87
|
-
describe("[changesPushSaga]", () => {
|
|
88
|
-
let saga: TestApi;
|
|
89
|
-
|
|
90
|
-
beforeEach(() => {
|
|
91
|
-
saga = testSaga(
|
|
92
|
-
changesPushSaga,
|
|
93
|
-
changesPushCreator.request(changesPayload),
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
test("Pushes changes when API response is OK display success toaster", async () => {
|
|
97
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
98
|
-
|
|
99
|
-
saga.next(null).call(getState);
|
|
100
|
-
|
|
101
|
-
saga.next(dummyServerState).put(
|
|
102
|
-
refreshStateCreator({
|
|
103
|
-
env: dummyServerState.env,
|
|
104
|
-
remoteCustomTypes: dummyServerState.remoteCustomTypes,
|
|
105
|
-
localCustomTypes: dummyServerState.customTypes,
|
|
106
|
-
libraries: dummyServerState.libraries,
|
|
107
|
-
remoteSlices: [],
|
|
108
|
-
clientError: undefined,
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
saga.next().put(changesPushCreator.success());
|
|
113
|
-
|
|
114
|
-
saga.next().put(
|
|
115
|
-
openToasterCreator({
|
|
116
|
-
content: "All slices and types have been pushed",
|
|
117
|
-
type: ToasterType.SUCCESS,
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
saga.next().isDone();
|
|
122
|
-
|
|
123
|
-
// Wait for network request to be performed
|
|
124
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
125
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test.each([
|
|
129
|
-
[LimitType.HARD, ModalKeysEnum.HARD_DELETE_DOCUMENTS_DRAWER],
|
|
130
|
-
[LimitType.SOFT, ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER],
|
|
131
|
-
])(
|
|
132
|
-
"Displays delete limit modal when there is a %s limit response",
|
|
133
|
-
async (limitType, expectedModalKey) => {
|
|
134
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
135
|
-
|
|
136
|
-
// This test will also verify that the details are sorted in descending order.
|
|
137
|
-
saga
|
|
138
|
-
.next({
|
|
139
|
-
type: limitType,
|
|
140
|
-
details: {
|
|
141
|
-
customTypes: [
|
|
142
|
-
{
|
|
143
|
-
id: "CT1",
|
|
144
|
-
numberOfDocuments: 2000,
|
|
145
|
-
url: "url",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: "CT2",
|
|
149
|
-
numberOfDocuments: 3000,
|
|
150
|
-
url: "url",
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
})
|
|
155
|
-
.put(
|
|
156
|
-
changesPushCreator.failure({
|
|
157
|
-
type: limitType,
|
|
158
|
-
details: {
|
|
159
|
-
customTypes: [
|
|
160
|
-
{
|
|
161
|
-
id: "CT2",
|
|
162
|
-
numberOfDocuments: 3000,
|
|
163
|
-
url: "url",
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: "CT1",
|
|
167
|
-
numberOfDocuments: 2000,
|
|
168
|
-
url: "url",
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
saga.next().put(
|
|
176
|
-
modalOpenCreator({
|
|
177
|
-
modalKey: expectedModalKey,
|
|
178
|
-
}),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
saga.next().isDone();
|
|
182
|
-
|
|
183
|
-
// Wait for network request to be performed
|
|
184
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
185
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
test("Displays an error toaster when there is an API error on push", () => {
|
|
190
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
191
|
-
|
|
192
|
-
saga.throw(new Error()).put(
|
|
193
|
-
openToasterCreator({
|
|
194
|
-
content:
|
|
195
|
-
"Something went wrong when pushing your changes. Check your terminal logs.",
|
|
196
|
-
type: ToasterType.ERROR,
|
|
197
|
-
}),
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
saga.next().isDone();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// TODO: unskip when auth error is handled
|
|
204
|
-
test.skip.each([[401], [403]])(
|
|
205
|
-
"when there's a %s error while pushing a slice it should stop and open the login model",
|
|
206
|
-
(errorCode) => {
|
|
207
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
208
|
-
|
|
209
|
-
const customError = new CustomAxiosError(errorCode);
|
|
210
|
-
|
|
211
|
-
saga
|
|
212
|
-
.throw(customError)
|
|
213
|
-
.put(modalOpenCreator({ modalKey: ModalKeysEnum.LOGIN }));
|
|
214
|
-
|
|
215
|
-
saga.next().isDone();
|
|
216
|
-
},
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
// TODO: unskip when invalid references are handled
|
|
220
|
-
test.skip("when there's INVALID_CUSTOM_TYPES response, open the references drawer", () => {
|
|
221
|
-
saga.next().call(pushChanges, {
|
|
222
|
-
confirmDeleteDocuments: false,
|
|
223
|
-
changes: [
|
|
224
|
-
{ id: "slice1", status: ModelStatus.New, type: "Slice" },
|
|
225
|
-
{
|
|
226
|
-
id: "customType1",
|
|
227
|
-
status: ModelStatus.Modified,
|
|
228
|
-
type: "CustomType",
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
saga
|
|
234
|
-
.next({
|
|
235
|
-
status: 200,
|
|
236
|
-
data: {
|
|
237
|
-
type: "INVALID_CUSTOM_TYPES",
|
|
238
|
-
details: {
|
|
239
|
-
customTypes: [{ id: "CT1" }, { id: "CT2" }],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
.put(
|
|
244
|
-
changesPushCreator.failure({
|
|
245
|
-
type: "INVALID_CUSTOM_TYPES",
|
|
246
|
-
details: {
|
|
247
|
-
customTypes: [{ id: "CT1" }, { id: "CT2" }],
|
|
248
|
-
},
|
|
249
|
-
}),
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
saga.next().put(
|
|
253
|
-
modalOpenCreator({
|
|
254
|
-
modalKey: ModalKeysEnum.REFERENCES_MISSING_DRAWER,
|
|
255
|
-
}),
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
saga.next().isDone();
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
File without changes
|