File size: 2,099 Bytes
a612fa9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*!
 * Matomo - free/libre analytics platform
 *
 * ImageGraph plugin screenshot tests.
 *
 * @link    https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

describe("ImageGraph", function () {
    before(function () {
        testEnvironment.multiplicateTableResults = 169856;
        testEnvironment.save();
    });

    function getImageGraphUrl(apiModule, apiAction, graphType, period, date) {
        return "index.php?module=API&method=ImageGraph.get&idSite=1&width=500&height=250&apiModule=" + apiModule + "&apiAction=" + apiAction
             + "&graphType=" + graphType + "&period=" + period + "&date=" + date;
    }

    it("should render evolution graphs correctly", async function() {
        await page.goto(getImageGraphUrl('VisitsSummary', 'get', 'evolution', 'month', '2011-06-01,2012-06-01'));

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

    it("should render evolution graphs correctly for week dates", async function() {
        await page.goto(getImageGraphUrl('VisitsSummary', 'get', 'evolution', 'week', '2011-06-01,2012-06-01'));

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

    it("should render horizontal bar graphs correctly", async function() {
        await page.goto(getImageGraphUrl('DevicesDetection', 'getBrowsers', 'horizontalBar', 'year', '2012-01-01'));

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

    it("should render vertical bar graphs correctly", async function() {
        await page.goto(getImageGraphUrl('UserCountry', 'getCountry', 'verticalBar', 'year', '2012-01-01'));

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

    it("should render pie graphs correctly", async function() {
        await page.goto(getImageGraphUrl('DevicesDetection', 'getOsVersions', 'pie', 'year', '2012-01-01'));

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