mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-14 02:27:02 +02:00
* testing bar chart changeS * Added namespace search to client count - Used existing search select component for namespace search * Added changelog * Added download csv component - generate namespaces data in csv format - Show root in top 10 namespaces - Changed active direct tokens to non-entity tokens * Added test for checking graph render * Added documentation for the download csv component * correctly updates chart when data changes * Cleaned up template and tooltip * Added changelog * updates label tooltip and regroups dom elements Co-authored-by: Arnav Palnitkar <arnav@hashicorp.com>
86 lines
2.5 KiB
JavaScript
86 lines
2.5 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { findAll, render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
|
|
module('Integration | Component | bar-chart', function(hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('it renders', async function(assert) {
|
|
let dataset = [
|
|
{
|
|
namespace_id: 'root',
|
|
namespace_path: 'root',
|
|
counts: {
|
|
distinct_entities: 268,
|
|
non_entity_tokens: 985,
|
|
clients: 1253,
|
|
},
|
|
},
|
|
{
|
|
namespace_id: 'O0i4m',
|
|
namespace_path: 'top-namespace',
|
|
counts: {
|
|
distinct_entities: 648,
|
|
non_entity_tokens: 220,
|
|
clients: 868,
|
|
},
|
|
},
|
|
{
|
|
namespace_id: '1oihz',
|
|
namespace_path: 'anotherNamespace',
|
|
counts: {
|
|
distinct_entities: 547,
|
|
non_entity_tokens: 337,
|
|
clients: 884,
|
|
},
|
|
},
|
|
{
|
|
namespace_id: '1oihz',
|
|
namespace_path: 'someOtherNamespaceawgagawegawgawgawgaweg',
|
|
counts: {
|
|
distinct_entities: 807,
|
|
non_entity_tokens: 234,
|
|
clients: 1041,
|
|
},
|
|
},
|
|
];
|
|
|
|
let flattenData = () => {
|
|
return dataset.map(d => {
|
|
return {
|
|
label: d['namespace_path'],
|
|
non_entity_tokens: d['counts']['non_entity_tokens'],
|
|
distinct_entities: d['counts']['distinct_entities'],
|
|
total: d['counts']['clients'],
|
|
};
|
|
});
|
|
};
|
|
|
|
this.set('title', 'Top Namespaces');
|
|
this.set('description', 'Each namespaces client count includes clients in child namespaces.');
|
|
this.set('dataset', flattenData());
|
|
|
|
await render(hbs`
|
|
<BarChart
|
|
@title={{title}}
|
|
@description={{description}}
|
|
@dataset={{dataset}}
|
|
@mapLegend={{array
|
|
(hash key="non_entity_tokens" label="Active direct tokens")
|
|
(hash key="distinct_entities" label="Unique Entities")}}
|
|
>
|
|
<button type="button" class="link">
|
|
Export all namespace data
|
|
</button>
|
|
</BarChart>
|
|
`);
|
|
assert.dom('[data-test-bar-chart]').exists('bar chart renders');
|
|
assert.dom('[data-test-bar-chart] .chart-title').hasText('Top Namespaces', 'displays title');
|
|
assert
|
|
.dom('[data-test-bar-chart] .chart-description')
|
|
.hasText('Each namespaces client count includes clients in child namespaces.', 'displays description');
|
|
assert.equal(findAll('.data-bar').length, 8, 'bars render');
|
|
});
|
|
});
|