2022-02-24 20:04:40 +00:00
|
|
|
import { module, test } from 'qunit';
|
2022-05-12 21:06:48 +00:00
|
|
|
import { visit, currentURL, settled, click } from '@ember/test-helpers';
|
2022-02-24 20:04:40 +00:00
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2022-06-01 18:42:05 +00:00
|
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
import ENV from 'vault/config/environment';
|
2022-02-24 20:04:40 +00:00
|
|
|
import authPage from 'vault/tests/pages/auth';
|
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
import { clickTrigger } from 'ember-power-select/test-support/helpers';
|
|
|
|
import ss from 'vault/tests/pages/components/search-select';
|
2022-06-01 18:42:05 +00:00
|
|
|
import { overrideResponse, SELECTORS } from '../helpers/clients';
|
2022-02-24 20:04:40 +00:00
|
|
|
|
|
|
|
const searchSelect = create(ss);
|
|
|
|
|
2022-06-01 18:42:05 +00:00
|
|
|
module('Acceptance | clients current tab', function (hooks) {
|
2022-02-24 20:04:40 +00:00
|
|
|
setupApplicationTest(hooks);
|
2022-06-01 18:42:05 +00:00
|
|
|
setupMirage(hooks);
|
2022-02-24 20:04:40 +00:00
|
|
|
|
2022-06-01 18:42:05 +00:00
|
|
|
hooks.before(function () {
|
|
|
|
ENV['ember-cli-mirage'].handler = 'clients';
|
|
|
|
});
|
|
|
|
|
|
|
|
hooks.after(function () {
|
|
|
|
ENV['ember-cli-mirage'].handler = null;
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|
|
|
|
|
2022-06-01 18:42:05 +00:00
|
|
|
hooks.beforeEach(function () {
|
|
|
|
return authPage.login();
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('shows empty state when config disabled, no data', async function (assert) {
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.expect(3);
|
|
|
|
this.server.get('sys/internal/counters/config', () => {
|
|
|
|
return {
|
|
|
|
request_id: 'some-config-id',
|
|
|
|
data: {
|
|
|
|
default_report_months: 12,
|
|
|
|
enabled: 'default-disable',
|
|
|
|
retention_months: 24,
|
|
|
|
},
|
|
|
|
};
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|
2022-06-01 18:42:05 +00:00
|
|
|
this.server.get('sys/internal/counters/activity/monthly', () => overrideResponse(204));
|
2022-02-24 20:04:40 +00:00
|
|
|
await visit('/vault/clients/current');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(currentURL(), '/vault/clients/current');
|
2022-03-17 00:36:48 +00:00
|
|
|
assert.dom(SELECTORS.currentMonthActiveTab).hasText('Current month', 'current month tab is active');
|
2022-02-24 20:04:40 +00:00
|
|
|
assert.dom(SELECTORS.emptyStateTitle).hasText('Tracking is disabled');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('shows empty state when config enabled, no data', async function (assert) {
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.expect(3);
|
|
|
|
this.server.get('sys/internal/counters/activity/monthly', () => {
|
|
|
|
return {
|
|
|
|
request_id: 'some-monthly-id',
|
|
|
|
data: {
|
|
|
|
by_namespace: [],
|
|
|
|
clients: 0,
|
|
|
|
distinct_entities: 0,
|
|
|
|
entity_clients: 0,
|
|
|
|
months: [],
|
|
|
|
non_entity_clients: 0,
|
|
|
|
non_entity_tokens: 0,
|
|
|
|
},
|
|
|
|
};
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|
|
|
|
await visit('/vault/clients/current');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(currentURL(), '/vault/clients/current');
|
2022-03-17 00:36:48 +00:00
|
|
|
assert.dom(SELECTORS.currentMonthActiveTab).hasText('Current month', 'current month tab is active');
|
2022-02-24 20:04:40 +00:00
|
|
|
assert.dom(SELECTORS.emptyStateTitle).hasText('No data received');
|
|
|
|
});
|
2022-06-01 18:42:05 +00:00
|
|
|
|
|
|
|
test('filters correctly on current with full data', async function (assert) {
|
|
|
|
assert.expect(27);
|
|
|
|
await visit('/vault/clients/current');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(currentURL(), '/vault/clients/current');
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.dom(SELECTORS.currentMonthActiveTab).hasText('Current month', 'current month tab is active');
|
|
|
|
assert.dom(SELECTORS.usageStats).exists('usage stats block exists');
|
|
|
|
assert.dom('[data-test-stat-text-container]').exists({ count: 3 }, '3 stat texts exist');
|
|
|
|
|
|
|
|
// TODO update with dynamic counts
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('175');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('132');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('43');
|
|
|
|
assert.dom('[data-test-clients-attribution]').exists('Shows attribution area');
|
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
|
|
|
await settled();
|
|
|
|
|
|
|
|
// FILTER BY NAMESPACE
|
|
|
|
await clickTrigger();
|
|
|
|
await searchSelect.options.objectAt(0).click();
|
|
|
|
await settled();
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('100');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('85');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('15');
|
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
|
|
|
await settled();
|
|
|
|
|
|
|
|
// FILTER BY AUTH METHOD
|
|
|
|
await clickTrigger();
|
|
|
|
await searchSelect.options.objectAt(0).click();
|
|
|
|
await settled();
|
|
|
|
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('35');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('20');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('15');
|
|
|
|
assert.dom(SELECTORS.attributionBlock).doesNotExist('Does not show attribution block');
|
|
|
|
|
|
|
|
// Delete auth filter goes back to filtered only on namespace
|
|
|
|
await click('#auth-method-search-select [data-test-selected-list-button="delete"]');
|
|
|
|
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('100');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('85');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('15');
|
|
|
|
await settled();
|
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
|
|
|
assert.dom(SELECTORS.attributionBlock).exists('Still shows attribution block');
|
|
|
|
await clickTrigger();
|
|
|
|
await searchSelect.options.objectAt(0).click();
|
|
|
|
await settled();
|
|
|
|
// Delete namespace filter with auth filter on
|
|
|
|
await click('#namespace-search-select-monthly [data-test-selected-list-button="delete"]');
|
|
|
|
// Goes back to no filters
|
|
|
|
// TODO update with dynamic counts
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('175');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('132');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('43');
|
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
|
|
|
assert.dom('[data-test-chart-container="new-clients"] [data-test-empty-state-subtext]').doesNotExist();
|
|
|
|
});
|
2022-02-24 20:04:40 +00:00
|
|
|
|
|
|
|
test('filters correctly on current with no auth mounts', async function (assert) {
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.expect(16);
|
2022-02-24 20:04:40 +00:00
|
|
|
await visit('/vault/clients/current');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(currentURL(), '/vault/clients/current');
|
2022-03-17 00:36:48 +00:00
|
|
|
assert.dom(SELECTORS.currentMonthActiveTab).hasText('Current month', 'current month tab is active');
|
2022-02-24 20:04:40 +00:00
|
|
|
assert.dom(SELECTORS.usageStats).exists('usage stats block exists');
|
|
|
|
assert.dom('[data-test-stat-text-container]').exists({ count: 3 }, '3 stat texts exist');
|
2022-06-01 18:42:05 +00:00
|
|
|
// TODO CMB update with dynamic data
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('175');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('132');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('43');
|
2022-02-24 20:04:40 +00:00
|
|
|
assert.dom('[data-test-clients-attribution]').exists('Shows attribution area');
|
2022-05-03 01:37:09 +00:00
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
2022-04-15 19:06:10 +00:00
|
|
|
|
2022-02-24 20:04:40 +00:00
|
|
|
// Filter by namespace
|
|
|
|
await clickTrigger();
|
|
|
|
await searchSelect.options.objectAt(0).click();
|
|
|
|
await settled();
|
2022-06-01 18:42:05 +00:00
|
|
|
|
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('100');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('85');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('15');
|
|
|
|
|
|
|
|
// TODO add month data without mounts
|
|
|
|
// assert.dom(SELECTORS.attributionBlock).doesNotExist('Does not show attribution');
|
|
|
|
// assert.dom('#auth-method-search-select').doesNotExist('Auth method filter is not shown');
|
|
|
|
|
2022-02-24 20:04:40 +00:00
|
|
|
// Remove namespace filter
|
|
|
|
await click('#namespace-search-select-monthly [data-test-selected-list-button="delete"]');
|
2022-06-01 18:42:05 +00:00
|
|
|
|
2022-02-24 20:04:40 +00:00
|
|
|
// Goes back to no filters
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('175');
|
|
|
|
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('132');
|
|
|
|
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('43');
|
2022-05-03 01:37:09 +00:00
|
|
|
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|
2022-03-02 18:44:41 +00:00
|
|
|
|
|
|
|
test('shows correct empty state when config off but no read on config', async function (assert) {
|
2022-06-01 18:42:05 +00:00
|
|
|
assert.expect(2);
|
|
|
|
this.server.get('sys/internal/counters/activity/monthly', () => overrideResponse(204));
|
|
|
|
this.server.get('sys/internal/counters/config', () => overrideResponse(403));
|
2022-03-02 18:44:41 +00:00
|
|
|
await visit('/vault/clients/current');
|
|
|
|
assert.dom(SELECTORS.filterBar).doesNotExist('Filter bar is not shown');
|
|
|
|
assert.dom(SELECTORS.emptyStateTitle).containsText('No data available', 'Shows no data empty state');
|
|
|
|
});
|
2022-02-24 20:04:40 +00:00
|
|
|
});
|