open-vault/ui/tests/acceptance/client-current-test.js

176 lines
8.1 KiB
JavaScript
Raw Normal View History

2022-02-24 20:04:40 +00:00
import { module, test } from 'qunit';
import { visit, currentURL, settled, click } from '@ember/test-helpers';
2022-02-24 20:04:40 +00:00
import { setupApplicationTest } from 'ember-qunit';
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';
import { overrideResponse, SELECTORS } from '../helpers/clients';
2022-02-24 20:04:40 +00:00
const searchSelect = create(ss);
module('Acceptance | clients current tab', function (hooks) {
2022-02-24 20:04:40 +00:00
setupApplicationTest(hooks);
setupMirage(hooks);
2022-02-24 20:04:40 +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
});
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) {
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
});
this.server.get('sys/internal/counters/activity/monthly', () => overrideResponse(204));
2022-02-24 20:04:40 +00:00
await visit('/vault/clients/current');
Ember Upgrade to 4.4 (#17086) * runs ember-cli-update to 4.4.0 * updates yarn.lock * updates dependencies causing runtime errors (#17135) * Inject Store Service When Accessed Implicitly (#17345) * adds codemod for injecting store service * adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms * updates inject-store-service codemod to only look for .extend object expressions and adds recast options * runs inject-store-service codemod on js files * replace query-params helper with hash (#17404) * Updates/removes dependencies throwing errors in Ember 4.4 (#17396) * updates ember-responsive to latest * updates ember-composable-helpers to latest and uses includes helper since contains was removed * updates ember-concurrency to latest * updates ember-cli-clipboard to latest * temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo * adds missing store injection to auth configure route * fixes issue with string-list component throwing error for accessing prop in same computation * fixes non-iterable query params issue in mfa methods controller * refactors field-to-attrs to handle belongsTo rather than fragments * converts mount-config fragment to belongsTo on auth-method model * removes ember-api-actions and adds tune method to auth-method adapter * converts cluster replication attributes from fragment to relationship * updates ember-data, removes ember-data-fragments and updates yarn to latest * removes fragments from secret-engine model * removes fragment from test-form-model * removes commented out code * minor change to inject-store-service codemod and runs again on js files * Remove LinkTo positional params (#17421) * updates ember-cli-page-object to latest version * update toolbar-link to support link-to args and not positional params * adds replace arg to toolbar-link component * Clean up js lint errors (#17426) * replaces assert.equal to assert.strictEqual * update eslint no-console to error and disables invididual intended uses of console * cleans up hbs lint warnings (#17432) * Upgrade bug and test fixes (#17500) * updates inject-service codemod to take arg for service name and runs for flashMessages service * fixes hbs lint error after merging main * fixes flash messages * updates more deps * bug fixes * test fixes * updates ember-cli-content-security-policy and prevents default form submission throwing errors * more bug and test fixes * removes commented out code * fixes issue with code-mirror modifier sending change event on setup causing same computation error * Upgrade Clean Up (#17543) * updates deprecation workflow and filter * cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest * fixes control groups test that was skipped after upgrade * updates control group service tests * addresses review feedback * updates control group service handleError method to use router.currentURL rather that transition.intent.url * adds changelog entry
2022-10-18 15:46:02 +00:00
assert.strictEqual(currentURL(), '/vault/clients/current');
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) {
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');
Ember Upgrade to 4.4 (#17086) * runs ember-cli-update to 4.4.0 * updates yarn.lock * updates dependencies causing runtime errors (#17135) * Inject Store Service When Accessed Implicitly (#17345) * adds codemod for injecting store service * adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms * updates inject-store-service codemod to only look for .extend object expressions and adds recast options * runs inject-store-service codemod on js files * replace query-params helper with hash (#17404) * Updates/removes dependencies throwing errors in Ember 4.4 (#17396) * updates ember-responsive to latest * updates ember-composable-helpers to latest and uses includes helper since contains was removed * updates ember-concurrency to latest * updates ember-cli-clipboard to latest * temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo * adds missing store injection to auth configure route * fixes issue with string-list component throwing error for accessing prop in same computation * fixes non-iterable query params issue in mfa methods controller * refactors field-to-attrs to handle belongsTo rather than fragments * converts mount-config fragment to belongsTo on auth-method model * removes ember-api-actions and adds tune method to auth-method adapter * converts cluster replication attributes from fragment to relationship * updates ember-data, removes ember-data-fragments and updates yarn to latest * removes fragments from secret-engine model * removes fragment from test-form-model * removes commented out code * minor change to inject-store-service codemod and runs again on js files * Remove LinkTo positional params (#17421) * updates ember-cli-page-object to latest version * update toolbar-link to support link-to args and not positional params * adds replace arg to toolbar-link component * Clean up js lint errors (#17426) * replaces assert.equal to assert.strictEqual * update eslint no-console to error and disables invididual intended uses of console * cleans up hbs lint warnings (#17432) * Upgrade bug and test fixes (#17500) * updates inject-service codemod to take arg for service name and runs for flashMessages service * fixes hbs lint error after merging main * fixes flash messages * updates more deps * bug fixes * test fixes * updates ember-cli-content-security-policy and prevents default form submission throwing errors * more bug and test fixes * removes commented out code * fixes issue with code-mirror modifier sending change event on setup causing same computation error * Upgrade Clean Up (#17543) * updates deprecation workflow and filter * cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest * fixes control groups test that was skipped after upgrade * updates control group service tests * addresses review feedback * updates control group service handleError method to use router.currentURL rather that transition.intent.url * adds changelog entry
2022-10-18 15:46:02 +00:00
assert.strictEqual(currentURL(), '/vault/clients/current');
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');
});
test('filters correctly on current with full data', async function (assert) {
assert.expect(27);
await visit('/vault/clients/current');
Ember Upgrade to 4.4 (#17086) * runs ember-cli-update to 4.4.0 * updates yarn.lock * updates dependencies causing runtime errors (#17135) * Inject Store Service When Accessed Implicitly (#17345) * adds codemod for injecting store service * adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms * updates inject-store-service codemod to only look for .extend object expressions and adds recast options * runs inject-store-service codemod on js files * replace query-params helper with hash (#17404) * Updates/removes dependencies throwing errors in Ember 4.4 (#17396) * updates ember-responsive to latest * updates ember-composable-helpers to latest and uses includes helper since contains was removed * updates ember-concurrency to latest * updates ember-cli-clipboard to latest * temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo * adds missing store injection to auth configure route * fixes issue with string-list component throwing error for accessing prop in same computation * fixes non-iterable query params issue in mfa methods controller * refactors field-to-attrs to handle belongsTo rather than fragments * converts mount-config fragment to belongsTo on auth-method model * removes ember-api-actions and adds tune method to auth-method adapter * converts cluster replication attributes from fragment to relationship * updates ember-data, removes ember-data-fragments and updates yarn to latest * removes fragments from secret-engine model * removes fragment from test-form-model * removes commented out code * minor change to inject-store-service codemod and runs again on js files * Remove LinkTo positional params (#17421) * updates ember-cli-page-object to latest version * update toolbar-link to support link-to args and not positional params * adds replace arg to toolbar-link component * Clean up js lint errors (#17426) * replaces assert.equal to assert.strictEqual * update eslint no-console to error and disables invididual intended uses of console * cleans up hbs lint warnings (#17432) * Upgrade bug and test fixes (#17500) * updates inject-service codemod to take arg for service name and runs for flashMessages service * fixes hbs lint error after merging main * fixes flash messages * updates more deps * bug fixes * test fixes * updates ember-cli-content-security-policy and prevents default form submission throwing errors * more bug and test fixes * removes commented out code * fixes issue with code-mirror modifier sending change event on setup causing same computation error * Upgrade Clean Up (#17543) * updates deprecation workflow and filter * cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest * fixes control groups test that was skipped after upgrade * updates control group service tests * addresses review feedback * updates control group service handleError method to use router.currentURL rather that transition.intent.url * adds changelog entry
2022-10-18 15:46:02 +00:00
assert.strictEqual(currentURL(), '/vault/clients/current');
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) {
assert.expect(16);
2022-02-24 20:04:40 +00:00
await visit('/vault/clients/current');
Ember Upgrade to 4.4 (#17086) * runs ember-cli-update to 4.4.0 * updates yarn.lock * updates dependencies causing runtime errors (#17135) * Inject Store Service When Accessed Implicitly (#17345) * adds codemod for injecting store service * adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms * updates inject-store-service codemod to only look for .extend object expressions and adds recast options * runs inject-store-service codemod on js files * replace query-params helper with hash (#17404) * Updates/removes dependencies throwing errors in Ember 4.4 (#17396) * updates ember-responsive to latest * updates ember-composable-helpers to latest and uses includes helper since contains was removed * updates ember-concurrency to latest * updates ember-cli-clipboard to latest * temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo * adds missing store injection to auth configure route * fixes issue with string-list component throwing error for accessing prop in same computation * fixes non-iterable query params issue in mfa methods controller * refactors field-to-attrs to handle belongsTo rather than fragments * converts mount-config fragment to belongsTo on auth-method model * removes ember-api-actions and adds tune method to auth-method adapter * converts cluster replication attributes from fragment to relationship * updates ember-data, removes ember-data-fragments and updates yarn to latest * removes fragments from secret-engine model * removes fragment from test-form-model * removes commented out code * minor change to inject-store-service codemod and runs again on js files * Remove LinkTo positional params (#17421) * updates ember-cli-page-object to latest version * update toolbar-link to support link-to args and not positional params * adds replace arg to toolbar-link component * Clean up js lint errors (#17426) * replaces assert.equal to assert.strictEqual * update eslint no-console to error and disables invididual intended uses of console * cleans up hbs lint warnings (#17432) * Upgrade bug and test fixes (#17500) * updates inject-service codemod to take arg for service name and runs for flashMessages service * fixes hbs lint error after merging main * fixes flash messages * updates more deps * bug fixes * test fixes * updates ember-cli-content-security-policy and prevents default form submission throwing errors * more bug and test fixes * removes commented out code * fixes issue with code-mirror modifier sending change event on setup causing same computation error * Upgrade Clean Up (#17543) * updates deprecation workflow and filter * cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest * fixes control groups test that was skipped after upgrade * updates control group service tests * addresses review feedback * updates control group service handleError method to use router.currentURL rather that transition.intent.url * adds changelog entry
2022-10-18 15:46:02 +00:00
assert.strictEqual(currentURL(), '/vault/clients/current');
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');
// 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');
assert.dom('[data-test-chart-container="new-clients"]').doesNotExist();
2022-02-24 20:04:40 +00:00
// 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');
// 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-02-24 20:04:40 +00:00
// Goes back to no filters
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();
2022-02-24 20:04:40 +00:00
});
test('shows correct empty state when config off but no read on config', async function (assert) {
assert.expect(2);
this.server.get('sys/internal/counters/activity/monthly', () => overrideResponse(204));
this.server.get('sys/internal/counters/config', () => overrideResponse(403));
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
});