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
|
/*!
* Matomo - free/libre analytics platform
*
* Page Performance screenshot tests.
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("PagePerformance", function () {
this.timeout(0);
this.fixture = "Piwik\\Plugins\\PagePerformance\\tests\\Fixtures\\VisitsWithPagePerformanceMetrics";
const generalParams = 'idSite=1&period=day&date=2010-03-12',
urlBase = 'module=CoreHome&action=index&' + generalParams;
async function ensureTooltipIsVisibleInScreenshot() {
await page.evaluate(() => {
var html = $('.ui-tooltip').attr('id', 'test-tooltip-permanent')[0].outerHTML;
$('.ui-dialog').append(html);
});
}
it("should load page performance overview", async function () {
await page.goto("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=PagePerformance_Performance");
pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('load');
});
it("should show new row action in pages reports", async function () {
await page.goto("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Pages");
// hover first row
const row = await page.waitForSelector('.dataTable tbody tr:first-child');
await row.hover();
await page.waitForTimeout(50);
pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('rowactions');
});
it("should show rowaction for subtable rows", async function () {
const subtablerow = await page.jQuery('tr.subDataTable:eq(1) .label');
await subtablerow.click();
await page.waitForNetworkIdle();
await page.waitForTimeout(200);
// hover first row
const row = await page.jQuery('tr.subDataTable:eq(1) + tr');
await row.hover();
pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('rowactions_subtable');
});
it("should load page performance overlay", async function () {
// click page performance icon
const row = await page.waitForSelector('.dataTable tbody tr:first-child');
await row.hover();
const icon = await page.waitForSelector('.dataTable tbody tr:first-child a.actionPagePerformance');
await icon.click();
await page.waitForNetworkIdle();
const pageWrap = await page.waitForSelector('.ui-dialog');
await page.hover('.piwik-graph');
await page.waitForSelector('.ui-tooltip', { visible: true });
await ensureTooltipIsVisibleInScreenshot();
await page.waitForTimeout(100);
expect(await pageWrap.screenshot()).to.matchImage('pageurl_overlay');
});
it("should show new table with performance metrics visualization in selection", async function () {
await page.goto("?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Actions&actionToWidgetize=getPageUrls&" + generalParams);
// hover visualization selection
const icon = await page.jQuery('.activateVisualizationSelection');
await icon.click();
await page.waitForTimeout(500); // animation
expect(await page.screenshot({ fullPage: true })).to.matchImage('visualizations');
});
it("should load new table with performance metrics visualization", async function () {
// hover visualization selection
const icon = await page.jQuery('.dropdown-content .icon-page-performance');
await icon.click();
await page.waitForNetworkIdle();
pageWrap = await page.$('.widget');
expect(await pageWrap.screenshot()).to.matchImage('performance_visualization');
});
it("performance overlay should work on page titles report", async function () {
await page.goto("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPageTitles");
// hover first row
const row = await page.waitForSelector('.dataTable tbody tr:first-child');
await row.hover();
// click page performance icon
const icon = await page.waitForSelector('.dataTable tbody tr:first-child a.actionPagePerformance');
await icon.click();
await page.waitForNetworkIdle();
pageWrap = await page.waitForSelector('.ui-dialog');
await page.hover('.piwik-graph');
await page.waitForSelector('.ui-tooltip', { visible: true });
await ensureTooltipIsVisibleInScreenshot();
await page.waitForTimeout(250);
expect(await pageWrap.screenshot()).to.matchImage('pagetitle_overlay');
});
});
|