@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 101 lines 3.43 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cci from "@distilled.cloud/gcp/contactcenterinsights_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 const waitUntilGone = (name: string) =>
15 cci.getProjectsLocationsAuthorizedViewSets({ name }).pipe(
16 Effect.as("found" as const),
17 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
18 Effect.repeat({
19 schedule: Schedule.spaced("1 second"),
20 until: (status) => status === "gone",
21 times: 10,
22 }),
23 );
24
25 test.provider(
26 "getProjectsLocationsAuthorizedViewSets on a missing set fails with a typed tag",
27 (stack) =>
28 Effect.gen(function* () {
29 const { project } = yield* GcpEnvironment.current;
30 yield* stack.destroy();
31
32 const error = yield* Effect.flip(
33 cci.getProjectsLocationsAuthorizedViewSets({
34 name: `projects/${project}/locations/us-central1/authorizedViewSets/alchemy-missing-set`,
35 }),
36 );
37 expect(error._tag).toEqual("NotFound");
38
39 yield* stack.destroy();
40 }).pipe(logLevel),
41 {
42 tags: ["provider:gcp", "provider:gcp:contactcenterinsights", "live"],
43 timeout: 90_000,
44 },
45 );
46
47 // Needs Contact Center AI Insights features the testing project does not
48 // have enabled: create returns 404 NOT_FOUND "Requested entity was not found." and list returns 400 INVALID_ARGUMENT.
49 test.provider.skipIf(!process.env.GCP_TEST_CCAI_QUALITY || !!process.env.FAST)(
50 "create, update, and delete an authorized view set",
51 (stack) =>
52 Effect.gen(function* () {
53 yield* stack.destroy();
54
55 const created = yield* stack.deploy(
56 Effect.gen(function* () {
57 return yield* GCP.ContactCenterInsights.AuthorizedViewSet("QaViews", {
58 displayName: "qa",
59 });
60 }),
61 );
62
63 expect(created.authorizedViewSetId).toEqual(expect.any(String));
64 expect(created.name).toContain("/authorizedViewSets/");
65 expect(created.location).toEqual("us-central1");
66 expect(created.displayName).toEqual("qa");
67
68 const fetched = yield* cci.getProjectsLocationsAuthorizedViewSets({
69 name: created.name,
70 });
71 expect(fetched.name).toEqual(created.name);
72 expect(fetched.displayName).toContain("alchemy-id=");
73
74 const updated = yield* stack.deploy(
75 Effect.gen(function* () {
76 return yield* GCP.ContactCenterInsights.AuthorizedViewSet("QaViews", {
77 authorizedViewSetId: created.authorizedViewSetId,
78 location: "us-central1",
79 displayName: "qa-v2",
80 });
81 }),
82 );
83
84 expect(updated.name).toEqual(created.name);
85 expect(updated.displayName).toEqual("qa-v2");
86
87 const fetchedUpdate = yield* cci.getProjectsLocationsAuthorizedViewSets({
88 name: updated.name,
89 });
90 expect(fetchedUpdate.displayName).toContain("qa-v2");
91
92 yield* stack.destroy();
93
94 const gone = yield* waitUntilGone(created.name);
95 expect(gone).toEqual("gone");
96 }).pipe(logLevel),
97 {
98 tags: ["provider:gcp", "provider:gcp:contactcenterinsights", "live"],
99 timeout: 90_000,
100 },
101 );