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

ReportExporting_spec.js « specs « UI « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 992dd18b4f45afefd80c7003b6f7f2221ebb0daa (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
/*!
 * Piwik - free/libre analytics platform
 *
 * Export link screenshot tests.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

describe("ReportExporting", function () {
    this.timeout(0);

    var baseUrl = "?module=Widgetize&action=iframe&idSite=1&period=year&date=2012-08-09&isFooterExpandedInDashboard=1",
        referrersGetWebsitesUrl = baseUrl + "&moduleToWidgetize=Referrers&actionToWidgetize=getWebsites&filter_limit=5",
        visitsSummaryGetUrl = baseUrl + "&moduleToWidgetize=VisitsSummary&actionToWidgetize=get&forceView=1&viewDataTable=graphEvolution";

    function normalReportTest(format) {
        it("should export a normal report correctly when the " + format + " export link is clicked", function (done) {
            expect.file('Referrers.getWebsites_exported.' + format.toLowerCase() + '.txt').to.be.pageContents(function (page) {
                if (page.getCurrentUrl() != referrersGetWebsitesUrl) {
                    page.load(referrersGetWebsitesUrl);
                    page.click('a.tableIcon[var=export]');
                    page.click('a.tableIcon[var=export]'); // have to click twice in phantomjs
                }

                page.downloadLink('.exportToFormatItems a[format=' + format + ']');
            }, done);
        });
    }

    function evolutionReportTest(format) {
        it("should export an evolution graph report correclty when the " + format + " export link is clicked", function (done) {
            expect.file('VisitsSummary.get_exported.' + format.toLowerCase() + '.txt').to.be.pageContents(function (page) {
                if (page.getCurrentUrl() != visitsSummaryGetUrl) {
                    page.load(visitsSummaryGetUrl);
                    page.click('a.tableIcon[var=export]');
                    page.click('a.tableIcon[var=export]'); // have to click twice in phantomjs
                }

                page.downloadLink('.exportToFormatItems a[format=' + format + ']');
            }, done);
        });
    }

    function rowEvolutionReportTest(format) {
        it("should export an row evolution graph report correclty when the " + format + " export link is clicked", function (done) {
            expect.file('RowEvolution_exported.' + format.toLowerCase() + '.txt').to.be.pageContents(function (page) {
                if (!page.getCurrentUrl() || page.getCurrentUrl().indexOf('popover') == -1) {
                    page.load(referrersGetWebsitesUrl);
                    page.mouseMove('tbody tr:first-child');
                    page.mouseMove('a.actionRowEvolution:visible'); // necessary to get popover to display
                    page.click('a.actionRowEvolution:visible');

                    page.click('.ui-dialog a.tableIcon[var=export]');
                }

                page.downloadLink('.ui-dialog .exportToFormatItems a[format=' + format + ']');
            }, done);
        });
    }

    var formats = ['CSV', 'TSV', 'XML', 'JSON', 'PHP'];
    formats.forEach(normalReportTest);
    formats.forEach(evolutionReportTest);
    formats.forEach(rowEvolutionReportTest);
});