@sanity/workbench 0.1.0-alpha.7 → 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.
Files changed (34) hide show
  1. package/dist/_chunks-es/index.js +6 -1
  2. package/dist/_chunks-es/index.js.map +1 -1
  3. package/dist/_internal.js +3 -8
  4. package/dist/_internal.js.map +1 -1
  5. package/dist/core.d.ts +582 -24
  6. package/dist/core.js +207 -105
  7. package/dist/core.js.map +1 -1
  8. package/package.json +9 -3
  9. package/src/_internal/render.ts +4 -11
  10. package/src/core/applications/application-list.ts +1 -1
  11. package/src/core/applications/local-application.ts +6 -2
  12. package/src/core/canvases.ts +1 -1
  13. package/src/core/index.ts +1 -1
  14. package/src/core/log/index.ts +12 -0
  15. package/src/core/media-libraries.ts +1 -1
  16. package/src/core/user-applications/core-app.ts +66 -10
  17. package/src/core/user-applications/studios/index.ts +3 -0
  18. package/src/core/user-applications/studios/schemas.ts +106 -0
  19. package/src/core/user-applications/{studio.ts → studios/studio.ts} +56 -214
  20. package/src/core/user-applications/studios/workspace.ts +143 -0
  21. package/src/core/user-applications/user-application.ts +36 -5
  22. package/src/_internal/render.test.ts +0 -73
  23. package/src/core/__tests__/__fixtures__.ts +0 -248
  24. package/src/core/applications/application-list.test.ts +0 -222
  25. package/src/core/applications/local-application.test.ts +0 -93
  26. package/src/core/canvases.test.ts +0 -38
  27. package/src/core/log/index.test.ts +0 -133
  28. package/src/core/media-libraries.test.ts +0 -38
  29. package/src/core/organizations.test.ts +0 -134
  30. package/src/core/projects.test.ts +0 -248
  31. package/src/core/shared/urls.test.ts +0 -182
  32. package/src/core/user-applications/core-app.test.ts +0 -151
  33. package/src/core/user-applications/studio.test.ts +0 -928
  34. package/src/core/user-applications/user-application.test.ts +0 -126
@@ -1,126 +0,0 @@
1
- import type {
2
- ApplicationResource as ProtocolApplicationResource,
3
- CoreApplication,
4
- } from "@sanity/message-protocol";
5
- import { afterEach, describe, expect, it, vi } from "vitest";
6
-
7
- import { APPLICATION_DATA } from "../__tests__/__fixtures__";
8
- import { UserApplication as AbstractUserApplication } from "./user-application";
9
-
10
- class UserApplication extends AbstractUserApplication<
11
- CoreApplication,
12
- "coreApp",
13
- ProtocolApplicationResource
14
- > {
15
- constructor(application: CoreApplication) {
16
- super(application, "coreApp");
17
- }
18
-
19
- get title(): string {
20
- return this.application.title;
21
- }
22
-
23
- get subtitle() {
24
- return undefined;
25
- }
26
-
27
- get href(): string {
28
- return "";
29
- }
30
-
31
- toProtocolResource() {
32
- return {
33
- ...this.application,
34
- type: "application",
35
- url: this.url.toString(),
36
- } as const;
37
- }
38
- }
39
-
40
- const setup = (overrides?: Partial<CoreApplication>) =>
41
- new UserApplication({
42
- ...APPLICATION_DATA,
43
- ...overrides,
44
- } as CoreApplication);
45
-
46
- describe("UserApplication", () => {
47
- afterEach(() => {
48
- vi.unstubAllEnvs();
49
- });
50
-
51
- it("should generate a url for an internal application", () => {
52
- vi.stubEnv("VITE_SANITY_ENV", "staging");
53
- vi.stubEnv("VITE_SANITY_DOMAIN", "sanity.work");
54
- const application = setup();
55
- expect(application.url).toBeInstanceOf(URL);
56
- expect(application.url.toString()).toMatchInlineSnapshot(
57
- `"https://x7apsmr6fxvc.studio.sanity.work/"`,
58
- );
59
- });
60
-
61
- it("should respect the SANITY_ENV", () => {
62
- vi.stubEnv("VITE_SANITY_ENV", "production");
63
- const application = setup();
64
- expect(application.url).toBeInstanceOf(URL);
65
- expect(application.url.toString()).toMatchInlineSnapshot(
66
- `"https://x7apsmr6fxvc.sanity.studio/"`,
67
- );
68
- });
69
-
70
- it("should generate a url for an external application", () => {
71
- const application = setup({
72
- ...APPLICATION_DATA,
73
- activeDeployment: null,
74
- appHost: "https://my-app.com",
75
- urlType: "external",
76
- });
77
- expect(application.url).toBeInstanceOf(URL);
78
- expect(application.url.toString()).toMatchInlineSnapshot(
79
- `"https://my-app.com/"`,
80
- );
81
- });
82
-
83
- describe("initials", () => {
84
- const initials = (title: string) => setup({ title }).initials;
85
-
86
- it("should return the initials of a name", () => {
87
- expect(initials("John Doe")).toBe("JD");
88
- });
89
-
90
- it("should return the initials of a name with extra spaces", () => {
91
- expect(initials(" John Doe ")).toBe("JD");
92
- });
93
-
94
- it("should return intials even if the name is only one word", () => {
95
- expect(initials("John")).toBe("J");
96
- });
97
-
98
- it("should return a maximum of two initials", () => {
99
- expect(initials("John Doe Smith")).toBe("JS");
100
- });
101
-
102
- it("should handle empty string", () => {
103
- expect(initials("")).toBe("");
104
- });
105
-
106
- it("should handle symbols-only string", () => {
107
- expect(initials("@#$%")).toBe("");
108
- });
109
-
110
- it("should handle a single character", () => {
111
- expect(initials("A")).toBe("A");
112
- });
113
-
114
- it("should handle strings containing numbers", () => {
115
- expect(initials("0xHoldings")).toBe("0X");
116
- expect(initials("7-Eleven")).toBe("7E");
117
- expect(initials("Forever 21")).toBe("F2");
118
- expect(initials("Motel 6")).toBe("M6");
119
- expect(initials("2 Wire")).toBe("2W");
120
-
121
- expect(initials("010101")).toBe("01");
122
- expect(initials("W4t")).toBe("W4");
123
- expect(initials("H4xx0r")).toBe("H4");
124
- });
125
- });
126
- });