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

Menus_spec.js « specs « UI « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3680d8f1dda149fb7f667f64dc18d9611daa9d01 (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
/*!
 * Piwik - free/libre analytics platform
 *
 * Screenshot tests for main, top and admin menus.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

describe("Menus", function () {
    this.fixture = "Piwik\\Tests\\Fixtures\\ThreeGoalsOnePageview";

    const generalParams = 'idSite=1&period=year&date=2009-01-04',
        urlBase = 'module=CoreHome&action=index&' + generalParams;

    async function openMenuItem(page, menuItem) {
        const element = await page.jQuery('#secondNavBar .navbar a:contains(' + menuItem + '):first');
        await element.click();
    }

    // main menu tests
    it('should load the main reporting menu correctly', async function() {
        await page.goto("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Pages");
        await page.waitFor('#secondNavBar', { visible: true });

        const element = await page.jQuery('#secondNavBar');
        expect(await element.screenshot()).to.matchImage('mainmenu_loaded');
    });

    it('should change the menu when a upper menu item is clicked in the main menu', async function() {
        await openMenuItem(page, 'Visitors');

        const element = await page.jQuery('#secondNavBar');
        expect(await element.screenshot()).to.matchImage('mainmenu_upper_clicked');
    });

    it('should change the menu when a lower menu item is clicked in the main menu', async function() {
        await openMenuItem(page, 'Custom Variables');

        const element = await page.jQuery('#secondNavBar');
        expect(await element.screenshot()).to.matchImage('mainmenu_lower_clicked');
    });

    // admin menu tests
    it('should load the admin reporting menu correctly', async function() {
        await page.goto("?" + generalParams + "&module=CoreAdminHome&action=generalSettings");
        await page.waitFor('#secondNavBar');

        const element = await page.jQuery('#secondNavBar');
        expect(await element.screenshot()).to.matchImage('admin_loaded');
    });

    it('should change the admin page correctly when an admin menu item is clicked', async function() {
        await openMenuItem(page, 'Manage');
        await page.waitForNetworkIdle();
        await page.waitFor('#secondNavBar');

        const element = await page.jQuery('#secondNavBar');
        expect(await element.screenshot()).to.matchImage('admin_changed');
    });

    // top menu on mobile
    it('should load the admin reporting menu correctly', async function() {
        page.webpage.setViewport({ width: 768, height: 512 });
        await page.goto("?" + generalParams + "&module=CoreAdminHome&action=index");
        await page.waitFor('.pageWrap');
        await page.evaluate(function(){
            $('.activateTopMenu').click();
        });
        await page.waitFor(250);

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