-
Notifications
You must be signed in to change notification settings - Fork 2
/
multi-level-dropdown.spec.js
55 lines (43 loc) · 1.87 KB
/
multi-level-dropdown.spec.js
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
const { test, expect } = require("@playwright/test");
test.describe("Multi Level Dropdown", () => {
test("Should validate Setting sub-menu items", async ({ page }) => {
await page.goto("apps/multi-level-dropdown/");
await expect(page.locator(".navbar-nav")).toBeVisible();
await page.locator(".icon-button").last().click(); // Opens main menu
await page.locator("text=Settings").click(); // Opens Settings sub-menu
await expect(page.locator(".menu-secondary-enter-done >> .menu-item")).toHaveText([
"My Tutorial",
"HTML",
"CSS",
"JavaScript",
"Awesome!",
]);
const links = page.locator(".menu-secondary-enter-done >> a:visible");
const linksCount = await links.count();
await expect(links).not.toHaveCount(0);
const expectedLinks = ["#main", "#!HTML", "#!CSS", "#!JavaScript", "#!Awesome"];
for (let i = 0; i < linksCount; i++) {
await expect(links.nth(i)).toHaveAttribute("href", expectedLinks[i]);
}
});
test("Should validate Animals sub-menu items", async ({ page }) => {
await page.goto("apps/multi-level-dropdown/");
await expect(page.locator(".navbar-nav")).toBeVisible();
await page.locator(".icon-button").last().click(); // Opens main menu
await page.locator("text=Animals").click(); // Opens Animals sub-menu
await expect(page.locator(".menu-secondary-enter-done >> .menu-item")).toHaveText([
"Animals",
"🦘Kangaroo",
"🐸Frog",
"🦋Horse",
"🦔Hedgehog",
]);
const links = page.locator(".menu-secondary-enter-done >> a:visible");
const linksCount = await links.count();
await expect(links).not.toHaveCount(0);
const expectedLinks = ["#main", "#!Kangaroo", "#!Frog", "#!Horse", "#!Hedgehog"];
for (let i = 0; i < linksCount; i++) {
await expect(links.nth(i)).toHaveAttribute("href", expectedLinks[i]);
}
});
});