Vault Automation 5d869440c3
[UI] Ember Data Migration - Client Counts (#12026) (#12132)
* updates flags service to use api service

* converts clients index route to ts

* updates clients config workflows to use api service

* updates clients date-range component to handle Date objects rather than ISO strings

* updates clients page-header component to handle Date objects and use api and capabilities services

* updates clients route to use api and capabilities services

* updates types in client-counts helpers

* updates client counts route to use api service

* updates types for client-counts serializers

* updates date handling in client counts page component

* updates clients overview page component

* converts clients page-header component to ts

* fixes type errors in clients page-header component

* updates client counts tests

* updates client-count-card component to use api service

* converts client-count-card component to ts

* removes model-form-fields test that uses clients/config model

* removes clients/version-history model usage from client-counts helpers tests

* removes migrated models from adapter and model registries

* removes clients ember data models, adapters and serializers

* updates clients date-range component to format dates in time zone

* cleans up references to activityError in client counts route

* adds clients/activity mirage model

* updates activation flags assertions in sync overview tests

* fixes issue selecting current period in clients date-range component and adds test

* fixes issues with enabled state for client counts

* updates parseAPITimestamp to handle date object formatting

* removes unnecesarry type casting for format return in parseAPITimestamp util

* updates parseAPITimestamp to use formatInTimeZone for strings

* updates parseAPITimestamp comment

* updates enabled value in clients config component to boolean

* adds date-fns-tz to core addon

* removes parseISO from date-formatters util in favor of new Date

* updates comments for client counts

* updates retention months validation for client counts config

* updates comment and min retention months default for client counts config

Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
2026-02-03 16:18:52 +00:00

79 lines
3.0 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs';
module('Integration | Component | clients/no-data', function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
hooks.beforeEach(async function () {
this.server.post('/sys/capabilities-self', allowAllCapabilitiesStub());
this.canUpdate = false;
this.setConfig = (enabled, reporting_enabled) => ({
enabled: enabled ? 'default-enabled' : 'default-disabled',
reporting_enabled,
});
this.renderComponent = async () => {
return render(hbs`<Clients::NoData @config={{this.config}} @canUpdate={{this.canUpdate}} />`);
};
});
test('it renders empty state when enabled', async function (assert) {
assert.expect(2);
this.config = this.setConfig(true, false);
await this.renderComponent();
assert.dom(GENERAL.emptyStateTitle).hasText('No data received');
assert
.dom(GENERAL.emptyStateMessage)
.hasText('Tracking is turned on and Vault is gathering data. It should appear here within 30 minutes.');
});
test('it renders empty state when reporting is fully enabled', async function (assert) {
assert.expect(2);
this.config = this.setConfig(true, true);
await this.renderComponent();
assert.dom(GENERAL.emptyStateTitle).hasText('No data received');
assert
.dom(GENERAL.emptyStateMessage)
.hasText('Tracking is turned on and Vault is gathering data. It should appear here within 30 minutes.');
});
test('it renders empty state when reporting is fully disabled', async function (assert) {
assert.expect(4);
this.config = this.setConfig(false, false);
await this.renderComponent();
assert.dom(GENERAL.emptyStateTitle).hasText('Data tracking is disabled');
assert
.dom(GENERAL.emptyStateMessage)
.hasText(
'Tracking is disabled, and no data is being collected. To turn it on, edit the configuration.'
);
assert.dom(GENERAL.linkTo('config')).doesNotExist('Config link does not render without capabilities');
this.canUpdate = true;
await this.renderComponent();
assert.dom(GENERAL.linkTo('config')).exists('Config link renders with update capabilities');
});
test('it renders empty state when config data is not available', async function (assert) {
assert.expect(2);
this.config = null;
await this.renderComponent();
assert.dom(GENERAL.emptyStateTitle).hasText('Activity configuration data is unavailable');
assert
.dom(GENERAL.emptyStateMessage)
.hasText(
'Reporting status is unknown and could be enabled or disabled. Check the Vault logs for more information.'
);
});
});