mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 03:57:01 +02:00
* Add http request volume table (#6765) * init http metrics page * remove flex-table-column * add http requests table * calculate percent change between each counter * start percent change tests * style request table * show percent more/less glyph * add percent more less tests * add inline alert about recorded metrics * make arrows diagonal * remove conditional inside countersWithChange * add better error msg * use tagName and wrapping element a la glimmer components * extend ClusterRouteBase so auth and seal checks happen * make table accessible * remove curlies * add HttpRequestsTable to storybook * make table accessible * use qunit dom for better assertions * remove EmptyState since we will never have 0 requests * ensure counters is set in test context * Http request volume/add barchart (#6814) * Add http request volume table (#6765) * init http metrics page * remove flex-table-column * add http requests table * calculate percent change between each counter * start percent change tests * style request table * show percent more/less glyph * add percent more less tests * add inline alert about recorded metrics * make arrows diagonal * remove conditional inside countersWithChange * add better error msg * use tagName and wrapping element a la glimmer components * extend ClusterRouteBase so auth and seal checks happen * make table accessible * remove curlies * add HttpRequestsTable to storybook * make table accessible * use qunit dom for better assertions * remove EmptyState since we will never have 0 requests * ensure counters is set in test context * add http-requests-bar-chart * add HttpRequestsBarChart tests * add HttpRequestsBarChart to Storybook * format total number of requests according to locale * do not show extra minus sign when percent change is negative * add link to request metrics in status bar menu * only show bar chart if we have data for more than 1 month * make ticks lighter * ensure charts show data for correct month * make example counters response look like the adapter response instead of the raw api response * ensure ui shows the same utc date as the api response * add format-utc tests * downgrade to d3 v4 to support ie11 * add gridlines * move dasharray to css * use scheduleOnce instead of debounce to prevent multiple re-renders * add key function to bars * add exit case when data is no longer in parsedCounters * fix timestamp in table test * fix timestamps * use utcParse and fallback to isoParse for non-UTC dates * fix bar chart tests
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
const COUNTERS = [
|
|
{ start_time: '2019-04-01T00:00:00Z', total: 5500 },
|
|
{ start_time: '2019-05-01T00:00:00Z', total: 4500 },
|
|
{ start_time: '2019-06-01T00:00:00Z', total: 5000 },
|
|
];
|
|
|
|
module('Integration | Component | http-requests-table', function(hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function() {
|
|
this.set('counters', COUNTERS);
|
|
});
|
|
|
|
test('it renders', async function(assert) {
|
|
await render(hbs`<HttpRequestsTable @counters={{counters}}/>`);
|
|
|
|
assert.dom('.http-requests-table').exists();
|
|
});
|
|
|
|
test('it does not show Change column with less than one month of data', async function(assert) {
|
|
const one_month_counter = [
|
|
{
|
|
start_time: '2019-05-01T00:00:00Z',
|
|
total: 50,
|
|
},
|
|
];
|
|
this.set('one_month_counter', one_month_counter);
|
|
|
|
await render(hbs`<HttpRequestsTable @counters={{one_month_counter}}/>`);
|
|
|
|
assert.dom('.http-requests-table').exists();
|
|
assert.dom('[data-test-change]').doesNotExist();
|
|
});
|
|
|
|
test('it shows Change column for more than one month of data', async function(assert) {
|
|
await render(hbs`<HttpRequestsTable @counters={{counters}}/>`);
|
|
|
|
assert.dom('[data-test-change]').exists();
|
|
});
|
|
|
|
test('it shows the percent change between each time window', async function(assert) {
|
|
await render(hbs`<HttpRequestsTable @counters={{counters}}/>`);
|
|
const expected = Math.abs(
|
|
(((COUNTERS[1].total - COUNTERS[0].total) / COUNTERS[1].total) * 100).toFixed(1)
|
|
);
|
|
|
|
assert.ok(this.element.textContent.includes(expected));
|
|
});
|
|
});
|