/
rootcause-test.js
160 lines (142 loc) · 4.82 KB
/
rootcause-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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit, fillIn, click, currentURL } from '@ember/test-helpers';
import $ from 'jquery';
const PLACEHOLDER = '.rootcause-placeholder';
const TABS = '.rootcause-tabs';
const LABEL = '.rootcause-legend__label';
const SELECTED_METRIC = '.rootcause-select-metric-dimension';
const ROOTCAUSE_HEADER = 'rootcause-header';
const HEADER = `.${ROOTCAUSE_HEADER}__major`;
const LAST_SAVED = `.${ROOTCAUSE_HEADER}__last-updated-info`;
const COMMENT_TEXT = `.${ROOTCAUSE_HEADER}--textarea`;
const BASELINE = '#select-compare-mode';
const EXPAND_ANOMALY_BTN = '.rootcause-anomaly__icon a';
const ANOMALY_TITLE = '.rootcause-anomaly__title';
const ANOMALY_VALUE = '.rootcause-anomaly__props-value';
const ANOMALY_STATUS = '.ember-radio-button.checked';
const SAVE_BTN = '.te-button';
const METRICS_TABLE = '.rootcause-metrics';
const HEATMAP_DROPDOWN = '#select-heatmap-mode';
const SELECTED_HEATMAP_MODE = '.ember-power-select-selected-item';
const EVENTS_FILTER_BAR = '.filter-bar';
const EVENTS_TABLE = '.events-table';
const RCA_TOGGLE = '.rootcause-to-legacy-toggle';
module('Acceptance | rootcause', async function(hooks) {
setupApplicationTest(hooks);
test('empty state of rootcause page should have a placeholder and no tabs', async (assert) => {
await visit('/rootcause');
assert.equal(
currentURL(),
'/rootcause',
'link is correct');
assert.ok(
$(PLACEHOLDER).get(0),
'placeholder exists'
);
assert.notOk(
$(TABS).get(0),
'tabs do not exist'
);
});
test(`visiting /rootcause with only a metric provided should have correct metric name selected by default and displayed
in the legend`, async assert => {
await visit('/rootcause?metricId=1');
assert.equal(
currentURL(),
'/rootcause?metricId=1',
'link is correct');
assert.equal(
$(LABEL).get(0).innerText,
'pageViews',
'metric label is correct'
);
assert.equal(
$(SELECTED_METRIC).get(0).innerText,
'pageViews',
'selected metric is correct'
);
});
test('visiting rootcause page and making changes to the title and comment should create a session with saved changes',
async assert => {
const header = 'My Session';
const comment = 'Cause of anomaly is unknown';
await visit('/rootcause');
await fillIn(HEADER, header);
await fillIn(COMMENT_TEXT, comment);
await click(SAVE_BTN);
assert.equal(
currentURL(),
'/rootcause?sessionId=1',
'link is correct');
assert.equal(
$(HEADER).get(0).value,
'My Session',
'session name is correct');
assert.ok(
$(LAST_SAVED).get(0).innerText.includes('Last saved by rootcauseuser'),
'last saved information is correct');
assert.equal(
$(COMMENT_TEXT).get(1).value,
'Cause of anomaly is unknown',
'comments are correct');
assert.equal(
$(BASELINE).get(0).innerText,
'WoW',
'default baseline is correct');
});
test('visiting rootcause page with an anomaly should have correct anomaly information', async assert => {
await visit('/rootcause?anomalyId=1');
await click(EXPAND_ANOMALY_BTN);
assert.equal(
currentURL(),
'/rootcause?anomalyId=1',
'link is correct');
assert.equal(
$(ANOMALY_TITLE).get(0).innerText,
'Anomaly #1 anomaly_label',
'anomaly title is correct'
);
assert.equal(
$(ANOMALY_VALUE).get(0).innerText,
'pageViews',
'metric name in anomaly card is correct'
);
assert.equal(
$(ANOMALY_STATUS).get(0).innerText.trim(),
'No (False Alarm)',
'anomaly status is correct');
});
test('Metrics, Dimensions, and Events tabs exist and should have correct information', async (assert) => {
await visit('/rootcause?metricId=1');
assert.equal(
$(`${TABS} a`).get(0).innerText,
'Metrics',
'default tab is correct');
assert.ok(
$(METRICS_TABLE).get(0),
'metrics table exist');
// Click on Dimensions tab
await click($(`${TABS} a`).get(1));
assert.ok(
$(HEATMAP_DROPDOWN).get(0),
'heatmap dropdown exists');
assert.equal(
$(SELECTED_HEATMAP_MODE).get(4).innerText,
'Change in Contribution',
'default heatmap mode is correct');
// Click on Events tab
await click($(`${TABS} a`).get(2));
assert.ok(
$(EVENTS_FILTER_BAR).get(0),
'filter bar exists in events tab');
assert.ok(
$(EVENTS_TABLE).get(0),
'events table exists in events tab');
});
test('links to legacy rca should work', async (assert) => {
await visit('/rootcause');
await click(RCA_TOGGLE);
assert.ok(currentURL().includes('rca'), currentURL());
});
});