Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MD]Severless Support: update data-test-subjattribute for functional tests & fix bug in edit flow #4126

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
zhongnansu marked this conversation as resolved.
Show resolved Hide resolved
/>
</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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to modify the file "edit_data_source_form.test.tsx" ? Thanks

Copy link
Member Author

@zhongnansu zhongnansu May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, "data-test-subj" attributes are for cypress tests only. I have a PR open in the cypress test repo using those updated values. opensearch-project/opensearch-dashboards-functional-test#665

/>
</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