@sanity/workbench 0.1.0-alpha.8 → 0.1.0-alpha.9
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/package.json +7 -3
- package/src/_internal/render.test.ts +0 -105
- package/src/core/__tests__/__fixtures__.ts +0 -245
- package/src/core/applications/application-list.test.ts +0 -222
- package/src/core/applications/local-application.test.ts +0 -93
- package/src/core/canvases.test.ts +0 -38
- package/src/core/log/index.test.ts +0 -133
- package/src/core/media-libraries.test.ts +0 -38
- package/src/core/organizations.test.ts +0 -134
- package/src/core/projects.test.ts +0 -248
- package/src/core/shared/urls.test.ts +0 -182
- package/src/core/user-applications/core-app.test.ts +0 -236
- package/src/core/user-applications/studios/schemas.test.ts +0 -113
- package/src/core/user-applications/studios/studio.test.ts +0 -997
- package/src/core/user-applications/user-application.test.ts +0 -125
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { createPath, joinUrlPaths, normalizePath, parsePath } from "./urls";
|
|
4
|
-
|
|
5
|
-
describe("joinUrlPaths", () => {
|
|
6
|
-
it("joins two simple segments", () => {
|
|
7
|
-
expect(joinUrlPaths("foo", "bar")).toBe("foo/bar");
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("handles trailing slash on first segment", () => {
|
|
11
|
-
expect(joinUrlPaths("foo/", "bar")).toBe("foo/bar");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("handles leading slash on second segment", () => {
|
|
15
|
-
expect(joinUrlPaths("foo", "/bar")).toBe("foo/bar");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("collapses double slashes at the join", () => {
|
|
19
|
-
expect(joinUrlPaths("foo/", "/bar")).toBe("foo/bar");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("joins multiple segments", () => {
|
|
23
|
-
expect(joinUrlPaths("a", "b", "c")).toBe("a/b/c");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("skips null and undefined values", () => {
|
|
27
|
-
expect(joinUrlPaths("a", null, undefined, "b")).toBe("a/b");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("returns empty string for all nullish inputs", () => {
|
|
31
|
-
expect(joinUrlPaths(null, undefined)).toBe("");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns empty string with no arguments", () => {
|
|
35
|
-
expect(joinUrlPaths()).toBe("");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("returns single segment unchanged", () => {
|
|
39
|
-
expect(joinUrlPaths("foo")).toBe("foo");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("extracts pathname from URL objects", () => {
|
|
43
|
-
const url = new URL("https://example.com/api");
|
|
44
|
-
expect(joinUrlPaths(url, "users")).toBe("/api/users");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("handles URL object with trailing slash", () => {
|
|
48
|
-
const url = new URL("https://example.com/api/");
|
|
49
|
-
expect(joinUrlPaths(url, "users")).toBe("/api/users");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("joins two URL objects", () => {
|
|
53
|
-
const a = new URL("https://example.com/api");
|
|
54
|
-
const b = new URL("https://example.com/v2");
|
|
55
|
-
expect(joinUrlPaths(a, b)).toBe("/api/v2");
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("normalizePath", () => {
|
|
60
|
-
it("adds leading slash when missing", () => {
|
|
61
|
-
expect(normalizePath("foo")).toBe("/foo");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("preserves existing leading slash", () => {
|
|
65
|
-
expect(normalizePath("/foo")).toBe("/foo");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("removes trailing slash", () => {
|
|
69
|
-
expect(normalizePath("/foo/")).toBe("/foo");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("preserves root path", () => {
|
|
73
|
-
expect(normalizePath("/")).toBe("/");
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("handles bare segment with trailing slash", () => {
|
|
77
|
-
expect(normalizePath("foo/")).toBe("/foo");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("handles deeper paths", () => {
|
|
81
|
-
expect(normalizePath("/a/b/c/")).toBe("/a/b/c");
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("parsePath", () => {
|
|
86
|
-
it("parses pathname only", () => {
|
|
87
|
-
expect(parsePath("/foo")).toEqual({ pathname: "/foo" });
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("parses pathname with search", () => {
|
|
91
|
-
expect(parsePath("/foo?bar=1")).toEqual({
|
|
92
|
-
pathname: "/foo",
|
|
93
|
-
search: "?bar=1",
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("parses pathname with hash", () => {
|
|
98
|
-
expect(parsePath("/foo#heading")).toEqual({
|
|
99
|
-
pathname: "/foo",
|
|
100
|
-
hash: "#heading",
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("parses pathname with search and hash", () => {
|
|
105
|
-
expect(parsePath("/foo?bar=1#heading")).toEqual({
|
|
106
|
-
pathname: "/foo",
|
|
107
|
-
search: "?bar=1",
|
|
108
|
-
hash: "#heading",
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("parses hash that appears before search in the string", () => {
|
|
113
|
-
expect(parsePath("/foo#heading?notSearch")).toEqual({
|
|
114
|
-
pathname: "/foo",
|
|
115
|
-
hash: "#heading?notSearch",
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("returns empty object for empty string", () => {
|
|
120
|
-
expect(parsePath("")).toEqual({});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("parses search-only path", () => {
|
|
124
|
-
expect(parsePath("?q=1")).toEqual({ search: "?q=1" });
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("parses hash-only path", () => {
|
|
128
|
-
expect(parsePath("#top")).toEqual({ hash: "#top" });
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe("createPath", () => {
|
|
133
|
-
it("returns pathname only", () => {
|
|
134
|
-
expect(createPath({ pathname: "/foo" })).toBe("/foo");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("appends search string", () => {
|
|
138
|
-
expect(createPath({ pathname: "/foo", search: "?bar=1" })).toBe(
|
|
139
|
-
"/foo?bar=1",
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("appends hash string", () => {
|
|
144
|
-
expect(createPath({ pathname: "/foo", hash: "#heading" })).toBe(
|
|
145
|
-
"/foo#heading",
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("appends both search and hash", () => {
|
|
150
|
-
expect(
|
|
151
|
-
createPath({
|
|
152
|
-
pathname: "/foo",
|
|
153
|
-
search: "?bar=1",
|
|
154
|
-
hash: "#heading",
|
|
155
|
-
}),
|
|
156
|
-
).toBe("/foo?bar=1#heading");
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("adds ? prefix when search is missing it", () => {
|
|
160
|
-
expect(createPath({ pathname: "/foo", search: "bar=1" })).toBe(
|
|
161
|
-
"/foo?bar=1",
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("adds # prefix when hash is missing it", () => {
|
|
166
|
-
expect(createPath({ pathname: "/foo", hash: "heading" })).toBe(
|
|
167
|
-
"/foo#heading",
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("defaults pathname to /", () => {
|
|
172
|
-
expect(createPath({})).toBe("/");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("ignores bare ? search", () => {
|
|
176
|
-
expect(createPath({ pathname: "/foo", search: "?" })).toBe("/foo");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("ignores bare # hash", () => {
|
|
180
|
-
expect(createPath({ pathname: "/foo", hash: "#" })).toBe("/foo");
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports
|
|
2
|
-
import type { ApplicationResource as ProtocolApplicationResource } from "@sanity/message-protocol";
|
|
3
|
-
import { afterEach, describe, expect, expectTypeOf, it, vi } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { APPLICATION_DATA } from "../__tests__/__fixtures__";
|
|
6
|
-
import {
|
|
7
|
-
CoreAppApplication,
|
|
8
|
-
parseCoreApplication,
|
|
9
|
-
type CoreAppUserApplication,
|
|
10
|
-
} from "./core-app";
|
|
11
|
-
import type { UserApplicationId } from "./user-application";
|
|
12
|
-
|
|
13
|
-
const setup = () => new CoreAppApplication(APPLICATION_DATA);
|
|
14
|
-
|
|
15
|
-
describe("CoreAppApplication", () => {
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
vi.unstubAllEnvs();
|
|
18
|
-
});
|
|
19
|
-
it("should have a type of coreApp", () => {
|
|
20
|
-
const application = setup();
|
|
21
|
-
expect(application.type).toBe("coreApp");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("should have a href of <application>/<id>", () => {
|
|
25
|
-
const application = setup();
|
|
26
|
-
expect(application.href).toBe("/application/v27rvqtlp3lmdvcln6ey3lro");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should have a name of the application title", () => {
|
|
30
|
-
const application = setup();
|
|
31
|
-
expect(application.title).toBe("sdk-movie-list");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should have a updatedAt property", () => {
|
|
35
|
-
const application = setup();
|
|
36
|
-
expect(application.updatedAt).toBe("2025-03-27T19:00:32.792Z");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should have an activeDeployment property", () => {
|
|
40
|
-
const application = setup();
|
|
41
|
-
expect(application.activeDeployment).toMatchInlineSnapshot(`
|
|
42
|
-
{
|
|
43
|
-
"createdAt": "2025-03-27T19:07:21.038Z",
|
|
44
|
-
"deployedAt": "2025-03-27T19:07:21.082Z",
|
|
45
|
-
"deployedBy": "gwXueEBci",
|
|
46
|
-
"id": "dv3kz3fsl4aqha3parc8k391",
|
|
47
|
-
"isActiveDeployment": true,
|
|
48
|
-
"isAutoUpdating": false,
|
|
49
|
-
"manifest": null,
|
|
50
|
-
"size": 528292,
|
|
51
|
-
"updatedAt": "2025-03-27T19:07:21.082Z",
|
|
52
|
-
"userApplicationId": "v27rvqtlp3lmdvcln6ey3lro",
|
|
53
|
-
"version": "3.81.0",
|
|
54
|
-
}
|
|
55
|
-
`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should implement the toProtocolResource method", () => {
|
|
59
|
-
vi.stubEnv("VITE_SANITY_ENV", "staging");
|
|
60
|
-
vi.stubEnv("VITE_SANITY_DOMAIN", "sanity.work");
|
|
61
|
-
const application = setup();
|
|
62
|
-
expect(application.toProtocolResource()).toMatchInlineSnapshot(`
|
|
63
|
-
{
|
|
64
|
-
"activeDeployment": {
|
|
65
|
-
"createdAt": "2025-03-27T19:07:21.038Z",
|
|
66
|
-
"deployedAt": "2025-03-27T19:07:21.082Z",
|
|
67
|
-
"deployedBy": "gwXueEBci",
|
|
68
|
-
"id": "dv3kz3fsl4aqha3parc8k391",
|
|
69
|
-
"isActiveDeployment": true,
|
|
70
|
-
"isAutoUpdating": false,
|
|
71
|
-
"manifest": null,
|
|
72
|
-
"size": 528292,
|
|
73
|
-
"updatedAt": "2025-03-27T19:07:21.082Z",
|
|
74
|
-
"userApplicationId": "v27rvqtlp3lmdvcln6ey3lro",
|
|
75
|
-
"version": "3.81.0",
|
|
76
|
-
},
|
|
77
|
-
"appHost": "x7apsmr6fxvc",
|
|
78
|
-
"createdAt": "2025-03-27T19:00:32.792Z",
|
|
79
|
-
"dashboardStatus": "default",
|
|
80
|
-
"id": "v27rvqtlp3lmdvcln6ey3lro",
|
|
81
|
-
"organizationId": "oSyH1iET5",
|
|
82
|
-
"title": "sdk-movie-list",
|
|
83
|
-
"type": "application",
|
|
84
|
-
"updatedAt": "2025-03-27T19:00:32.792Z",
|
|
85
|
-
"url": "https://x7apsmr6fxvc.studio.sanity.work/",
|
|
86
|
-
"urlType": "internal",
|
|
87
|
-
}
|
|
88
|
-
`);
|
|
89
|
-
|
|
90
|
-
expectTypeOf(
|
|
91
|
-
application.toProtocolResource(),
|
|
92
|
-
).toEqualTypeOf<ProtocolApplicationResource>();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("should return undefined for subtitle", () => {
|
|
96
|
-
const application = setup();
|
|
97
|
-
expect(application.subtitle).toBeUndefined();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("get", () => {
|
|
101
|
-
it("should throw when accessing a non-existent attribute", () => {
|
|
102
|
-
const application = setup();
|
|
103
|
-
expect(() =>
|
|
104
|
-
// @ts-expect-error - testing invalid attribute
|
|
105
|
-
application.get("nonExistent"),
|
|
106
|
-
).toThrow(
|
|
107
|
-
"Attribute nonExistent does not exist on application v27rvqtlp3lmdvcln6ey3lro",
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe("manifest functionality", () => {
|
|
113
|
-
it("should use manifest from application when present", () => {
|
|
114
|
-
const application = new CoreAppApplication(
|
|
115
|
-
parseCoreApplication({
|
|
116
|
-
...APPLICATION_DATA,
|
|
117
|
-
activeDeployment: {
|
|
118
|
-
...APPLICATION_DATA.activeDeployment!,
|
|
119
|
-
manifest: {
|
|
120
|
-
version: "1.0.0",
|
|
121
|
-
icon: "<svg>test-icon</svg>",
|
|
122
|
-
title: "Manifest Title",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
}),
|
|
126
|
-
);
|
|
127
|
-
expect(application.title).toBe("Manifest Title");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("should use manifest from activeDeployment when application manifest is not present", () => {
|
|
131
|
-
const application = new CoreAppApplication(
|
|
132
|
-
parseCoreApplication({
|
|
133
|
-
...APPLICATION_DATA,
|
|
134
|
-
activeDeployment: {
|
|
135
|
-
...APPLICATION_DATA.activeDeployment!,
|
|
136
|
-
manifest: {
|
|
137
|
-
version: "1.0.0",
|
|
138
|
-
icon: "<svg>deployment-icon</svg>",
|
|
139
|
-
title: "Deployment Title",
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
}),
|
|
143
|
-
);
|
|
144
|
-
expect(application.title).toBe("Deployment Title");
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("should allow you to get attributes from the application", () => {
|
|
148
|
-
const application = setup();
|
|
149
|
-
|
|
150
|
-
expect(application.get("title")).toBe("sdk-movie-list");
|
|
151
|
-
expect(application.get("urlType")).toBe("internal");
|
|
152
|
-
expect(application.get("appHost")).toBe("x7apsmr6fxvc");
|
|
153
|
-
expectTypeOf(application.get("appHost")).toEqualTypeOf<string>();
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const VALID_INTERNAL_CORE_APP = {
|
|
159
|
-
id: "app-001",
|
|
160
|
-
appHost: "my-app-host",
|
|
161
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
162
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
163
|
-
dashboardStatus: "default",
|
|
164
|
-
title: "My App",
|
|
165
|
-
organizationId: "org-001",
|
|
166
|
-
type: "coreApp",
|
|
167
|
-
urlType: "internal",
|
|
168
|
-
activeDeployment: {
|
|
169
|
-
id: "deploy-001",
|
|
170
|
-
version: "1.0.0",
|
|
171
|
-
isActiveDeployment: true,
|
|
172
|
-
userApplicationId: "app-001",
|
|
173
|
-
isAutoUpdating: false,
|
|
174
|
-
manifest: null,
|
|
175
|
-
size: 500,
|
|
176
|
-
deployedAt: "2025-01-01T00:00:00Z",
|
|
177
|
-
deployedBy: "user-001",
|
|
178
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
179
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
180
|
-
},
|
|
181
|
-
} as const;
|
|
182
|
-
|
|
183
|
-
const VALID_EXTERNAL_CORE_APP = {
|
|
184
|
-
id: "app-002",
|
|
185
|
-
appHost: "https://my-app.example.com",
|
|
186
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
187
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
188
|
-
dashboardStatus: "default",
|
|
189
|
-
title: "My External App",
|
|
190
|
-
organizationId: "org-001",
|
|
191
|
-
type: "coreApp",
|
|
192
|
-
urlType: "external",
|
|
193
|
-
activeDeployment: null,
|
|
194
|
-
} as const;
|
|
195
|
-
|
|
196
|
-
describe("parseCoreApplication", () => {
|
|
197
|
-
it("parses a valid internal core application", () => {
|
|
198
|
-
const app = parseCoreApplication(VALID_INTERNAL_CORE_APP);
|
|
199
|
-
expect(app.urlType).toBe("internal");
|
|
200
|
-
expect(app.title).toBe("My App");
|
|
201
|
-
expectTypeOf(app).toEqualTypeOf<CoreAppUserApplication>();
|
|
202
|
-
expectTypeOf(app.id).toEqualTypeOf<UserApplicationId>();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("parses a valid external core application", () => {
|
|
206
|
-
const app = parseCoreApplication(VALID_EXTERNAL_CORE_APP);
|
|
207
|
-
expect(app.urlType).toBe("external");
|
|
208
|
-
expect(app.activeDeployment).toBeNull();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("rejects missing required fields", () => {
|
|
212
|
-
expect(() => parseCoreApplication({ id: "app-001" })).toThrow();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("rejects an empty id", () => {
|
|
216
|
-
expect(() =>
|
|
217
|
-
parseCoreApplication({ ...VALID_INTERNAL_CORE_APP, id: "" }),
|
|
218
|
-
).toThrow();
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("parses core app with deployment manifest", () => {
|
|
222
|
-
const app = parseCoreApplication({
|
|
223
|
-
...VALID_INTERNAL_CORE_APP,
|
|
224
|
-
activeDeployment: {
|
|
225
|
-
...VALID_INTERNAL_CORE_APP.activeDeployment,
|
|
226
|
-
manifest: {
|
|
227
|
-
version: "1.0.0",
|
|
228
|
-
title: "Manifest Title",
|
|
229
|
-
icon: "<svg></svg>",
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
expect(app.activeDeployment?.manifest?.title).toBe("Manifest Title");
|
|
235
|
-
});
|
|
236
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import type { UserApplicationId } from "../user-application";
|
|
4
|
-
import {
|
|
5
|
-
parseStudioUserApplication,
|
|
6
|
-
type StudioUserApplication,
|
|
7
|
-
} from "./schemas";
|
|
8
|
-
|
|
9
|
-
const VALID_INTERNAL_STUDIO = {
|
|
10
|
-
id: "studio-001",
|
|
11
|
-
appHost: "my-studio",
|
|
12
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
13
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
14
|
-
dashboardStatus: "default",
|
|
15
|
-
title: null,
|
|
16
|
-
projectId: "proj-001",
|
|
17
|
-
type: "studio",
|
|
18
|
-
urlType: "internal",
|
|
19
|
-
manifest: null,
|
|
20
|
-
manifestData: null,
|
|
21
|
-
autoUpdatingVersion: "latest",
|
|
22
|
-
activeDeployment: {
|
|
23
|
-
id: "deploy-001",
|
|
24
|
-
version: "4.0.0",
|
|
25
|
-
isActiveDeployment: true,
|
|
26
|
-
userApplicationId: "studio-001",
|
|
27
|
-
isAutoUpdating: true,
|
|
28
|
-
manifest: null,
|
|
29
|
-
size: 1000,
|
|
30
|
-
deployedAt: "2025-01-01T00:00:00Z",
|
|
31
|
-
deployedBy: "user-001",
|
|
32
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
33
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
34
|
-
},
|
|
35
|
-
config: {},
|
|
36
|
-
} as const;
|
|
37
|
-
|
|
38
|
-
const VALID_EXTERNAL_STUDIO = {
|
|
39
|
-
id: "studio-002",
|
|
40
|
-
appHost: "https://my-studio.example.com",
|
|
41
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
42
|
-
updatedAt: "2025-01-01T00:00:00Z",
|
|
43
|
-
dashboardStatus: "default",
|
|
44
|
-
title: "My External Studio",
|
|
45
|
-
projectId: "proj-001",
|
|
46
|
-
type: "studio",
|
|
47
|
-
urlType: "external",
|
|
48
|
-
manifest: null,
|
|
49
|
-
manifestData: null,
|
|
50
|
-
autoUpdatingVersion: null,
|
|
51
|
-
activeDeployment: null,
|
|
52
|
-
config: {},
|
|
53
|
-
} as const;
|
|
54
|
-
|
|
55
|
-
describe("parseStudioUserApplication", () => {
|
|
56
|
-
it("parses a valid internal studio application", () => {
|
|
57
|
-
const studio = parseStudioUserApplication(VALID_INTERNAL_STUDIO);
|
|
58
|
-
expect(studio.urlType).toBe("internal");
|
|
59
|
-
expect(studio.activeDeployment?.version).toBe("4.0.0");
|
|
60
|
-
expectTypeOf(studio).toEqualTypeOf<StudioUserApplication>();
|
|
61
|
-
expectTypeOf(studio.id).toEqualTypeOf<UserApplicationId>();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("parses a valid external studio application", () => {
|
|
65
|
-
const studio = parseStudioUserApplication(VALID_EXTERNAL_STUDIO);
|
|
66
|
-
expect(studio.urlType).toBe("external");
|
|
67
|
-
expect(studio.activeDeployment).toBeNull();
|
|
68
|
-
expect(studio.title).toBe("My External Studio");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("rejects missing required fields", () => {
|
|
72
|
-
expect(() => parseStudioUserApplication({ id: "studio-001" })).toThrow();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("rejects an empty id", () => {
|
|
76
|
-
expect(() =>
|
|
77
|
-
parseStudioUserApplication({ ...VALID_INTERNAL_STUDIO, id: "" }),
|
|
78
|
-
).toThrow();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("rejects invalid urlType", () => {
|
|
82
|
-
expect(() =>
|
|
83
|
-
parseStudioUserApplication({
|
|
84
|
-
...VALID_INTERNAL_STUDIO,
|
|
85
|
-
urlType: "unknown",
|
|
86
|
-
}),
|
|
87
|
-
).toThrow();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("parses studio with manifestData", () => {
|
|
91
|
-
const studio = parseStudioUserApplication({
|
|
92
|
-
...VALID_INTERNAL_STUDIO,
|
|
93
|
-
manifestData: {
|
|
94
|
-
value: {
|
|
95
|
-
version: 2,
|
|
96
|
-
createdAt: "2025-01-01T00:00:00Z",
|
|
97
|
-
workspaces: [
|
|
98
|
-
{
|
|
99
|
-
name: "default",
|
|
100
|
-
title: "Default",
|
|
101
|
-
basePath: "/",
|
|
102
|
-
projectId: "proj-001",
|
|
103
|
-
dataset: "production",
|
|
104
|
-
schema: "schema.json",
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
expect(studio.manifestData?.value.workspaces).toHaveLength(1);
|
|
112
|
-
});
|
|
113
|
-
});
|