slice-machine-ui 1.24.1-alpha.feat-disable-push-changes-with-git.1 → 1.24.1-alpha.feat-disable-push-changes-with-git.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.
- package/components/App/index.tsx +0 -2
- package/components/Changelog/index.tsx +29 -40
- package/components/Changelog/navigation/index.tsx +27 -23
- package/components/Changelog/versionDetails/{ReleaseNoteDetails.tsx → ReleaseNotesDetails.tsx} +5 -5
- package/components/Changelog/versionDetails/UpdateCommandBox.tsx +15 -11
- package/components/Changelog/versionDetails/VersionKindLabel.tsx +3 -2
- package/components/Changelog/versionDetails/index.tsx +17 -16
- package/components/Navigation/RunningVersion.tsx +14 -0
- package/components/Navigation/UpdateBox.tsx +16 -0
- package/components/Navigation/index.test.tsx +10 -35
- package/components/Navigation/index.tsx +14 -29
- package/components/ScreenshotChangesModal/VariationDropZone.tsx +18 -19
- package/lib/models/common/Environment.ts +0 -2
- package/out/404.html +1 -1
- package/out/_next/static/{xuVUCVxflC0RyiTkq5qed → R2G-iL0ukIJP5mlv6wM6E}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/286-877cd7b96660f95f.js +1 -0
- package/out/_next/static/chunks/{727-c6c0c0d8c72c2676.js → 727-ffb4c69fbb971ed7.js} +1 -1
- package/out/_next/static/chunks/{904-c09e8a519129a3d8.js → 904-d9089efa6d974e3e.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-701b914e9631b4cc.js → _app-55cb594e63d22821.js} +26 -26
- package/out/_next/static/chunks/pages/changelog-57289ca6bc99702b.js +1 -0
- package/out/_next/static/chunks/pages/{changes-1ef4fc53dccfdf6f.js → changes-515dc0829e5be3db.js} +1 -1
- package/out/_next/static/chunks/pages/{labs-773e5e6044d04247.js → labs-85d5c752dd5148b6.js} +1 -1
- package/out/_next/static/chunks/pages/settings-6f3e9b82e5b0aa79.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-4cd51835ba731872.js → [variation]-89c911fd39271b5d.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-e0ce615c38e8338d.js → slices-5dc0c55c386e047a.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/settings.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/src/apiClient.ts +0 -50
- package/src/features/changelog/useSliceMachineLatestNonBreakingVersion.ts +14 -0
- package/src/features/changelog/useSliceMachineReleaseNotes.ts +16 -0
- package/src/features/changelog/useSliceMachineVersions.ts +15 -0
- package/src/features/customTypes/customTypesBuilder/PageSnippetDialog/PageSnippetDialog.tsx +4 -6
- package/src/features/documentation/MarkdownRenderer/index.tsx +4 -6
- package/src/features/settings/git/GitProvider.ts +21 -21
- package/src/features/settings/git/GitProviderConnectButtons.tsx +5 -5
- package/src/hooks/useAdapterName.ts +4 -5
- package/src/hooks/useMarketingContent.ts +0 -3
- package/src/hooks/useSliceMachineRunningVersion.ts +14 -0
- package/src/hooks/useUpdateAvailable.ts +17 -0
- package/src/modules/environment/index.ts +2 -71
- package/src/modules/loading/types.ts +0 -2
- package/src/modules/useSliceMachineActions.ts +2 -11
- package/src/modules/userContext/index.ts +0 -19
- package/src/modules/userContext/types.ts +0 -4
- package/src/redux/saga.ts +0 -2
- package/test/src/modules/__fixtures__/serverState.ts +0 -13
- package/test/src/modules/environment.test.ts +0 -57
- package/test/src/modules/userContext.test.ts +0 -31
- package/lib/models/common/versions.ts +0 -39
- package/out/_next/static/chunks/286-ed90373e9a469944.js +0 -1
- package/out/_next/static/chunks/pages/changelog-cb1df3a70b20f1b8.js +0 -1
- package/out/_next/static/chunks/pages/settings-e404580aee7f138e.js +0 -1
- package/src/hooks/useChangelog.ts +0 -12
- package/test/pages/simulator.test.tsx +0 -332
- /package/out/_next/static/{xuVUCVxflC0RyiTkq5qed → R2G-iL0ukIJP5mlv6wM6E}/_ssgManifest.js +0 -0
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
|
|
3
|
-
import { describe, test, afterEach, expect, beforeAll, vi } from "vitest";
|
|
4
|
-
import { render, fireEvent, act, waitFor } from "../__testutils__";
|
|
5
|
-
import mockRouter from "next-router-mock";
|
|
6
|
-
import router from "next/router";
|
|
7
|
-
import { createDynamicRouteParser } from "next-router-mock/dynamic-routes";
|
|
8
|
-
import { Analytics } from "@segment/analytics-node";
|
|
9
|
-
|
|
10
|
-
import pkg from "../../package.json";
|
|
11
|
-
import Simulator from "../../pages/slices/[lib]/[sliceName]/[variation]/simulator";
|
|
12
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
13
|
-
import { createTestPlugin } from "test/__testutils__/createTestPlugin";
|
|
14
|
-
import { createTestProject } from "test/__testutils__/createTestProject";
|
|
15
|
-
import { createSliceMachineManager } from "@slicemachine/manager";
|
|
16
|
-
import { createSliceMachineManagerMSWHandler } from "@slicemachine/manager/test";
|
|
17
|
-
|
|
18
|
-
vi.mock("next/router", () => require("next-router-mock"));
|
|
19
|
-
vi.mock("next/dist/client/router", () => require("next-router-mock"));
|
|
20
|
-
mockRouter.useParser(
|
|
21
|
-
createDynamicRouteParser(["/slices/[lib]/[sliceName]/[variation]/simulator"]),
|
|
22
|
-
);
|
|
23
|
-
// mock simulator client, it would be nice not to have to do this :/
|
|
24
|
-
vi.mock("@prismicio/simulator", () => {
|
|
25
|
-
return {
|
|
26
|
-
SimulatorClient: vi.fn().mockReturnValue({
|
|
27
|
-
connect: vi.fn().mockResolvedValue(undefined),
|
|
28
|
-
disconnect: vi.fn(),
|
|
29
|
-
connected: true,
|
|
30
|
-
setSliceZone: vi.fn().mockResolvedValue(undefined),
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe.skip("simulator", () => {
|
|
36
|
-
beforeAll(async () => {
|
|
37
|
-
// USE THIS IF light mode is not enabled on ThemeProvider
|
|
38
|
-
// Object.defineProperty(window, "matchMedia", {
|
|
39
|
-
// writable: true,
|
|
40
|
-
// value: vi.fn().mockImplementation((query) => ({
|
|
41
|
-
// matches: false,
|
|
42
|
-
// media: query,
|
|
43
|
-
// onchange: null,
|
|
44
|
-
// addListener: vi.fn(), // Deprecated
|
|
45
|
-
// removeListener: vi.fn(), // Deprecated
|
|
46
|
-
// addEventListener: vi.fn(),
|
|
47
|
-
// removeEventListener: vi.fn(),
|
|
48
|
-
// dispatchEvent: vi.fn(),
|
|
49
|
-
// })),
|
|
50
|
-
// });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
document.createRange = () => {
|
|
54
|
-
// https://github.com/jsdom/jsdom/issues/3002
|
|
55
|
-
const range = new Range();
|
|
56
|
-
|
|
57
|
-
range.getBoundingClientRect = vi.fn().mockReturnValue({
|
|
58
|
-
width: 0,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
range.getClientRects = () => {
|
|
62
|
-
return {
|
|
63
|
-
item: () => null,
|
|
64
|
-
length: 0,
|
|
65
|
-
[Symbol.iterator]: vi.fn(),
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return range;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
afterEach(() => {
|
|
73
|
-
vi.clearAllMocks();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("save mock", async (ctx) => {
|
|
77
|
-
const adapter = createTestPlugin({
|
|
78
|
-
setup: ({ hook }) => {
|
|
79
|
-
hook("slice:asset:update", () => void 0);
|
|
80
|
-
hook("slice-simulator:setup:read", () => {
|
|
81
|
-
return [];
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
const cwd = await createTestProject({ adapter });
|
|
86
|
-
const manager = createSliceMachineManager({
|
|
87
|
-
nativePlugins: { [adapter.meta.name]: adapter },
|
|
88
|
-
cwd,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
await manager.telemetry.initTelemetry({
|
|
92
|
-
appName: pkg.name,
|
|
93
|
-
appVersion: pkg.version,
|
|
94
|
-
});
|
|
95
|
-
await manager.plugins.initPlugins();
|
|
96
|
-
|
|
97
|
-
ctx.msw.use(
|
|
98
|
-
createSliceMachineManagerMSWHandler({
|
|
99
|
-
url: "http://localhost:3000/_manager",
|
|
100
|
-
sliceMachineManager: manager,
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
vi.useFakeTimers();
|
|
105
|
-
|
|
106
|
-
router.push("/slices/MySlice/default/simulator");
|
|
107
|
-
const HEADING_TEXT = "HEADING TEXT";
|
|
108
|
-
const state = {
|
|
109
|
-
simulator: {
|
|
110
|
-
isWaitingForIframeCheck: true,
|
|
111
|
-
iframeStatus: null,
|
|
112
|
-
setupStatus: { manifest: null },
|
|
113
|
-
savingMock: false,
|
|
114
|
-
},
|
|
115
|
-
environment: {
|
|
116
|
-
changelog: {
|
|
117
|
-
sliceMachine: {
|
|
118
|
-
currentVersion: "0.0.0",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
manifest: {
|
|
122
|
-
localSliceSimulatorURL: "http://localhost:3000/slice-simulator",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
slices: {
|
|
126
|
-
libraries: [
|
|
127
|
-
{
|
|
128
|
-
path: "../../e2e-projects/next/slices2",
|
|
129
|
-
isLocal: true,
|
|
130
|
-
name: "slices",
|
|
131
|
-
components: [
|
|
132
|
-
{
|
|
133
|
-
from: "slices",
|
|
134
|
-
href: "slices",
|
|
135
|
-
pathToSlice: "./slices",
|
|
136
|
-
fileName: "index",
|
|
137
|
-
extension: "js",
|
|
138
|
-
screenshots: {},
|
|
139
|
-
mocks: [
|
|
140
|
-
{
|
|
141
|
-
__TYPE__: "SharedSliceContent",
|
|
142
|
-
variation: "default",
|
|
143
|
-
primary: {
|
|
144
|
-
title: {
|
|
145
|
-
__TYPE__: "StructuredTextContent",
|
|
146
|
-
value: [
|
|
147
|
-
{
|
|
148
|
-
type: "heading1",
|
|
149
|
-
content: {
|
|
150
|
-
text: HEADING_TEXT,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
},
|
|
155
|
-
description: {
|
|
156
|
-
__TYPE__: "StructuredTextContent",
|
|
157
|
-
value: [
|
|
158
|
-
{
|
|
159
|
-
type: "paragraph",
|
|
160
|
-
content: {
|
|
161
|
-
text: "Et irure id id ea exercitation excepteur consectetur. Ea amet irure minim labore non aliquip ex. Tempor incididunt Lorem incididunt amet est cillum nisi Lorem officia pariatur exercitation in occaecat sit.",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
items: [
|
|
168
|
-
{
|
|
169
|
-
__TYPE__: "GroupItemContent",
|
|
170
|
-
value: [],
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
model: {
|
|
176
|
-
id: "my_slice",
|
|
177
|
-
type: "SharedSlice",
|
|
178
|
-
name: "MySlice",
|
|
179
|
-
description: "MySlice",
|
|
180
|
-
variations: [
|
|
181
|
-
{
|
|
182
|
-
id: "default",
|
|
183
|
-
name: "Default",
|
|
184
|
-
docURL: "...",
|
|
185
|
-
version: "sktwi1xtmkfgx8626",
|
|
186
|
-
description: "MySlice",
|
|
187
|
-
primary: [
|
|
188
|
-
{
|
|
189
|
-
key: "title",
|
|
190
|
-
value: {
|
|
191
|
-
type: "StructuredText",
|
|
192
|
-
config: {
|
|
193
|
-
single: "heading1",
|
|
194
|
-
label: "Title",
|
|
195
|
-
placeholder: "This is where it all begins...",
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
key: "description",
|
|
201
|
-
value: {
|
|
202
|
-
type: "StructuredText",
|
|
203
|
-
config: {
|
|
204
|
-
single: "paragraph",
|
|
205
|
-
label: "Description",
|
|
206
|
-
placeholder: "A nice description of your feature",
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
items: [],
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
meta: {
|
|
218
|
-
isNodeModule: false,
|
|
219
|
-
isDownloaded: false,
|
|
220
|
-
isManual: true,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// server.use(
|
|
228
|
-
// rest.get("/api/state", (_req, res, ctx) => {
|
|
229
|
-
// return res(
|
|
230
|
-
// ctx.json({
|
|
231
|
-
// env: state.environment,
|
|
232
|
-
// libraries: state.slices.libraries,
|
|
233
|
-
// })
|
|
234
|
-
// );
|
|
235
|
-
// })
|
|
236
|
-
// );
|
|
237
|
-
//
|
|
238
|
-
// server.use(
|
|
239
|
-
// rest.get(
|
|
240
|
-
// state.environment.manifest.localSliceSimulatorURL,
|
|
241
|
-
// (_req, res, ctx) => {
|
|
242
|
-
// return res(ctx.status(200));
|
|
243
|
-
// }
|
|
244
|
-
// )
|
|
245
|
-
// );
|
|
246
|
-
//
|
|
247
|
-
// const saveMockSpy = vi.fn(
|
|
248
|
-
// (req: RestRequest, res: ResponseComposition, ctx: RestContext) => {
|
|
249
|
-
// return req.json().then((json) => {
|
|
250
|
-
// const result = SaveMockBody.decode(json);
|
|
251
|
-
// if (result._tag === "Right") {
|
|
252
|
-
// return res(ctx.json(json.mock));
|
|
253
|
-
// }
|
|
254
|
-
// return res(ctx.status(400));
|
|
255
|
-
// });
|
|
256
|
-
// }
|
|
257
|
-
// );
|
|
258
|
-
//
|
|
259
|
-
// server.use(rest.post("http://localhost/api/slices/mock", saveMockSpy));
|
|
260
|
-
// server.use(
|
|
261
|
-
// rest.get(
|
|
262
|
-
// state.environment.manifest.localSliceSimulatorURL,
|
|
263
|
-
// (_req, res, ctx) => {
|
|
264
|
-
// res(ctx.json({}));
|
|
265
|
-
// }
|
|
266
|
-
// )
|
|
267
|
-
// );
|
|
268
|
-
//
|
|
269
|
-
// server.use(
|
|
270
|
-
// rest.get("http://localhost/api/simulator/check", (_req, res, ctx) => {
|
|
271
|
-
// return res(
|
|
272
|
-
// ctx.json({
|
|
273
|
-
// manifest: "ok",
|
|
274
|
-
// value: state.environment.manifest.localSliceSimulatorURL,
|
|
275
|
-
// })
|
|
276
|
-
// );
|
|
277
|
-
// })
|
|
278
|
-
// );
|
|
279
|
-
|
|
280
|
-
const App = render(<Simulator />, {
|
|
281
|
-
preloadedState: state as unknown as Partial<SliceMachineStoreType>,
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
await waitFor(() => expect(Analytics.prototype.track).toHaveBeenCalled());
|
|
285
|
-
|
|
286
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
287
|
-
expect(Analytics.prototype.track).toHaveBeenCalledWith(
|
|
288
|
-
expect.objectContaining({
|
|
289
|
-
event: "SliceMachine Slice Simulator Open",
|
|
290
|
-
properties: {
|
|
291
|
-
version: state.environment.changelog.sliceMachine.currentVersion,
|
|
292
|
-
},
|
|
293
|
-
}),
|
|
294
|
-
expect.any(Function),
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const button = App.container.querySelector('[data-cy="save-mock"]');
|
|
298
|
-
expect(button).not.toBeNull();
|
|
299
|
-
|
|
300
|
-
const input = App.getByText(HEADING_TEXT);
|
|
301
|
-
expect(input).not.toBeNull();
|
|
302
|
-
|
|
303
|
-
await act(async () => {
|
|
304
|
-
// fireEvent.change(input as Element, {target: {value: "🎉"}})
|
|
305
|
-
// see: https://github.com/testing-library/dom-testing-library/pull/235
|
|
306
|
-
fireEvent.blur(input as Element, { target: { textContent: "🎉" } });
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
expect(button).not.toHaveAttribute("disabled");
|
|
310
|
-
|
|
311
|
-
await act(async () => {
|
|
312
|
-
fireEvent.click(button as Element);
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
const expectedMock = [...state.slices.libraries[0].components[0].mocks];
|
|
316
|
-
expectedMock[0].primary.title.value[0].content.text = "🎉";
|
|
317
|
-
// @ts-expect-error - Ignoring wrong type
|
|
318
|
-
expectedMock[0].primary.title.value[0].content.spans = [];
|
|
319
|
-
// @ts-expect-error - Ignoring wrong type
|
|
320
|
-
expectedMock[0].primary.title.value[0].direction = "ltr";
|
|
321
|
-
|
|
322
|
-
expect(Analytics.prototype.track).toHaveBeenCalledTimes(2);
|
|
323
|
-
expect(Analytics.prototype.track).toHaveBeenCalledWith(
|
|
324
|
-
expect.objectContaining({
|
|
325
|
-
sliceName: "MySlice",
|
|
326
|
-
libraryName: "slices",
|
|
327
|
-
mocks: expectedMock,
|
|
328
|
-
}),
|
|
329
|
-
expect.any(Function),
|
|
330
|
-
);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
File without changes
|