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

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

describe("UserSettings", function () {
    this.timeout(0);
    this.fixture = "Piwik\\Plugins\\UsersManager\\tests\\Fixtures\\ManyUsers";

    var userSettingsUrl = "?module=UsersManager&action=userSettings";
    var userSecurityUrl = "?module=UsersManager&action=userSecurity";

    before(async function() {
        await page.webpage.setViewport({
            width: 1250,
            height: 768
        });
    });

    it('should show user security page', async function () {
        await page.goto(userSecurityUrl);
        await page.waitFor('.listAuthTokens', { visible: true });
        await page.evaluate(() => { // give table headers constant width so the screenshot stays the same
            $('table.listAuthTokens th').css('width', '25%');
        });
        await page.waitFor(100);
        expect(await page.screenshotSelector('.admin')).to.matchImage('load_security');
    });

    it('should ask for password when trying to add token', async function () {
        await page.click('.addNewToken');
        await page.waitForNetworkIdle();
        await page.waitForSelector('.loginSection');
        expect(await page.screenshotSelector('.loginSection')).to.matchImage('add_token_check_password');
    });

    it('should accept correct password', async function () {
        await page.type('#login_form_password', 'superUserPass');
        await page.click('#login_form_submit');
        await page.waitForNetworkIdle();
        await page.waitForSelector('.addTokenForm');
        expect(await page.screenshotSelector('.admin')).to.matchImage('add_token');
    });

    it('should create new token', async function () {
        await page.type('.addTokenForm input[id=description]', 'test description');
        await page.click('.addTokenForm .btn');
        await page.waitForNetworkIdle();
        expect(await page.screenshotSelector('.admin')).to.matchImage('add_token_success');
    });

    it('should show user settings page', async function () {
        await page.goto(userSettingsUrl);
        expect(await page.screenshotSelector('.admin')).to.matchImage('load');
    });

    it('should allow user to subscribe to newsletter', async function () {
        await page.click('#newsletterSignup label');
        await page.click('#newsletterSignupBtn input');
        await page.waitForNetworkIdle();
        expect(await page.screenshotSelector('.pageWrap')).to.matchImage('signup_success');
    });

    it('should not prompt user to subscribe to newsletter again', async function () {
        // Assumes previous test has clicked on the signup button - so we shouldn't see it this time
        await page.goto(userSettingsUrl);
        expect(await page.screenshotSelector('.admin')).to.matchImage('already_signed_up');
    });

    it('should ask for password confirmation when changing email', async function () {
        await page.evaluate(function () {
            $('#userSettingsTable input#email').val('testlogin123@example.com').change();
        });
        await page.click('#userSettingsTable [piwik-save-button] .btn');
        await page.waitFor(500); // wait for animation

        let pageWrap = await page.$('.modal.open');
        expect(await pageWrap.screenshot()).to.matchImage('asks_confirmation');
    });

    it('should load error when wrong password specified', async function () {
        await page.type('.modal.open #currentPassword', 'foobartest123');
        btnNo = await page.jQuery('.modal.open .modal-action:not(.modal-no)');
        await btnNo.click();
        await page.waitForNetworkIdle();

        let pageWrap = await page.$('#notificationContainer');
        expect(await pageWrap.screenshot()).to.matchImage('wrong_password_confirmed');
    });
});