Merge pull request #11123 from AlexSCorey/11028-MeshFix

Removes receptor instances from select option on metrics screen
This commit is contained in:
Alex Corey
2021-09-23 16:16:38 -04:00
committed by GitHub
2 changed files with 24 additions and 2 deletions

View File

@@ -70,9 +70,16 @@ function Metrics() {
]); ]);
const metricOptions = Object.keys(mets); const metricOptions = Object.keys(mets);
const instanceNames = [];
results.forEach((result) => {
if (result.node_type !== 'execution') {
instanceNames.push(result.hostname);
}
});
return { return {
instances: [...results.map((result) => result.hostname), t`All`], instances:
instanceNames.length > 1 ? [...instanceNames, t`All`] : instanceNames,
metrics: metricOptions, metrics: metricOptions,
}; };
}, []), }, []),

View File

@@ -13,7 +13,11 @@ describe('<Metrics/>', () => {
beforeEach(async () => { beforeEach(async () => {
InstancesAPI.read.mockResolvedValue({ InstancesAPI.read.mockResolvedValue({
data: { data: {
results: [{ hostname: 'instance 1' }, { hostname: 'instance 2' }], results: [
{ hostname: 'instance 1', node_type: 'control' },
{ hostname: 'instance 2', node_type: 'hybrid' },
{ hostname: 'receptor', node_type: 'execution' },
],
}, },
}); });
MetricsAPI.read.mockResolvedValue({ MetricsAPI.read.mockResolvedValue({
@@ -70,4 +74,15 @@ describe('<Metrics/>', () => {
node: 'instance 1', node: 'instance 1',
}); });
}); });
test('should not include receptor instances', async () => {
await act(async () => {
wrapper.find('Select[ouiaId="Instance-select"]').prop('onToggle')(true);
});
wrapper.update();
expect(wrapper.find('SelectOption[value="receptor"]')).toHaveLength(0);
expect(
wrapper.find('Select[ouiaId="Instance-select"]').find('SelectOption')
).toHaveLength(3);
});
}); });