Skip to content

Commit 59f1bb7

Browse files
committed
test(bedrock): cover ARN reset auto-detect and Bedrock 1M/service-tier options
Refs Zoo-Code-Org#1968
1 parent 0407dfe commit 59f1bb7

3 files changed

Lines changed: 55 additions & 13 deletions

File tree

‎packages/types/src/__tests__/bedrock-custom-arn.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe("resolveBedrockCustomArnBaseModelId", () => {
4444
).toBe("anthropic.claude-opus-4-8")
4545
})
4646

47+
it("treats an empty base model, stored after an ARN change, as auto-detect", () => {
48+
expect(
49+
resolveBedrockCustomArnBaseModelId(
50+
"arn:aws:bedrock:us-east-1:123456789012:inference-profile/us.anthropic.claude-opus-4-8",
51+
"",
52+
),
53+
).toBe("anthropic.claude-opus-4-8")
54+
})
55+
4756
it("lets an explicit Other choice override a model named in the ARN", () => {
4857
expect(
4958
resolveBedrockCustomArnBaseModelId(

‎webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx‎

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -552,31 +552,55 @@ describe("Bedrock Component", () => {
552552
})
553553
})
554554

555-
describe("custom ARN capabilities", () => {
555+
describe("1M context and service tier options", () => {
556556
const oneMillionCheckbox = "checkbox-settings:providers.awsbedrock1mcontextbetalabel"
557+
const serviceTierLabel = "settings:providers.awsServiceTier"
558+
const appProfileArn = "arn:aws:bedrock:us-west-2:123456789012:application-inference-profile/abcd1234efgh"
559+
const renderBedrock = (settings: Partial<ProviderSettings>) =>
560+
render(<Bedrock apiConfiguration={settings} setApiConfigurationField={mockSetApiConfigurationField} />)
557561
const renderCustomArn = (awsCustomArnBaseModelId?: string) =>
558-
render(
559-
<Bedrock
560-
apiConfiguration={{
561-
apiModelId: "custom-arn",
562-
awsCustomArn:
563-
"arn:aws:bedrock:us-west-2:123456789012:application-inference-profile/abcd1234efgh",
564-
awsCustomArnBaseModelId,
565-
}}
566-
setApiConfigurationField={mockSetApiConfigurationField}
567-
/>,
568-
)
562+
renderBedrock({ apiModelId: "custom-arn", awsCustomArn: appProfileArn, awsCustomArnBaseModelId })
563+
564+
it("offers the 1M context option, not service tiers, for a regular Opus 4.8 model", () => {
565+
renderBedrock({ apiModelId: "anthropic.claude-opus-4-8" })
566+
567+
expect(screen.getByTestId(oneMillionCheckbox)).toBeInTheDocument()
568+
expect(screen.queryByText(serviceTierLabel)).not.toBeInTheDocument()
569+
})
570+
571+
it("offers service tiers, not the 1M context option, for a regular Nova model", () => {
572+
renderBedrock({ apiModelId: "amazon.nova-lite-v1:0" })
573+
574+
expect(screen.getByText(serviceTierLabel)).toBeInTheDocument()
575+
expect(screen.queryByTestId(oneMillionCheckbox)).not.toBeInTheDocument()
576+
})
577+
578+
it("ignores a leftover custom ARN base model when a regular model is selected", () => {
579+
renderBedrock({ apiModelId: "amazon.nova-lite-v1:0", awsCustomArnBaseModelId: "anthropic.claude-opus-4-8" })
580+
581+
expect(screen.getByText(serviceTierLabel)).toBeInTheDocument()
582+
expect(screen.queryByTestId(oneMillionCheckbox)).not.toBeInTheDocument()
583+
})
569584

570585
it("offers the 1M context option when the custom ARN's base model supports it", () => {
571586
renderCustomArn("anthropic.claude-opus-4-8")
572587

573588
expect(screen.getByTestId(oneMillionCheckbox)).toBeInTheDocument()
589+
expect(screen.queryByText(serviceTierLabel)).not.toBeInTheDocument()
590+
})
591+
592+
it("offers service tiers when the custom ARN's base model supports them", () => {
593+
renderCustomArn("amazon.nova-lite-v1:0")
594+
595+
expect(screen.getByText(serviceTierLabel)).toBeInTheDocument()
596+
expect(screen.queryByTestId(oneMillionCheckbox)).not.toBeInTheDocument()
574597
})
575598

576-
it("hides the 1M context option when the custom ARN's base model is unknown", () => {
599+
it("hides both options when the custom ARN's base model is unknown", () => {
577600
renderCustomArn()
578601

579602
expect(screen.queryByTestId(oneMillionCheckbox)).not.toBeInTheDocument()
603+
expect(screen.queryByText(serviceTierLabel)).not.toBeInTheDocument()
580604
})
581605
})
582606
})

‎webview-ui/src/components/settings/providers/__tests__/BedrockCustomArn.spec.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ describe("BedrockCustomArn base model", () => {
151151
expect(setApiConfigurationField).toHaveBeenCalledWith("reasoningEffort", undefined)
152152
})
153153

154+
it("stores the first ARN entered when none is set yet", () => {
155+
const setApiConfigurationField = renderCustomArn({ awsCustomArn: undefined })
156+
157+
fireEvent.input(screen.getByTestId("custom-arn-input"), { target: { value: appProfileArn } })
158+
159+
expect(setApiConfigurationField).toHaveBeenCalledWith("awsCustomArn", appProfileArn)
160+
expect(setApiConfigurationField).toHaveBeenCalledWith("awsCustomArnBaseModelId", "")
161+
})
162+
154163
it("keeps the base model when the ARN input doesn't change the ARN", () => {
155164
const setApiConfigurationField = renderCustomArn({ awsCustomArnBaseModelId: "anthropic.claude-opus-5-5" })
156165

0 commit comments

Comments
 (0)