test: tighten bedrock discovery assertions

This commit is contained in:
Peter Steinberger
2026-05-11 00:23:22 +01:00
parent b3c34d24bb
commit ee38655af0

View File

@@ -30,6 +30,16 @@ function mockSingleActiveSummary(overrides: Partial<typeof baseActiveAnthropicSu
.mockResolvedValueOnce({ inferenceProfileSummaries: [] });
}
function expectModelFields(model: unknown, expected: Record<string, unknown>): void {
expect(model).toBeDefined();
expect(typeof model).toBe("object");
expect(model).not.toBeNull();
const actual = model as Record<string, unknown>;
for (const [key, value] of Object.entries(expected)) {
expect(actual[key]).toEqual(value);
}
}
describe("bedrock discovery", () => {
beforeEach(() => {
sendMock.mockClear();
@@ -86,7 +96,7 @@ describe("bedrock discovery", () => {
const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
expect(models).toHaveLength(1);
expect(models[0]).toMatchObject({
expectModelFields(models[0], {
id: "anthropic.claude-3-7-sonnet-20250219-v1:0",
name: "Claude 3.7 Sonnet",
reasoning: false,
@@ -119,7 +129,7 @@ describe("bedrock discovery", () => {
config: { defaultContextWindow: 64000, defaultMaxTokens: 8192 },
clientFactory,
});
expect(models[0]).toMatchObject({ contextWindow: 64000, maxTokens: 8192 });
expectModelFields(models[0], { contextWindow: 64000, maxTokens: 8192 });
});
it("keeps the conservative fallback for unknown inference profiles", async () => {
@@ -147,7 +157,7 @@ describe("bedrock discovery", () => {
const models = await discoverBedrockModels({ region: "ap-northeast-1", clientFactory });
expect(models).toHaveLength(1);
expect(models[0]).toMatchObject({
expectModelFields(models[0], {
id: "jp.example.unknown-text-v1:0",
contextWindow: 32000,
maxTokens: 4096,
@@ -179,7 +189,7 @@ describe("bedrock discovery", () => {
const models = await discoverBedrockModels({ region: "ap-northeast-1", clientFactory });
expect(models[0]).toMatchObject({
expectModelFields(models[0], {
id: "jp.anthropic.claude-sonnet-4-6-v1:0",
contextWindow: 1_000_000,
});
@@ -317,17 +327,17 @@ describe("bedrock discovery", () => {
const globalProfile = models.find((m) => m.id === "global.anthropic.claude-sonnet-4-6");
// Foundation model has image input.
expect(foundationModel).toMatchObject({ input: ["text", "image"] });
expectModelFields(foundationModel, { input: ["text", "image"] });
// Inference profiles inherit image input from the foundation model.
expect(usProfile).toMatchObject({
expectModelFields(usProfile, {
name: "US Anthropic Claude Sonnet 4.6",
input: ["text", "image"],
contextWindow: 1000000,
maxTokens: 4096,
});
expect(euProfile).toMatchObject({ input: ["text", "image"] });
expect(globalProfile).toMatchObject({ input: ["text", "image"] });
expectModelFields(euProfile, { input: ["text", "image"] });
expectModelFields(globalProfile, { input: ["text", "image"] });
// Inactive profile should not be present.
expect(models.find((m) => m.id === "ap.anthropic.claude-sonnet-4-6")).toBeUndefined();
@@ -424,7 +434,7 @@ describe("bedrock discovery", () => {
const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
const profile = models.find((model) => model.id === "us.my-prod-profile");
expect(profile).toMatchObject({
expectModelFields(profile, {
id: "us.my-prod-profile",
input: ["text", "image"],
contextWindow: 1000000,
@@ -456,7 +466,7 @@ describe("bedrock discovery", () => {
const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
expect(models[0]).toMatchObject({
expectModelFields(models[0], {
id: "us.my-prod-profile",
contextWindow: 1_000_000,
maxTokens: 4096,
@@ -582,14 +592,14 @@ describe("bedrock discovery", () => {
expect(models).toHaveLength(3);
const auProfile = models.find((m) => m.id === "au.anthropic.claude-sonnet-4-6");
expect(auProfile).toMatchObject({
expectModelFields(auProfile, {
id: "au.anthropic.claude-sonnet-4-6",
name: "AU Anthropic Claude Sonnet 4.6",
input: ["text", "image"],
});
const apacProfile = models.find((m) => m.id === "apac.anthropic.claude-sonnet-4-6");
expect(apacProfile).toMatchObject({
expectModelFields(apacProfile, {
id: "apac.anthropic.claude-sonnet-4-6",
name: "APAC Anthropic Claude Sonnet 4.6",
input: ["text", "image"],