Skip to content

Commit

Permalink
[MD]Update data-test-subj for functional tests & fix bug in edit flow (
Browse files Browse the repository at this point in the history
…#4126)

Signed-off-by: Su <[email protected]>
  • Loading branch information
zhongnansu authored May 25, 2023
1 parent 6399a6c commit 574f119
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export class CreateDataSourceForm extends React.Component<
value={this.state.auth.credentials.service}
onChange={(e) => this.onChangeSigV4ServiceName(e)}
name="ServiceName"
data-test-subj="createDataSourceFormAuthTypeSelect"
data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"
/>
</EuiFormRow>
<EuiFormRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface EditDataSourceState {
endpoint: string;
auth: {
type: AuthType;
credentials: UsernamePasswordTypedContent | SigV4Content | undefined;
credentials: UsernamePasswordTypedContent | SigV4Content;
};
showUpdatePasswordModal: boolean;
showUpdateAwsCredentialModal: boolean;
Expand Down Expand Up @@ -167,9 +167,24 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
};

onChangeAuthType = (e: React.ChangeEvent<HTMLSelectElement>) => {
this.setState({ auth: { ...this.state.auth, type: e.target.value as AuthType } }, () => {
this.onChangeFormValues();
});
const authType = e.target.value as AuthType;
this.setState(
{
auth: {
...this.state.auth,
type: authType,
credentials: {
...this.state.auth.credentials,
service:
(this.state.auth.credentials?.service as SigV4ServiceName) ||
SigV4ServiceName.OpenSearch,
},
},
},
() => {
this.onChangeFormValues();
}
);
};

onChangeDescription = (e: { target: { value: any } }) => {
Expand Down Expand Up @@ -804,7 +819,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
value={this.state.auth.credentials?.region || ''}
onChange={this.onChangeRegion}
onBlur={this.validateRegion}
data-test-subj="updateDataSourceFormRegionField"
data-test-subj="editDataSourceFormRegionField"
/>
</EuiFormRow>
<EuiFormRow
Expand All @@ -817,7 +832,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
value={this.state.auth.credentials?.service}
onChange={(e) => this.onChangeSigV4ServiceName(e)}
name="ServiceName"
data-test-subj="createDataSourceFormAuthTypeSelect"
data-test-subj="editDataSourceFormSigV4ServiceTypeSelect"
/>
</EuiFormRow>
<EuiFormRow
Expand Down Expand Up @@ -845,7 +860,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
onBlur={this.validateAccessKey}
spellCheck={false}
disabled={this.props.existingDataSource.auth.type === AuthType.SigV4}
data-test-subj="updateDataSourceFormAccessKeyField"
data-test-subj="editDataSourceFormAccessKeyField"
/>
</EuiFormRow>
<EuiFormRow
Expand Down Expand Up @@ -873,7 +888,7 @@ export class EditDataSourceForm extends React.Component<EditDataSourceProps, Edi
onBlur={this.validateSecretKey}
spellCheck={false}
disabled={this.props.existingDataSource.auth.type === AuthType.SigV4}
data-test-subj="updateDataSourceFormSecretKeyField"
data-test-subj="editDataSourceFormSecretKeyField"
/>
</EuiFormRow>
<EuiSpacer />
Expand Down

0 comments on commit 574f119

Please sign in to comment.