@@ -423,7 +435,7 @@ function CredentialSetup({
{hasConfigurableFields ? (
- fields.map((field) => (
+ visibleFields.map((field) => (
(
- DEFAULT_AWS_SCAN_MODE_CHOICE,
- );
+ const [awsScanMode, setAwsScanMode] = useState(DEFAULT_AWS_SCAN_MODE_CHOICE);
const allFields = provider.credentialFields ?? [];
const visibleFields = allFields.filter(
@@ -597,9 +607,7 @@ function CloudSetup({
)
: regionOptions;
const setupScript =
- provider.id === 'aws'
- ? getAwsCloudShellScript(awsEnvironment)
- : (provider.setupScript ?? '');
+ provider.id === 'aws' ? getAwsCloudShellScript(awsEnvironment) : (provider.setupScript ?? '');
const remediationScript = getAwsRemediationScript(awsEnvironment);
const cloudShellUrl = getAwsCloudShellUrl(awsEnvironment);
diff --git a/apps/app/src/components/integrations/ConnectionVariablesForm.test.tsx b/apps/app/src/components/integrations/ConnectionVariablesForm.test.tsx
index 99c00a4947..47e147b125 100644
--- a/apps/app/src/components/integrations/ConnectionVariablesForm.test.tsx
+++ b/apps/app/src/components/integrations/ConnectionVariablesForm.test.tsx
@@ -10,8 +10,10 @@ vi.mock('@trycompai/design-system', () => ({
),
Spinner: () => ,
- Select: ({ children }: { children: React.ReactNode }) => (
- {children}
+ Select: ({ children, value }: { children: React.ReactNode; value?: string }) => (
+
+ {children}
+
),
SelectTrigger: ({ children, id }: { children: React.ReactNode; id?: string }) => (
{children}
@@ -77,6 +79,36 @@ function renderFields(
);
}
+describe('ConnectionVariablesFields default preselection', () => {
+ const thresholdVariable = {
+ id: 'severity_threshold',
+ label: 'Fail at or above severity',
+ type: 'select',
+ required: false,
+ default: 'high',
+ options: [
+ { value: 'critical', label: 'Critical only' },
+ { value: 'high', label: 'High and above (default)' },
+ { value: 'low', label: 'Low and above' },
+ ],
+ } satisfies ConnectionVariable;
+
+ it('preselects a select variable default when no value is stored yet', () => {
+ // The boolean branch already falls back to `variable.default`; the select
+ // branch did not, so every defaulted dropdown rendered empty and the
+ // operator could not tell which value would be applied.
+ renderFields([thresholdVariable]);
+
+ expect(screen.getByTestId('ds-select')).toHaveAttribute('data-value', 'high');
+ });
+
+ it('leaves a select with no default empty', () => {
+ renderFields([{ ...thresholdVariable, default: undefined }]);
+
+ expect(screen.getByTestId('ds-select')).toHaveAttribute('data-value', '');
+ });
+});
+
describe('ConnectionVariablesFields dropdown clickability inside a modal', () => {
const modalSelectContentOptions = {
portal: false,
diff --git a/apps/app/src/components/integrations/ConnectionVariablesForm.tsx b/apps/app/src/components/integrations/ConnectionVariablesForm.tsx
index 78766302ca..506115c6fd 100644
--- a/apps/app/src/components/integrations/ConnectionVariablesForm.tsx
+++ b/apps/app/src/components/integrations/ConnectionVariablesForm.tsx
@@ -163,7 +163,7 @@ export function ConnectionVariablesFields({
/>
) : variable.type === 'select' ? (
- {credentialFields.map((field) => (
+ {visibleCredentialFields(credentialFields, credentialValues).map((field) => (