blob: d509adfb07fc85ff3324d5c55ae503504f42ee6c (
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
*
* ActionsDataTable screenshot tests.
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("QuickAccess", function () {
const selectorToCapture = ".quick-access,.quick-access .dropdown";
const url = "?module=CoreHome&action=index&idSite=1&period=year&date=2012-08-09";
async function enterSearchTerm(searchTermToAdd) {
await page.evaluate(function () {
$('.quick-access input').val('');
});
await page.focus(".quick-access input");
await page.keyboard.type(searchTermToAdd);
await page.waitForNetworkIdle();
await page.evaluate(function () {
$('.quick-access input').blur();
});
}
it("should be displayed", async function () {
await page.goto(url);
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('initially');
});
it("should search for something and update view", async function () {
await enterSearchTerm('s');
await page.waitFor(100);
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('search_1');
});
it("should search again when typing another letter", async function () {
await enterSearchTerm('as');
await page.waitFor(100);
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('search_2');
});
it("should show message if no results", async function () {
await enterSearchTerm('alaskdjfs');
await page.waitFor(100);
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('search_no_result');
});
it("should be possible to activate via shortcut", async function () {
await page.goto(url);
await page.focus('body');
await page.keyboard.type('f');
await page.evaluate(function () {
$('.quick-access input').blur();
});
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('shortcut');
});
it("should search for websites", async function () {
await enterSearchTerm('si');
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('search_sites');
});
it("clicking on a category should show all items that belong to that category", async function () {
const element = await page.jQuery('.quick-access-category:first');
await element.click();
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('search_category');
});
});
|