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

UIIntegration_spec.js « specs « UI « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b3e51288af2ffdca73bd15fd8cf6f97dd0159805 (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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
/*!
 * Piwik - free/libre analytics platform
 *
 * Screenshot integration tests.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

describe("UIIntegrationTest", function () { // TODO: Rename to Piwik?
    this.timeout(0);

    var generalParams = 'idSite=1&period=year&date=2012-08-09',
        idSite2Params = 'idSite=2&period=year&date=2012-08-09',
        evolutionParams = 'idSite=1&period=day&date=2012-01-31&evolution_day_last_n=30',
        urlBase = 'module=CoreHome&action=index&' + generalParams,
        widgetizeParams = "module=Widgetize&action=iframe",
        segment = encodeURIComponent("browserCode==FF") // from OmniFixture
        ;

    before(function (done) {
        testEnvironment.queryParamOverride = {
            forceNowValue: testEnvironment.forcedNowTimestamp,
            visitorId: testEnvironment.forcedIdVisitor,
            realtimeWindow: 'false'
        };
        testEnvironment.save();

        testEnvironment.callApi("SitesManager.setSiteAliasUrls", {idSite: 3, urls: []}, done);
    });

    beforeEach(function () {
        if (testEnvironment.configOverride.database) {
            delete testEnvironment.configOverride.database;
        }
        testEnvironment.testUseMockAuth = 1;
        testEnvironment.save();
    });

    after(function () {
        delete testEnvironment.queryParamOverride;
        testEnvironment.testUseMockAuth = 1;
        testEnvironment.save();
    });

    // dashboard tests
    it("should load dashboard1 correctly", function (done) {
        expect.screenshot("dashboard1").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=1");

            page.evaluate(function () {
                // Prevent random sizing error eg. http://builds-artifacts.piwik.org/ui-tests.master/2301.1/screenshot-diffs/diffviewer.html
                $("[widgetid=widgetActionsgetOutlinks] .widgetContent").text('Displays different at random -> hidden');
            });
        }, done);
    });

    it("should load dashboard2 correctly", function (done) {
        expect.screenshot("dashboard2").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=2");
        }, done);
    });

    it("should load dashboard3 correctly", function (done) {
        expect.screenshot("dashboard3").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=3");
        }, done);
    });

    it("should load dashboard4 correctly", function (done) {
        expect.screenshot("dashboard4").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=4");
        }, done);
    });

    it("should display dashboard correctly on a mobile phone", function (done) {
        expect.screenshot("dashboard5_mobile").to.be.capture(function (page) { // capture with menu
            page.setViewportSize(480, 320);
            page.load("?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=5");
        }, done);
    });

    // visitors pages
    it('should load visitors > overview page correctly', function (done) {
        expect.screenshot("visitors_overview").to.be.captureSelector('.pageWrap', function (page) {
            // use columns query param to make sure columns works when supplied in URL fragment
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=General_Overview&columns=nb_visits,nb_actions");
        }, done);
    });

    it('should reload the visitors > overview page when clicking on the visitors overview page element again', function (done) {
        expect.screenshot("visitors_overview").to.be.captureSelector("visitors_overview_reloaded", '.pageWrap', function (page) {
            page.click('#VisitsSummary_index > a.item');
        }, done);
    });

    // random failure here! the 'processed' screenshot displayed in UI test viewer is actually the next processed screenshot
    //it('should load visitors > visitor log page correctly', function (done) {
    //    expect.screenshot("visitors_visitorlog").to.be.skippedOnAbort();
    //    expect.screenshot("visitors_visitorlog").to.be.captureSelector('.pageWrap', function (page) {
    //        page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=Live_VisitorLog");
    //    }, done);
    //});
    //
    //it('should load visitors with site search > visitor log page correctly', function (done) {
    //    expect.screenshot("visitors_with_site_search_visitorlog").to.be.skippedOnAbort();
    //    expect.screenshot("visitors_with_site_search_visitorlog").to.be.captureSelector('.pageWrap', function (page) {
    //        page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=Live_VisitorLog&period=day&date=2012-01-11");
    //    }, done);
    //});

    it('should load the visitors > devices page correctly', function (done) {
        expect.screenshot("visitors_devices").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=DevicesDetection_Devices");
        }, done);
    });

    it('should load visitors > locations & provider page correctly', function (done) {
        expect.screenshot("visitors_locations_provider").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=UserCountry_SubmenuLocations");
        }, done);
    });

    it('should load the visitors > software page correctly', function (done) {
        expect.screenshot("visitors_software").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=DevicesDetection_Software");
        }, done);
    });

    it('should load the visitors > times page correctly', function (done) {
        expect.screenshot("visitors_times").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=VisitTime_SubmenuTimes");
        }, done);
    });

    it('should load the visitors > engagement page correctly', function (done) {
        expect.screenshot("visitors_engagement").to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=VisitorInterest_Engagement");
        }, done);
    });

    it('should load the visitors > custom variables page correctly', function (done) {
        expect.screenshot('visitors_custom_vars').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=CustomVariables_CustomVariables");
        }, done);
    });

    it('should load the visitors > real-time map page correctly', function (done) {
        expect.screenshot('visitors_realtime_map').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + idSite2Params + "&category=General_Visitors&subcategory=UserCountryMap_RealTimeMap"
                    + "&showDateTime=0&realtimeWindow=last2&changeVisitAlpha=0&enableAnimation=0&doNotRefreshVisits=1"
                    + "&removeOldVisits=0");
        }, done);
    });

    // actions pages
    it('should load the actions > pages page correctly', function (done) {
        expect.screenshot('actions_pages').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Pages");
        }, done);
    });

    // actions pages
    it('should load the actions > pages help tooltip, including the "Report generated time"', function (done) {
        expect.screenshot('actions_pages_tooltip_help').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Pages");
            page.mouseMove('[piwik-enriched-headline]');
            page.click(".helpIcon");
            page.evaluate(function () {
                $('.helpDate:visible').hide();
            });
        }, done);
    });

    it('should load the actions > entry pages page correctly', function (done) {
        expect.screenshot('actions_entry_pages').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesEntry");
        }, done);
    });

    it('should load the actions > exit pages page correctly', function (done) {
        expect.screenshot('actions_exit_pages').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesExit");
        }, done);
    });

    it('should load the actions > page titles page correctly', function (done) {
        expect.screenshot('actions_page_titles').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPageTitles");
        }, done);
    });

    it('should load the actions > site search page correctly', function (done) {
        expect.screenshot('actions_site_search').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuSitesearch");
        }, done);
    });

    it('should load the actions > outlinks page correctly', function (done) {
        expect.screenshot('actions_outlinks').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Outlinks");
        }, done);
    });

    it('should load the actions > downloads page correctly', function (done) {
        expect.screenshot('actions_downloads').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Downloads");
        }, done);
    });

    it('should load the actions > contents page correctly', function (done) {
        expect.screenshot('actions_contents').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Contents_Contents&period=day&date=2012-01-01");
        }, done);
    });

    it("should show all corresponding content pieces when clicking on a content name", function (done) {
        expect.screenshot("actions_content_name_piece").to.be.captureSelector('.pageWrap', function (page) {
            page.click('.dataTable .subDataTable .value:contains(ImageAd)');
        }, done);
    });

    it("should show all tracked content pieces when clicking on the table", function (done) {
        expect.screenshot("actions_content_piece").to.be.captureSelector('.pageWrap', function (page) {
            page.click('.reportDimension .dimension:contains(Content Piece)');
        }, done);
    });

    it("should show all corresponding content names when clicking on a content piece", function (done) {
        expect.screenshot("actions_content_piece_name").to.be.captureSelector('.pageWrap', function (page) {
            page.click('.dataTable .subDataTable .value:contains(Click NOW)');
        }, done);
    });

    // referrers pages
    it('should load the referrers > overview page correctly', function (done) {
        expect.screenshot('referrers_overview').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Referrers_Referrers&subcategory=General_Overview");
        }, done);
    });

    // referrers pages
    it('should load the referrers > overview page correctly', function (done) {
        expect.screenshot('referrers_allreferrers').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Referrers_Referrers&subcategory=Referrers_WidgetGetAll");
        }, done);
    });

    it('should display metric tooltip correctly', function (done) {
        expect.screenshot("metric_tooltip").to.be.captureSelector('.pageWrap,.columnDocumentation:visible', function (page) {
            page.mouseMove('[data-report="Referrers.getReferrerType"] #nb_visits .thDIV', 500);
        }, done);
    });

    it('should load the referrers > search engines & keywords page correctly', function (done) {
        this.retries(3);
        expect.screenshot('referrers_search_engines_keywords').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Referrers_Referrers&subcategory=Referrers_SubmenuSearchEngines");
        }, done);
    });

    it('should load the referrers > websites & social page correctly', function (done) {
        expect.screenshot('referrers_websites_social').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Referrers_Referrers&subcategory=Referrers_SubmenuWebsites");
        }, done);
    });

    it('should load the referrers > campaigns page correctly', function (done) {
        expect.screenshot('referrers_campaigns').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Referrers_Referrers&subcategory=Referrers_Campaigns");
        }, done);
    });

    // goals pages
    it('should load the goals > ecommerce page correctly', function (done) {
        expect.screenshot('goals_ecommerce').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load( "?" + urlBase + "#?" + generalParams + "&category=Goals_Ecommerce&subcategory=General_Overview")
        }, done);
    });

    it('should load the goals > overview page correctly', function (done) {
        expect.screenshot('goals_overview').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load( "?" + urlBase + "#?" + generalParams + "&category=Goals_Goals&subcategory=General_Overview");
        }, done);
    });

    it('should load the goals > management page correctly', function (done) {
        expect.screenshot('goals_manage').to.be.captureSelector('#content,.top_bar_sites_selector,.entityContainer', function (page) {
            page.load("?" + generalParams + "&module=Goals&action=manage");
            page.wait(200);
        }, done);
    });

    it('should load the goals > single goal page correctly', function (done) {
        expect.screenshot('goals_individual_goal').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Goals_Goals&subcategory=1");
        }, done);
    });

    it('should update the evolution chart if a sparkline is clicked', function (done) {
        expect.screenshot('goals_individual_goal_updated').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.click('.sparkline.linked:contains(%)');
        }, done);
    });

    // Events pages
    it('should load the Events > index page correctly', function (done) {
        expect.screenshot('events_overview').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Events_Events");
        }, done);
    });

    // one page w/ segment
    it('should load the visitors > overview page correctly when a segment is specified', function (done) {
        expect.screenshot('visitors_overview_segment').to.be.captureSelector('.pageWrap,.top_controls', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=General_Overview&segment=" + segment);
        }, done);
    });

    // example ui pages
    it('should load the example ui > dataTables page correctly', function (done) {
        expect.screenshot('exampleui_dataTables').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=ExampleUI_GetTemperaturesDataTable");
        }, done);
    });

    it('should load the example ui > barGraph page correctly', function (done) {
        expect.screenshot('exampleui_barGraph').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Bar%20graph");
        }, done);
    });

    it('should load the example ui > pieGraph page correctly', function (done) {
        expect.screenshot('exampleui_pieGraph').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Pie%20graph");
        }, done);
    });

    it('should load the example ui > tagClouds page correctly', function (done) {
        expect.screenshot('exampleui_tagClouds').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Tag%20clouds");
        }, done);
    });

    it('should load the example ui > sparklines page correctly', function (done) {
        expect.screenshot('exampleui_sparklines').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Sparklines");
        }, done);
    });

    it('should load the example ui > evolution graph page correctly', function (done) {
        expect.screenshot('exampleui_evolutionGraph').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Evolution%20Graph");
        }, done);
    });

    it('should load the example ui > treemap page correctly', function (done) {
        expect.screenshot('exampleui_treemap').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=ExampleUI_UiFramework&subcategory=Treemap");
            page.wait(2000);
        }, done);
    });

    // widgetize
    it('should load the widgetized visitor log correctly', function (done) {
        expect.screenshot('widgetize_visitor_log').to.be.capture(function (page) {
            expect.screenshot("widgetize_visitor_log").to.be.skippedOnAbort();
            page.load("?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=Live&actionToWidgetize=getVisitorLog");
            page.evaluate(function () {
                $('.expandDataTableFooterDrawer').click();
            });
        }, done);
    });

    it('should load the widgetized all websites dashboard correctly', function (done) {
        this.retries(3);
        expect.screenshot('widgetize_allwebsites').to.be.capture(function (page) {
            page.load("?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=MultiSites&actionToWidgetize=standalone");
        }, done);
    });

    it('should widgetize the ecommerce log correctly', function (done) {
        expect.screenshot("widgetize_ecommercelog").to.be.skippedOnAbort();
        expect.screenshot('widgetize_ecommercelog').to.be.capture(function (page) {
            page.load("?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=Ecommerce&actionToWidgetize=getEcommerceLog&filter_limit=-1");
        }, done);
    });

    // Do not allow API response to be displayed
    it('should not allow to widgetize an API call', function (done) {
        expect.screenshot('widgetize_apidisallowed').to.be.capture(function (page) {
            page.load("?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=API&actionToWidgetize=index&method=SitesManager.getImageTrackingCode&piwikUrl=test");
        }, done);
    });

    it('should not display API response in the content', function (done) {
        expect.screenshot('menu_apidisallowed').to.be.captureSelector('#content', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&module=API&action=SitesManager.getImageTrackingCode");
        }, done);
    });

    // Ecommerce
    it('should load the ecommerce overview page', function (done) {
        expect.screenshot('ecommerce_overview').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Goals_Ecommerce&subcategory=General_Overview");
        }, done);
    });

    it('should load the ecommerce log page', function (done) {
        expect.screenshot("ecommerce_log").to.be.skippedOnAbort();
        expect.screenshot('ecommerce_log').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Goals_Ecommerce&subcategory=Goals_EcommerceLog");
        }, done);
    });

    it('should load the ecommerce products page', function (done) {
        expect.screenshot('ecommerce_products').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Goals_Ecommerce&subcategory=Goals_Products");
        }, done);
    });

    it('should load the ecommerce sales page', function (done) {
        expect.screenshot('ecommerce_sales').to.be.captureSelector('.pageWrap,.dataTable', function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=Goals_Ecommerce&subcategory=Ecommerce_Sales");
        }, done);
    });

    it('should load the Admin home page correct', function (done) {
        expect.screenshot('admin_home').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CoreAdminHome&action=home");
        }, done);
    });

    // Admin user settings (plugins not displayed)
    it('should load the Manage > Websites admin page correctly', function (done) {
        expect.screenshot('admin_manage_websites').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=SitesManager&action=index");
            page.evaluate(function () {
                $('.form-help:contains(UTC time is)').hide();
            });
        }, done);
    });

    it('should load the Manage > Users admin page correctly', function (done) {
        expect.screenshot('admin_manage_users').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=UsersManager&action=index");

            // remove token auth which can be random
            page.evaluate(function () {
                $('td#token_auth').each(function () {
                    $(this).text('');
                });
                $('td#last_seen').each(function () {
                    $(this).text( '' )
                });
            });
        }, done);
    });

    it('should load the user settings admin page correctly', function (done) {
        expect.screenshot('admin_user_settings').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=UsersManager&action=userSettings");
        }, done);
    });

    it('should load the Manage > Tracking Code admin page correctly', function (done) {
        expect.screenshot('admin_manage_tracking_code').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CoreAdminHome&action=trackingCodeGenerator");
        }, done);
    });

    it('should load the Settings > General Settings admin page correctly', function (done) {
        expect.screenshot('admin_settings_general').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CoreAdminHome&action=generalSettings");
            // angular might need a little to render after page has loaded
            page.wait(1000);
            page.evaluate(function () {
                $('textarea:eq(0)').trigger('focus');
            });
            page.wait(1000);
        }, done);
    });

    it('should load the Settings > Privacy admin page correctly', function (done) {
        expect.screenshot('admin_privacy_settings').to.be.captureSelector('.pageWrap,.ui-inline-help', function (page) {
            page.load("?" + generalParams + "&module=PrivacyManager&action=privacySettings");
        }, done);
    });

    it('should load the Privacy Opt out iframe correctly', function (done) {
        expect.screenshot('admin_privacy_optout_iframe').to.be.capture(function (page) {
            page.load("?module=CoreAdminHome&action=optOut&language=de");
        }, done);
    });

    it('should load the Settings > Mobile Messaging admin page correctly', function (done) {
        expect.screenshot('admin_settings_mobilemessaging').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=MobileMessaging&action=index");
        }, done);
    });

    it('should load the themes admin page correctly', function (done) {
        expect.screenshot('admin_themes').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CorePluginsAdmin&action=themes");
        }, done);
    });

    it('should load the plugins admin page correctly', function (done) {
        expect.screenshot('admin_plugins').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CorePluginsAdmin&action=plugins");
        }, done);
    });

    it('should load the config file page correctly', function (done) {
        expect.screenshot('admin_diagnostics_configfile').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=Diagnostics&action=configfile");
        }, done);
    });

    it('should load the Settings > Visitor Generator admin page correctly', function (done) {
        expect.screenshot('admin_visitor_generator').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=VisitorGenerator&action=index");

            page.evaluate(function () {
                var $p = $('#content p:eq(1)');
                $p.text($p.text().replace(/\(change .*\)/g, ''));
            });
        }, done);
    });

    // Notifications
    it('should load the notifications page correctly', function (done) {
        expect.screenshot('notifications').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=ExampleUI&action=notifications&idSite=1&period=day&date=yesterday");
            page.evaluate(function () {
                $('#header').hide();
            });
        }, done);
    });

    // Fatal error safemode
    it('should load the safemode fatal error page correctly', function (done) {
        var message = "Call%20to%20undefined%20function%20Piwik%5CPlugins%5CFoobar%5CPiwik_Translate()",
            file = "%2Fhome%2Fvagrant%2Fwww%2Fpiwik%2Fplugins%2FFoobar%2FFoobar.php%20line%205",
            line = 58;

        expect.screenshot('fatal_error_safemode').to.be.capture(function (page) {
            page.load("?" + generalParams + "&module=CorePluginsAdmin&action=safemode&idSite=1&period=day&date=yesterday&activated"
                    + "&error_message=" + message + "&error_file=" + file + "&error_line=" + line + "&tests_hide_piwik_version=1");
        }, done);
    });

    // DB error message
    it('should fail correctly when db information in config is incorrect', function (done) {

        testEnvironment.overrideConfig('database', {
            host: config.phpServer.REMOTE_ADDR,
            username: 'slkdfjsdlkfj',
            password: 'slkdfjsldkfj',
            dbname: 'abcdefg',
            tables_prefix: 'gfedcba'
        });
        testEnvironment.save();

        expect.screenshot('db_connect_error').to.be.capture(function (page) {
            page.load("");
        }, done);
    });

    // CustomAlerts plugin TODO: move to CustomAlerts plugin
    it('should load the custom alerts list correctly', function (done) {
        expect.screenshot('customalerts_list').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CustomAlerts&action=index&idSite=1&period=day&date=yesterday&tests_hide_piwik_version=1");
        }, done);
    });

    it('should load the triggered custom alerts list correctly', function (done) {
        expect.screenshot('customalerts_list_triggered').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=CustomAlerts&action=historyTriggeredAlerts&idSite=1&period=day&date=yesterday&tests_hide_piwik_version=1");
        }, done);
    });

    // top bar pages
    it('should load the widgets listing page correctly', function (done) {
        expect.screenshot('widgets_listing').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=Widgetize&action=index");

            page.mouseMove('.widgetpreview-categorylist>li:contains(Visitors):first');
            page.click('.widgetpreview-categorylist>li:contains(Visitors):first');
            page.mouseMove('.widgetpreview-widgetlist li:contains(Visits Over Time)');
            page.click('.widgetpreview-widgetlist li:contains(Visits Over Time)');
            page.evaluate(function () {
                $('.formEmbedCode').each(function () {
                    var val = $(this).val();
                    val = val.replace(/localhost\:[0-9]+/g, 'localhost');
                    $(this).val(val);
                });
            });
        }, done);
    });

    it('should load the API listing page correctly', function (done) {
        expect.screenshot('api_listing').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=API&action=listAllAPI");
        }, done);
    });

    it('should load the email reports page correctly', function (done) {
        expect.screenshot('email_reports').to.be.captureSelector('.pageWrap', function (page) {
            page.load("?" + generalParams + "&module=ScheduledReports&action=index");
            page.evaluate(function () {
                $('#header').hide();
            });
        }, done);
    });

    it('should load the scheduled reports when Edit button is clicked', function (done) {
        expect.screenshot('email_reports_editor').to.be.captureSelector('.pageWrap', function (page) {
            page.click('.entityTable tr:nth-child(4) button[title=Edit]');
        }, done);
    });

    it('should load the feedback form when the feedback form link is clicked', function (done) {
        expect.screenshot('feedback_form').to.be.captureSelector('.pageWrap', function (page) {

            page.load("?" + generalParams + "&module=Feedback&action=index");

            page.evaluate(function () {
                $('.enrichedHeadline span').each(function () {
                    if ($(this).text().indexOf("Piwik") !== -1) {
                        var replace = $(this).text().replace(/Piwik\s*\d+\.\d+(\.\d+)?([\-a-z]*\d+)?/g, 'Piwik');
                        $(this).text(replace);
                    }
                });
            });
        }, done);
    });

    // date range clicked
    it('should reload to the correct date when a date range is selected in the period selector', function (done) {
        expect.screenshot('period_select_date_range_click').to.be.capture(function (page) {
            page.load("?" + urlBase + "#?" + generalParams + "&category=General_Visitors&subcategory=VisitTime_SubmenuTimes");
            page.wait(1000);
            page.click('#date.title');
            // we need to make sure there to wait for a bit till date is opened and period selected
            page.click('#period_id_range');
            page.evaluate(function () {
                $(document).ready(function () {
                    $('#inputCalendarFrom').val('2012-08-02');
                    $('#inputCalendarTo').val('2012-08-12');
                    setTimeout(function () {$('#calendarApply').click();}, 500);
                });
            });
        }, done);
    });

    // visitor profile popup
    it('should load the visitor profile popup correctly', function (done) {
        this.retries(3);

        expect.screenshot('visitor_profile_popup').to.be.capture(function (page) {
            page.load("?" + widgetizeParams + "&" + idSite2Params + "&moduleToWidgetize=Live&actionToWidgetize=getVisitorProfilePopup"
                    + "&enableAnimation=0");

            page.evaluate(function () {
                $(document).ready(function () {
                    $('.visitor-profile-show-map').click();
                });
            });

            page.wait(1000);
        }, done);
    });

    // opt out page
    it('should load the opt out page correctly', function (done) {
        expect.screenshot('opt_out').to.be.capture(function (page) {
            testEnvironment.testUseMockAuth = 0;
            testEnvironment.save();

            page.load("?module=CoreAdminHome&action=optOut&language=en");
        }, done);
    });

    // extra segment tests
    it('should load the row evolution page correctly when a segment is selected', function (done) {
        var url = "?module=CoreHome&action=index&idSite=1&period=year&date=2012-01-13#?module=CustomVariables&action=menuGetCustomVariables&idSite=1&period=year&date=2012-01-13";
        expect.page(url).contains('.ui-dialog > .ui-dialog-content > div.rowevolution:visible', 'segmented_rowevolution', function (page) {
            page.click('.segmentationTitle');
            page.click('.segname:contains(From Europe)');

            page.mouseMove('table.dataTable tbody tr:first-child');
            page.mouseMove('a.actionRowEvolution:visible'); // necessary to get popover to display
            page.click('a.actionRowEvolution:visible');
            page.wait(1000);

        }, done);
    });

    it('should load the segmented visitor log correctly when a segment is selected', function (done) {
        this.retries(3);

        expect.screenshot("segmented_visitorlog").to.be.skippedOnAbort();
        
        var url = "?module=CoreHome&action=index&idSite=1&period=year&date=2012-01-13#?category=General_Visitors&subcategory=CustomVariables_CustomVariables&idSite=1&period=year&date=2012-01-13";
        expect.page(url).contains('.ui-dialog > .ui-dialog-content > div.dataTableVizVisitorLog:visible', 'segmented_visitorlog', function (page) {
            page.wait(1000);
            page.click('.segmentationTitle');
            page.wait(500);
            page.click('.segname:contains(From Europe)');
            page.wait(500);
            page.mouseMove('table.dataTable tbody tr:first-child');
            page.wait(500);
            page.mouseMove('a.actionSegmentVisitorLog:visible'); // necessary to get popover to display
            page.wait(500);
            page.click('a.actionSegmentVisitorLog:visible');
            page.wait(1000);

        }, done);
    });

    it('should not apply current segmented when opening visitor log', function (done) {
        this.retries(3);

        var url = "?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=Live&actionToWidgetize=getVisitorLog&segment=visitCount==2&enableAnimation=0";

        delete testEnvironment.queryParamOverride.visitorId;
        testEnvironment.save();

        expect.screenshot("visitor_profile_not_segmented").to.be.similar(0.002).to.capture(function (page) {
            page.load(url);

            page.evaluate(function () {
                $('.visitor-log-visitor-profile-link').first().click();
            });

            page.wait(1000);
        }, done);
    });


});