-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
clients-history-test.js
89 lines (79 loc) · 3.73 KB
/
clients-history-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { module, test } from 'qunit';
import EmberObject from '@ember/object';
import { render } from '@ember/test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | client count history', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function() {
let model = EmberObject.create({
config: {},
activity: {},
});
this.model = model;
this.tab = 'history';
});
test('it shows empty state when disabled and no data available', async function(assert) {
Object.assign(this.model.config, { enabled: 'Off', queriesAvailable: false });
await render(hbs`<Clients::History @tab={{tab}} @model={{model}} />`);
assert.dom('[data-test-component="empty-state"]').exists('Empty state exists');
assert.dom('[data-test-empty-state-title]').hasText('Data tracking is disabled');
});
test('it shows empty state when enabled and no data available', async function(assert) {
Object.assign(this.model.config, { enabled: 'On', queriesAvailable: false });
await render(hbs`<Clients::History @tab={{tab}} @model={{model}} />`);
assert.dom('[data-test-component="empty-state"]').exists('Empty state exists');
assert.dom('[data-test-empty-state-title]').hasText('No monthly history');
});
test('it shows empty state when data available but not returned', async function(assert) {
Object.assign(this.model.config, { queriesAvailable: true });
await render(hbs`<Clients::History @tab={{tab}} @model={{model}} />`);
assert.dom('[data-test-pricing-metrics-form]').exists('Date range form component exists');
assert.dom('[data-test-pricing-result-dates]').doesNotExist('Date range form result dates are not shown');
assert.dom('[data-test-component="empty-state"]').exists('Empty state exists');
assert.dom('[data-test-empty-state-title]').hasText('No data received');
});
test('it shows warning when disabled and data available', async function(assert) {
Object.assign(this.model.config, { queriesAvailable: true, enabled: 'Off' });
await render(hbs`<Clients::History @tab={{tab}} @model={{model}} />`);
assert.dom('[data-test-pricing-metrics-form]').exists('Date range form component exists');
assert.dom('[data-test-tracking-disabled]').exists('Flash message exists');
assert.dom('[data-test-tracking-disabled] .message-title').hasText('Tracking is disabled');
});
test('it shows data when available from query', async function(assert) {
Object.assign(this.model.config, { queriesAvailable: true, configPath: { canRead: true } });
Object.assign(this.model.activity, {
byNamespace: [
{
counts: {
clients: 2725,
distinct_entities: 1137,
non_entity_tokens: 1588,
},
namespace_id: '8VIZc',
namespace_path: 'nsTest5/',
},
{
counts: {
clients: 200,
distinct_entities: 100,
non_entity_tokens: 100,
},
namespace_id: 'sd3Zc',
namespace_path: 'nsTest1/',
},
],
total: {
clients: 1234,
distinct_entities: 234,
non_entity_tokens: 232,
},
});
await render(hbs`<Clients::History @tab={{tab}} @model={{model}} />`);
assert.dom('[data-test-pricing-metrics-form]').exists('Date range form component exists');
assert.dom('[data-test-tracking-disabled]').doesNotExist('Flash message does not exists');
assert.dom('[data-test-client-count-stats]').exists('Client count data exists');
assert.dom('[data-test-client-count-graph]').exists('Top 10 namespaces chart exists');
assert.dom('[data-test-empty-state-title]').hasText('No namespace selected');
});
});