Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ViewDataTable_spec.js « specs « UI « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3270a768cd41310ff764fc99c4a39adbe3a7153f (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*!
 * Piwik - free/libre analytics platform
 *
 * ViewDataTable screenshot tests.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

describe("ViewDataTableTest", function () { // TODO: should remove Test suffix from images instead of naming suites ...Test
    // TODO: rename screenshot files, remove numbers
    var url = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
            + "actionToWidgetize=getKeywords&viewDataTable=table&filter_limit=5&isFooterExpandedInDashboard=1";

    it("should load correctly", async function () {
        await page.goto(url);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('0_initial');
    });

    it("should load all columns when all columns clicked", async function () {
        await page.click('.activateVisualizationSelection');
        await page.click('.tableIcon[data-footer-icon-id=tableAllColumns]');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('1_all_columns');
    });

    it("should sort a column in descending order when column clicked initially", async function () {
        await page.click('th#avg_time_on_site');
        await page.mouse.move(-10, -10);
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('2_column_sorted_desc');
    });

    it("should sort a column in ascending order when column clicked second time", async function () {
        await page.click('th#avg_time_on_site');
        await page.mouse.move(-10, -10);
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('3_column_sorted_asc');
    });

    it("should show all available visualizations for this report", async function () {
        await page.click('.activateVisualizationSelection');

        const element = await page.$('.dataTableFooterIcons');
        expect(await element.screenshot()).to.matchImage('5_visualizations');
    });

    it("should load goals table when goals footer icon clicked", async function () {
        await page.click('.tableIcon[data-footer-icon-id=tableGoals]');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('5_goals');
    });

    it("should load bar graph when bar graph footer icon clicked", async function () {
        await page.click('.activateVisualizationSelection');
        await page.click('.tableIcon[data-footer-icon-id=graphVerticalBar]');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('6_bar_graph');
    });

    it("should load pie graph when pie graph footer icon clicked", async function () {
        await page.click('.activateVisualizationSelection');
        await page.click('.tableIcon[data-footer-icon-id=graphPie]');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('7_pie_graph');
    });

    it("should load a tag cloud when tag cloud footer icon clicked", async function () {
        await page.click('.activateVisualizationSelection');
        await page.click('.tableIcon[data-footer-icon-id=cloud]');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('8_tag_cloud');
    });

    it("should load normal table when normal table footer icon clicked", async function () {
        await page.click('.activateVisualizationSelection');
        await page.click('.tableIcon[data-footer-icon-id=table]');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10); // mae sure no row is highlighted
        expect(await page.screenshot({ fullPage: true })).to.matchImage('9_normal_table');
    });

    it("should show the limit selector when the limit selector is clicked", async function () {
        await page.click('.limitSelection input');
        await page.waitFor(200);
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('limit_selector_open');
    });

    it("should change the number of rows when new limit selected", async function () {
        await page.evaluate(function () {
            $('.limitSelection ul li:contains(10):first span').click();
        });
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('10_change_limit');
    });

    it("should flatten the table when the flatten link is clicked", async function () {
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableFlatten');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('11_flattened');
    });

    it("should show dimensions separately when option is clicked", async function () {
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableShowDimensions');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('dimension_columns');
    });

    it("should search in subtable dimensions even when they are displayed separately", async function () {
        await page.click('.dataTableAction.searchAction');
        await page.focus('.searchAction .dataTableSearchInput');
        await page.keyboard.type('Bing');
        await page.click('.searchAction .icon-search');
        await page.waitForNetworkIdle();
        await page.evaluate(() => document.activeElement.blur());
        await page.waitFor(500);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('dimension_search');
    });

    it("search should still work when showing dimensions combined again", async function () {
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableShowDimensions');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('flatten_search');
    });

    it("search should still work when switching to back to separate dimensions", async function () {
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableShowDimensions');
        await page.waitForNetworkIdle();
        await page.waitFor(500);
        await page.mouse.move(-10, -10);
        await page.evaluate(() => document.activeElement.blur());
        expect(await page.screenshot({ fullPage: true })).to.matchImage('dimension_search');
    });

    it("should show aggregate rows when the aggregate rows option is clicked", async function () {
        await page.goto(url.replace(/filter_limit=5/, 'filter_limit=10') + '&flat=1');
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableIncludeAggregateRows');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('12_aggregate_shown');
    });

    it("should make the report hierarchical when the flatten link is clicked again", async function () {
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableFlatten');
        await page.waitForNetworkIdle();
        await page.mouse.move(-10, -10);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('13_make_hierarchical');
    });

    it("should show the visits percent when hovering over a column", async function () {
        await page.hover('td.column:not(.label)');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('14_visits_percent');
    });

    it("should load subtables correctly when row clicked", async function () {
        (await page.$$('tr.subDataTable'))[0].click();
        await page.waitForNetworkIdle();

        (await page.$$('tr.subDataTable'))[2].click();
        await page.waitForNetworkIdle();

        await page.waitFor(function () {
            return $('.cellSubDataTable > .dataTable').length === 2;
        });

        await page.mouse.move(-10, -10); // mae sure no row is highlighted

        expect(await page.screenshot({ fullPage: true })).to.matchImage('subtables_loaded');
    });

    it("should search the table when a search string is entered and the search button clicked", async function () {
        await page.click('.dataTableAction.searchAction');
        await page.focus('.searchAction .dataTableSearchInput');
        await page.keyboard.type('term');
        await page.click('.searchAction .icon-search');
        await page.waitForNetworkIdle();
        await page.evaluate(() => document.activeElement.blur());
        await page.waitFor(500);
        expect(await page.screenshot({ fullPage: true })).to.matchImage('15_search');
    });

    it("should display the export popover when clicking the export icon", async function () {
        await page.click('.activateExportSelection');
        await page.waitFor('#reportExport .btn');

        dialog = await page.$('.ui-dialog');
        expect(await dialog.screenshot()).to.matchImage('export_options');
    });

    it("should show the totals row when the config link is clicked", async function () {
        await page.goto(url);
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableShowTotalsRow');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('totals_row');
    });

    it("should display a related report when related report link is clicked", async function () {
        const newReportUrl = url.replace("=Referrers", "=DevicesDetection").replace("=getKeywords", "=getOsFamilies");
        await page.goto(newReportUrl);

        const visibleSpan = await page.jQuery('.datatableRelatedReports li>span:visible');
        await visibleSpan.click();
        await page.waitForNetworkIdle();

        await page.mouse.move(-10, -10); // mae sure no row is highlighted
        expect(await page.screenshot({ fullPage: true })).to.matchImage('related_report_click');
    });

    it("should exclude low population rows when low population clicked", async function () {
        const newUrl = url
            .replace('moduleToWidgetize=Referrers', 'moduleToWidgetize=Actions')
            .replace('actionToWidgetize=getKeywords', 'actionToWidgetize=getPageUrls');
        await page.goto(newUrl);
        await page.click('.dropdownConfigureIcon');
        await page.click('.dataTableExcludeLowPopulation');
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('exclude_low_population');
    });
});