1import * as AWS from "@/AWS";
2import * as Test from "@/Test/Alchemy";
3import * as transcribe from "@distilled.cloud/aws/transcribe";
4import { expect } from "alchemy-test";
5import * as Effect from "effect/Effect";
6import * as Result from "effect/Result";
7
8const { test } = Test.make({ providers: AWS.providers() });
9
10// Ungated typed-error probe: reading a nonexistent transcription job must
11// surface as a typed error from distilled's `GetTranscriptionJobError` union —
12// proves the SDK's typed error mapping and that the binding's callable is wired
13// against the real batch API, at zero cost (no S3 media, no job). The full
14// start→poll lifecycle needs an S3 audio input and multi-minute async
15// processing; it is gated behind AWS_TEST_SLOW=1.
16//
17// NOTE: AWS Transcribe reports a missing job as `BadRequestException` ("The
18// requested job couldn't be found."), NOT `NotFoundException` — a documented
19// API quirk. Both tags are in the typed union; we assert the one AWS actually
20// returns.
21test.provider(
22 "reading a nonexistent transcription job returns a typed BadRequestException",
23 (_stack) =>
24 Effect.gen(function* () {
25 const result = yield* Effect.result(
26 transcribe.getTranscriptionJob({
27 TranscriptionJobName: "alchemy-nonexistent-job-probe",
28 }),
29 );
30
31 expect(Result.isFailure(result)).toBe(true);
32 if (Result.isFailure(result)) {
33 expect(result.failure._tag).toBe("BadRequestException");
34 }
35 }),
36 {
37 tags: ["provider:aws", "provider:aws:transcribe", "live"],
38 timeout: 60_000,
39 },
40);