1import * as AWS from "@/AWS";
2import { Instance } from "@/AWS/IdentityCenter";
3import * as Provider from "@/Provider";
4import * as Test from "@/Test/Alchemy";
5import { expect } from "alchemy-test";
6import * as Effect from "effect/Effect";
7
8const { test } = Test.make({ providers: AWS.providers() });
9
10// An IAM Identity Center instance is a pre-existing account/organization
11// singleton — you generally cannot create one inside a test. `list()`
12// enumerates every visible instance via `ListInstances` and returns the
13// exact `read` Attributes shape. Accounts without SSO enabled return `[]`
14// (not an error), so this test asserts a well-typed `Attributes[]` and
15// validates the element shape only when at least one instance exists.
16test.provider(
17 "list enumerates visible Identity Center instances",
18 () =>
19 Effect.gen(function* () {
20 const provider = yield* Provider.findProvider(Instance);
21 const all = yield* provider.list();
22
23 expect(Array.isArray(all)).toBe(true);
24
25 for (const instance of all) {
26 expect(typeof instance.instanceArn).toBe("string");
27 expect(instance.instanceArn.length).toBeGreaterThan(0);
28 expect(typeof instance.identityStoreId).toBe("string");
29 expect(instance.identityStoreId.length).toBeGreaterThan(0);
30 expect(instance.mode).toBe("existing");
31 }
32 }),
33 { tags: ["provider:aws", "provider:aws:identitycenter", "live"] },
34);