File: IgnoreCookie_spec.js

package info (click to toggle)
matomo 5.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 95,068 kB
  • sloc: php: 289,425; xml: 127,249; javascript: 112,130; python: 202; sh: 178; makefile: 20; sql: 10
file content (47 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download
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
/*!
 * Matomo - free/libre analytics platform
 *
 * UsersManager screenshot tests.
 *
 * @link    https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

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

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

    it('should show ignore cookie setting on user settings page', async function () {
        await page.goto(userSettingsUrl);
        expect(await page.screenshotSelector('.ignoreCookieSettings')).to.matchImage('loaded');
    });

    it('should set an ignore cookie and reload the page correctly when clicking ignore link', async function () {
      await page.click('.ignoreCookieSettings a');
      await page.waitForNetworkIdle();

      var cookies = await page.cookies();
      var ignoreCookie = cookies.filter((cookie) => cookie.name === 'matomo_ignore');

      expect(ignoreCookie.length).to.eq(1);
      expect(await page.screenshotSelector('.ignoreCookieSettings')).to.matchImage('ignored');
    });

    it('should remove ignore cookie and reload the page correctly when clicking ignore link again', async function () {
      await page.click('.ignoreCookieSettings a');
      await page.waitForNetworkIdle();

      var cookies = await page.cookies();
      var ignoreCookie = cookies.filter((cookie) => cookie.name === 'matomo_ignore');

      expect(ignoreCookie.length).to.eq(0);
      expect(await page.screenshotSelector('.ignoreCookieSettings')).to.matchImage('reset');
    });

    it('should fail when directly opening the ignore cookie action without a nonce', async function () {
      await page.goto('?module=UsersManager&action=setIgnoreCookie');

      expect(await page.evaluate(() => document.getElementsByClassName('header')[0].innerText)).to.contain('An error occurred');
    });
});