|
1 | 1 | // npx vitest run src/__tests__/cloud.test.ts |
2 | 2 |
|
3 | 3 | import { |
| 4 | + organizationCloudSettingsSchema, |
4 | 5 | organizationFeaturesSchema, |
5 | 6 | organizationSettingsSchema, |
| 7 | + type OrganizationCloudSettings, |
6 | 8 | type OrganizationFeatures, |
7 | 9 | type OrganizationSettings, |
| 10 | + type WorkspaceTaskVisibility, |
8 | 11 | } from "../cloud.js" |
9 | 12 |
|
10 | 13 | describe("organizationFeaturesSchema", () => { |
@@ -171,3 +174,84 @@ describe("organizationSettingsSchema with features", () => { |
171 | 174 | expect(result.data).toEqual(input) |
172 | 175 | }) |
173 | 176 | }) |
| 177 | + |
| 178 | +describe("organizationCloudSettingsSchema with workspaceTaskVisibility", () => { |
| 179 | + it("should validate without workspaceTaskVisibility property", () => { |
| 180 | + const input = { |
| 181 | + recordTaskMessages: true, |
| 182 | + enableTaskSharing: true, |
| 183 | + } |
| 184 | + const result = organizationCloudSettingsSchema.safeParse(input) |
| 185 | + expect(result.success).toBe(true) |
| 186 | + expect(result.data?.workspaceTaskVisibility).toBeUndefined() |
| 187 | + }) |
| 188 | + |
| 189 | + it("should validate with workspaceTaskVisibility as 'all'", () => { |
| 190 | + const input = { |
| 191 | + recordTaskMessages: true, |
| 192 | + workspaceTaskVisibility: "all" as WorkspaceTaskVisibility, |
| 193 | + } |
| 194 | + const result = organizationCloudSettingsSchema.safeParse(input) |
| 195 | + expect(result.success).toBe(true) |
| 196 | + expect(result.data?.workspaceTaskVisibility).toBe("all") |
| 197 | + }) |
| 198 | + |
| 199 | + it("should validate with workspaceTaskVisibility as 'list-only'", () => { |
| 200 | + const input = { |
| 201 | + workspaceTaskVisibility: "list-only" as WorkspaceTaskVisibility, |
| 202 | + } |
| 203 | + const result = organizationCloudSettingsSchema.safeParse(input) |
| 204 | + expect(result.success).toBe(true) |
| 205 | + expect(result.data?.workspaceTaskVisibility).toBe("list-only") |
| 206 | + }) |
| 207 | + |
| 208 | + it("should validate with workspaceTaskVisibility as 'full-lockdown'", () => { |
| 209 | + const input = { |
| 210 | + workspaceTaskVisibility: "full-lockdown" as WorkspaceTaskVisibility, |
| 211 | + } |
| 212 | + const result = organizationCloudSettingsSchema.safeParse(input) |
| 213 | + expect(result.success).toBe(true) |
| 214 | + expect(result.data?.workspaceTaskVisibility).toBe("full-lockdown") |
| 215 | + }) |
| 216 | + |
| 217 | + it("should reject invalid workspaceTaskVisibility value", () => { |
| 218 | + const input = { |
| 219 | + workspaceTaskVisibility: "invalid-value", |
| 220 | + } |
| 221 | + const result = organizationCloudSettingsSchema.safeParse(input) |
| 222 | + expect(result.success).toBe(false) |
| 223 | + }) |
| 224 | + |
| 225 | + it("should have correct TypeScript type", () => { |
| 226 | + // Type-only test to ensure TypeScript compilation |
| 227 | + const settings: OrganizationCloudSettings = { |
| 228 | + recordTaskMessages: true, |
| 229 | + workspaceTaskVisibility: "all", |
| 230 | + } |
| 231 | + expect(settings.workspaceTaskVisibility).toBe("all") |
| 232 | + |
| 233 | + const settingsWithoutVisibility: OrganizationCloudSettings = { |
| 234 | + recordTaskMessages: false, |
| 235 | + } |
| 236 | + expect(settingsWithoutVisibility.workspaceTaskVisibility).toBeUndefined() |
| 237 | + }) |
| 238 | + |
| 239 | + it("should validate in organizationSettingsSchema with workspaceTaskVisibility", () => { |
| 240 | + const input = { |
| 241 | + version: 1, |
| 242 | + cloudSettings: { |
| 243 | + recordTaskMessages: true, |
| 244 | + enableTaskSharing: true, |
| 245 | + workspaceTaskVisibility: "list-only" as WorkspaceTaskVisibility, |
| 246 | + }, |
| 247 | + defaultSettings: {}, |
| 248 | + allowList: { |
| 249 | + allowAll: true, |
| 250 | + providers: {}, |
| 251 | + }, |
| 252 | + } |
| 253 | + const result = organizationSettingsSchema.safeParse(input) |
| 254 | + expect(result.success).toBe(true) |
| 255 | + expect(result.data?.cloudSettings?.workspaceTaskVisibility).toBe("list-only") |
| 256 | + }) |
| 257 | +}) |
0 commit comments