Skip to content

Commit f32f146

Browse files
author
Kevin White
committed
Add example URLs to Bedrock VPC endpoint section and update tests
1 parent 42be6dc commit f32f146

File tree

2 files changed

+69
-8
lines changed

2 files changed

+69
-8
lines changed

webview-ui/src/components/settings/providers/Bedrock.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,21 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
135135
Use custom VPC endpoint
136136
</Checkbox>
137137
{awsEndpointSelected && (
138-
<VSCodeTextField
139-
value={apiConfiguration?.awsBedrockEndpoint || ""}
140-
style={{ width: "100%", marginTop: 3, marginBottom: 5 }}
141-
type="url"
142-
onInput={handleInputChange("awsBedrockEndpoint")}
143-
placeholder="Enter VPC Endpoint URL (optional)"
144-
data-testid="vpc-endpoint-input"
145-
/>
138+
<>
139+
<VSCodeTextField
140+
value={apiConfiguration?.awsBedrockEndpoint || ""}
141+
style={{ width: "100%", marginTop: 3, marginBottom: 5 }}
142+
type="url"
143+
onInput={handleInputChange("awsBedrockEndpoint")}
144+
placeholder="Enter VPC Endpoint URL (optional)"
145+
data-testid="vpc-endpoint-input"
146+
/>
147+
<div className="text-sm text-vscode-descriptionForeground ml-6 mt-1 mb-3">
148+
Examples:
149+
<div className="ml-2">• https://vpce-xxx.bedrock.region.vpce.amazonaws.com/</div>
150+
<div className="ml-2">• https://gateway.my-company.com/route/app/bedrock</div>
151+
</div>
152+
</>
146153
)}
147154
</>
148155
)

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,60 @@ describe("Bedrock Component", () => {
250250
})
251251
})
252252

253+
// Test Scenario 3: UI Elements Tests
254+
describe("UI Elements", () => {
255+
it("should display example URLs when VPC endpoint checkbox is checked", () => {
256+
const apiConfiguration: Partial<ProviderSettings> = {
257+
awsBedrockEndpoint: "https://example.com",
258+
awsBedrockEndpointEnabled: true,
259+
awsUseProfile: true,
260+
}
261+
262+
render(
263+
<Bedrock
264+
apiConfiguration={apiConfiguration as ProviderSettings}
265+
setApiConfigurationField={mockSetApiConfigurationField}
266+
/>,
267+
)
268+
269+
// Check that the VPC endpoint input is visible
270+
expect(screen.getByTestId("vpc-endpoint-input")).toBeInTheDocument()
271+
272+
// Check for the example URLs section
273+
// Since we don't have a specific testid for the examples section,
274+
// we'll check for the text content
275+
expect(screen.getByText("Examples:")).toBeInTheDocument()
276+
expect(screen.getByText("• https://vpce-xxx.bedrock.region.vpce.amazonaws.com/")).toBeInTheDocument()
277+
expect(screen.getByText("• https://gateway.my-company.com/route/app/bedrock")).toBeInTheDocument()
278+
})
279+
280+
it("should hide example URLs when VPC endpoint checkbox is unchecked", () => {
281+
const apiConfiguration: Partial<ProviderSettings> = {
282+
awsBedrockEndpoint: "https://example.com",
283+
awsBedrockEndpointEnabled: true,
284+
awsUseProfile: true,
285+
}
286+
287+
render(
288+
<Bedrock
289+
apiConfiguration={apiConfiguration as ProviderSettings}
290+
setApiConfigurationField={mockSetApiConfigurationField}
291+
/>,
292+
)
293+
294+
// Initially the examples should be visible
295+
expect(screen.getByText("Examples:")).toBeInTheDocument()
296+
297+
// Uncheck the VPC endpoint checkbox
298+
fireEvent.click(screen.getByTestId("checkbox-input-use-custom-vpc-endpoint"))
299+
300+
// Now the examples should be hidden
301+
expect(screen.queryByText("Examples:")).not.toBeInTheDocument()
302+
expect(screen.queryByText("• https://vpce-xxx.bedrock.region.vpce.amazonaws.com/")).not.toBeInTheDocument()
303+
expect(screen.queryByText("• https://gateway.my-company.com/route/app/bedrock")).not.toBeInTheDocument()
304+
})
305+
})
306+
253307
// Test Scenario 4: Error Handling Tests
254308
describe("Error Handling", () => {
255309
it("should handle invalid endpoint URLs gracefully", () => {

0 commit comments

Comments
 (0)