t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/CloudWatch/Dashboard.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

61 lines
2 KiB
TypeScript

import * as AWS from "@/AWS";
import { Dashboard } from "@/AWS/CloudWatch/Dashboard.ts";
import * as Provider from "@/Provider";
import * as Test from "@/Test/Alchemy";
import * as cloudwatch from "@distilled.cloud/aws/cloudwatch";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
const { test } = Test.make({ providers: AWS.providers() });
// Canonical `list()` test (AWS account/region-scoped collection): deploy a
// real dashboard, resolve the provider from context via `findProvider`, call
// `list()`, and assert the deployed dashboard appears in the exhaustively-
// paginated result.
test.provider(
"list enumerates the deployed dashboard",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const dashboard = yield* stack.deploy(
Effect.gen(function* () {
return yield* Dashboard("ListDashboard", {
name: "alchemy-test-dashboard-list",
DashboardBody: {
widgets: [
{
type: "text",
x: 0,
y: 0,
width: 6,
height: 3,
properties: { markdown: "# list test" },
},
],
},
});
}),
);
const provider = yield* Provider.findProvider(Dashboard);
const all = yield* provider.list();
expect(all.some((d) => d.dashboardName === dashboard.dashboardName)).toBe(
true,
);
yield* stack.destroy();
// Out-of-band assert-gone: getDashboard returns the typed
// DashboardNotFoundError once the dashboard is deleted.
const gone = yield* cloudwatch
.getDashboard({ DashboardName: dashboard.dashboardName })
.pipe(
Effect.map(() => false),
Effect.catchTag("DashboardNotFoundError", () => Effect.succeed(true)),
);
expect(gone).toBe(true);
}),
{ tags: ["provider:aws", "provider:aws:cloudwatch", "live"] },
);