mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-19 13:41:10 +02:00
* cleanup namespaceArrayToObject method * WIP typescript conversion * WIP typescripted destructured block * slowly making progress.... * WIP move all types to util type file, separate returns in formatByMonths * namespaceArrayToObject is working?!? * fix mirage handler not generating months when queries are after upgrade * wow, the types are actually working omg * add comments and update client-count-utils test * delete old js file * remove types from activity model * remove comment * reuse totalclients type to minimize places we add types * commit file with type changes for git diff * delete util file again * address PR feedback and move type declarations to util file * remove unused types * update tests, use client helper in dashboard clients test * remove typo * make modifications with updated combined activity response from the backend
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'vault/tests/helpers';
|
|
import { render, click } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import sinon from 'sinon';
|
|
import { LICENSE_START, STATIC_NOW } from 'vault/mirage/handlers/clients';
|
|
import timestamp from 'core/utils/timestamp';
|
|
import { ACTIVITY_RESPONSE_STUB } from 'vault/tests/helpers/clients';
|
|
|
|
module('Integration | Component | dashboard/client-count-card', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.before(function () {
|
|
sinon.stub(timestamp, 'now').callsFake(() => STATIC_NOW);
|
|
});
|
|
|
|
hooks.beforeEach(function () {
|
|
this.license = {
|
|
startTime: LICENSE_START.toISOString(),
|
|
};
|
|
});
|
|
|
|
hooks.after(function () {
|
|
timestamp.now.restore();
|
|
});
|
|
|
|
test('it should display client count information', async function (assert) {
|
|
assert.expect(9);
|
|
this.server.get('sys/internal/counters/activity', () => {
|
|
// this assertion should be hit twice, once initially and then again clicking 'refresh'
|
|
assert.true(true, 'makes request to sys/internal/counters/activity');
|
|
return {
|
|
request_id: 'some-activity-id',
|
|
data: ACTIVITY_RESPONSE_STUB,
|
|
};
|
|
});
|
|
|
|
await render(hbs`<Dashboard::ClientCountCard @license={{this.license}} />`);
|
|
assert.dom('[data-test-client-count-title]').hasText('Client count');
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-label').hasText('Total');
|
|
assert
|
|
.dom('[data-test-stat-text="total-clients"] .stat-text')
|
|
.hasText('The number of clients in this billing period (Jul 2023 - Jan 2024).');
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('7,805');
|
|
assert.dom('[data-test-stat-text="new-clients"] .stat-label').hasText('New');
|
|
assert
|
|
.dom('[data-test-stat-text="new-clients"] .stat-text')
|
|
.hasText('The number of clients new to Vault in the current month.');
|
|
assert.dom('[data-test-stat-text="new-clients"] .stat-value').hasText('336');
|
|
|
|
// fires second request to /activity
|
|
await click('[data-test-refresh]');
|
|
});
|
|
});
|