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
commit fd3a82d430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

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

View File

@ -13,7 +13,11 @@ describe('<Metrics/>', () => {
beforeEach(async () => {
InstancesAPI.read.mockResolvedValue({
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({
@ -70,4 +74,15 @@ describe('<Metrics/>', () => {
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);
});
});