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
| 1 | import * as Axiom from "@alchemy.run/axiom"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Provider from "alchemy/Provider"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: Axiom.providers() }); |
| 9 | |
| 10 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 11 | |
| 12 | // Axiom credentials are resolved via the AuthProvider (env method reads |
| 13 | // AXIOM_TOKEN / AXIOM_API_KEY). When neither is present the suite can't talk |
| 14 | // to the real API, so skipIf-gate the live list test. On an entitled run the |
| 15 | // failure mode without creds is a `ConfigError`: |
| 16 | // "Axiom env credentials not found. Set AXIOM_TOKEN (or AXIOM_API_KEY)." |
| 17 | const hasAxiomCreds = !!(process.env.AXIOM_TOKEN || process.env.AXIOM_API_KEY); |
| 18 | |
| 19 | // Minimal, deterministic dashboard document. `owner: ""` is required when |
| 20 | // authenticating with an API token (Axiom rewrites it to the org-shared |
| 21 | // X-AXIOM-EVERYONE); relative windows use the `qr-now-*` form. |
| 22 | const dashboardProps = { |
| 23 | dashboard: { |
| 24 | name: "Alchemy List Test", |
| 25 | owner: "", |
| 26 | description: "list() lifecycle test dashboard", |
| 27 | charts: [], |
| 28 | layout: [], |
| 29 | refreshTime: 60, |
| 30 | schemaVersion: 2, |
| 31 | timeWindowStart: "qr-now-1h", |
| 32 | timeWindowEnd: "qr-now", |
| 33 | }, |
| 34 | }; |
| 35 | |
| 36 | test.provider.skipIf(!hasAxiomCreds)( |
| 37 | "list enumerates the deployed dashboard", |
| 38 | (stack) => |
| 39 | Effect.gen(function* () { |
| 40 | yield* stack.destroy(); |
| 41 | |
| 42 | const deployed = yield* stack.deploy( |
| 43 | Effect.gen(function* () { |
| 44 | return yield* Axiom.Dashboard("ListDashboard", dashboardProps); |
| 45 | }), |
| 46 | ); |
| 47 | |
| 48 | const provider = yield* Provider.findProvider(Axiom.Dashboard); |
| 49 | const all = yield* provider.list(); |
| 50 | |
| 51 | expect(all.length).toBeGreaterThan(0); |
| 52 | expect(all.some((d) => d.uid === deployed.uid)).toBe(true); |
| 53 | |
| 54 | const found = all.find((d) => d.uid === deployed.uid); |
| 55 | expect(found?.id).toEqual(deployed.id); |
| 56 | expect(found?.dashboard.name).toEqual("Alchemy List Test"); |
| 57 | |
| 58 | yield* stack.destroy(); |
| 59 | }).pipe(logLevel), |
| 60 | { tags: ["provider:axiom", "provider:axiom:dashboard", "live"] }, |
| 61 | ); |