CloudWatch: Fix display name of metric and namespace (#54860)

* convert value to option

* add unit test

* fix lint issue
This commit is contained in:
Erik Sundell 2022-09-09 14:15:32 +02:00 committed by GitHub
parent 34e06dbe18
commit a37fa758a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -191,4 +191,14 @@ describe('MetricStatEditor', () => {
]);
});
});
describe('metric value', () => {
it('should be displayed when a custom value is used and its value is not in the select options', async () => {
const expected = 'CPUUtilzation';
await act(async () => {
render(<MetricStatEditor {...props} metricStat={{ ...props.metricStat, metricName: expected }} />);
});
expect(await screen.findByText(expected)).toBeInTheDocument();
});
});
});

View File

@ -61,7 +61,7 @@ export function MetricStatEditor({
<EditorField label="Namespace" width={26}>
<Select
aria-label="Namespace"
value={metricStat.namespace}
value={metricStat?.namespace && toOption(metricStat.namespace)}
allowCustomValue
options={namespaces}
onChange={({ value: namespace }) => {
@ -74,7 +74,7 @@ export function MetricStatEditor({
<EditorField label="Metric name" width={16}>
<Select
aria-label="Metric name"
value={metricStat.metricName || null}
value={metricStat?.metricName && toOption(metricStat.metricName)}
allowCustomValue
options={metrics}
onChange={({ value: metricName }) => {