-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathoptions.test.ts
More file actions
164 lines (136 loc) · 4.28 KB
/
options.test.ts
File metadata and controls
164 lines (136 loc) · 4.28 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* @fileoverview Tests for language selection and options panel functionality.
*/
//-----------------------------------------------------------------------------
// Imports
//-----------------------------------------------------------------------------
import { expect, test } from "@playwright/test";
//-----------------------------------------------------------------------------
// Tests
//-----------------------------------------------------------------------------
/**
* This test verifies that:
* - Users can open the language options popover
* - Users can switch between supported languages (JavaScript, JSON, Markdown, CSS, HTML)
* - For each language the entire page is correctly rendered
*/
test("should switch language and show options for each", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Language Options" }).click();
const languageSelect = page.getByRole("combobox", { name: "Language" });
// JavaScript
await test.step("should show JavaScript options when JavaScript is selected", async () => {
await languageSelect.click();
await page
.getByRole("option", { exact: true, name: "JavaScript" })
.click();
// `Language` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Language" }),
).toHaveText("JavaScript");
// `Parser` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Parser" }),
).toHaveText("Espree");
// `Source Type` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Source Type" }),
).toHaveText("Module");
// `ECMAScript Version` Combobox
await expect(
page.getByRole("combobox", {
exact: true,
name: "ECMAScript Version",
}),
).toHaveText("Latest");
// `JSX` Switch
await expect(
page.getByRole("switch", {
exact: true,
name: "JSX",
}),
).toBeVisible();
});
// JSON
await test.step("should show JSON options when JSON is selected", async () => {
await languageSelect.click();
await page.getByRole("option", { exact: true, name: "JSON" }).click();
// `Language` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Language" }),
).toHaveText("JSON");
// `Mode` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Mode" }),
).toHaveText("jsonc");
// `Allow Trailing Commas` Switch
await expect(
page.getByRole("switch", {
exact: true,
name: "Allow Trailing Commas",
}),
).toBeVisible();
});
// Markdown
await test.step("should show Markdown options when Markdown is selected", async () => {
await languageSelect.click();
await page
.getByRole("option", { exact: true, name: "Markdown" })
.click();
// `Language` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Language" }),
).toHaveText("Markdown");
// `Mode` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Mode" }),
).toHaveText("CommonMark");
// `Front Matter` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Front Matter" }),
).toBeVisible();
// `Math` Switch
await expect(
page.getByRole("switch", {
exact: true,
name: "Math",
}),
).toBeVisible();
});
// CSS
await test.step("should show CSS options when CSS is selected", async () => {
await languageSelect.click();
await page.getByRole("option", { exact: true, name: "CSS" }).click();
// `Language` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Language" }),
).toHaveText("CSS");
// `Tolerant Parsing` Switch
await expect(
page.getByRole("switch", { exact: true, name: "Tolerant Parsing" }),
).toBeVisible();
});
// HTML
await test.step("should show HTML options when HTML is selected", async () => {
await languageSelect.click();
await page.getByRole("option", { exact: true, name: "HTML" }).click();
// `Language` Combobox
await expect(
page.getByRole("combobox", { exact: true, name: "Language" }),
).toHaveText("HTML");
// `Template Engine Syntax` Combobox
await expect(
page.getByRole("combobox", {
exact: true,
name: "Template Engine Syntax",
}),
).toBeVisible();
// `Front Matter` Switch
await expect(
page.getByRole("switch", {
exact: true,
name: "Front Matter",
}),
).toBeVisible();
});
});