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
|
/*!
* Piwik - free/libre analytics platform
*
* Overlay screenshot tests.
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
// TODO: should be stored in Overlay plugin
describe("Overlay", function () {
this.timeout(0);
var url = null;
function removeOptOutIframe(page) {
page.evaluate(function () {
$('iframe#optOutIframe', $('iframe').contents()).remove();
});
}
before(function (done) {
url = "?module=Overlay&period=year&date=today&idSite=3#l=" + encodeURIComponent(testEnvironment.overlayUrl).replace(/[%]/g, "$");
testEnvironment.callApi("SitesManager.addSiteAliasUrls", {idSite: 3, urls: [config.piwikUrl]}, done);
});
after(function (done) {
testEnvironment.callApi("SitesManager.setSiteAliasUrls", {idSite: 3, urls: []}, done);
});
it("should load correctly", function (done) {
expect.screenshot("loaded").to.be.capture(function (page) {
page.load(url);
removeOptOutIframe(page);
}, done);
});
it("should show clicks when hover over link in iframe", function (done) {
expect.screenshot("page_link_clicks").to.be.capture(function (page) {
var pos = page.webpage.evaluate(function () {
var iframe = $('iframe'),
innerOffset = $('.btn.btn-lg', iframe.contents()).offset();
return {
x: iframe.offset().left + innerOffset.left,
y: iframe.offset().top + innerOffset.top
};
});
page.sendMouseEvent('mousemove', pos);
page.evaluate(function () {
$('div#PIS_StatusBar', $('iframe').contents()).each(function () {
var html = $(this).html();
html = html.replace(/localhost\:[0-9]+/g, 'localhost');
$(this).html(html);
});
});
removeOptOutIframe(page);
}, done);
});
it("should show stats for new links when dropdown opened", function (done) {
expect.screenshot("page_new_links").to.be.capture(function (page) {
var pos = page.webpage.evaluate(function () {
var iframe = $('iframe'),
innerOffset = $('.dropdown-toggle', iframe.contents()).offset();
return {
x: iframe.offset().left + innerOffset.left + 32, // position is incorrect for some reason w/o adding pixels
y: iframe.offset().top + innerOffset.top
};
});
page.sendMouseEvent('click', pos, 2000);
removeOptOutIframe(page);
}, done);
});
it("should change page when clicking on internal iframe link", function (done) {
expect.screenshot("page_change").to.be.capture(function (page) {
var pos = page.webpage.evaluate(function () {
var iframe = $('iframe'),
innerOffset = $('ul.nav>li:nth-child(2)>a', iframe.contents()).offset();
return {
x: iframe.offset().left + innerOffset.left + 32, // position is incorrect for some reason w/o adding pixels
y: iframe.offset().top + innerOffset.top
};
});
page.sendMouseEvent('click', pos);
removeOptOutIframe(page);
}, done);
});
it("should change date range when period changed", function (done) {
expect.screenshot("period_change").to.be.capture(function (page) {
page.evaluate(function () {
$('#overlayDateRangeSelect').val('day;yesterday').trigger('change');
});
removeOptOutIframe(page);
}, done);
});
it("should open row evolution popup when row evolution link clicked", function (done) {
expect.screenshot("row_evolution").to.be.capture(function (page) {
page.click('#overlayRowEvolution');
page.evaluate(function () {
$('.jqplot-xaxis').hide(); // xaxis will change every day so hide it
});
removeOptOutIframe(page);
}, done);
});
it("should open transitions popup when transitions link clicked", function (done) {
expect.screenshot("transitions").to.be.capture(function (page) {
page.click('button.ui-dialog-titlebar-close');
page.click('#overlayTransitions');
removeOptOutIframe(page);
}, done);
});
});
|