Skip to content

Commit 9804b2d

Browse files
[MD]Update data-test-subj for functional tests & fix bug in edit flow (#4126)
Signed-off-by: Su <szhongna@amazon.com> (cherry picked from commit 574f119) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1c09ca6 commit 9804b2d

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export class CreateDataSourceForm extends React.Component<
430430
value={this.state.auth.credentials.service}
431431
onChange={(e) => this.onChangeSigV4ServiceName(e)}
432432
name="ServiceName"
433-
data-test-subj="createDataSourceFormAuthTypeSelect"
433+
data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"
434434
/>
435435
</EuiFormRow>
436436
<EuiFormRow

src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx

+23-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface EditDataSourceState {
5959
endpoint: string;
6060
auth: {
6161
type: AuthType;
62-
credentials: UsernamePasswordTypedContent | SigV4Content | undefined;
62+
credentials: UsernamePasswordTypedContent | SigV4Content;
6363
};
6464
showUpdatePasswordModal: boolean;
6565
showUpdateAwsCredentialModal: boolean;
@@ -167,9 +167,24 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
167167
};
168168

169169
onChangeAuthType = (e: React.ChangeEvent<HTMLSelectElement>) => {
170-
this.setState({ auth: { ...this.state.auth, type: e.target.value as AuthType } }, () => {
171-
this.onChangeFormValues();
172-
});
170+
const authType = e.target.value as AuthType;
171+
this.setState(
172+
{
173+
auth: {
174+
...this.state.auth,
175+
type: authType,
176+
credentials: {
177+
...this.state.auth.credentials,
178+
service:
179+
(this.state.auth.credentials?.service as SigV4ServiceName) ||
180+
SigV4ServiceName.OpenSearch,
181+
},
182+
},
183+
},
184+
() => {
185+
this.onChangeFormValues();
186+
}
187+
);
173188
};
174189

175190
onChangeDescription = (e: { target: { value: any } }) => {
@@ -804,7 +819,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
804819
value={this.state.auth.credentials?.region || ''}
805820
onChange={this.onChangeRegion}
806821
onBlur={this.validateRegion}
807-
data-test-subj="updateDataSourceFormRegionField"
822+
data-test-subj="editDataSourceFormRegionField"
808823
/>
809824
</EuiFormRow>
810825
<EuiFormRow
@@ -817,7 +832,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
817832
value={this.state.auth.credentials?.service}
818833
onChange={(e) => this.onChangeSigV4ServiceName(e)}
819834
name="ServiceName"
820-
data-test-subj="createDataSourceFormAuthTypeSelect"
835+
data-test-subj="editDataSourceFormSigV4ServiceTypeSelect"
821836
/>
822837
</EuiFormRow>
823838
<EuiFormRow
@@ -845,7 +860,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
845860
onBlur={this.validateAccessKey}
846861
spellCheck={false}
847862
disabled={this.props.existingDataSource.auth.type === AuthType.SigV4}
848-
data-test-subj="updateDataSourceFormAccessKeyField"
863+
data-test-subj="editDataSourceFormAccessKeyField"
849864
/>
850865
</EuiFormRow>
851866
<EuiFormRow
@@ -873,7 +888,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
873888
onBlur={this.validateSecretKey}
874889
spellCheck={false}
875890
disabled={this.props.existingDataSource.auth.type === AuthType.SigV4}
876-
data-test-subj="updateDataSourceFormSecretKeyField"
891+
data-test-subj="editDataSourceFormSecretKeyField"
877892
/>
878893
</EuiFormRow>
879894
<EuiSpacer />

0 commit comments

Comments
 (0)