-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.test.ts
More file actions
97 lines (88 loc) · 3.38 KB
/
basic.test.ts
File metadata and controls
97 lines (88 loc) · 3.38 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
import { expect, test } from "@playwright/test";
test.beforeEach(async ({ page }) => {
await page.goto("/");
});
test("home page loads", async ({ page }) => {
const resp = await page.goto("/");
expect(resp).toBeDefined();
expect(resp?.ok()).toBe(true);
});
test("blank text updates with formatted output", async ({ page }) => {
await page.getByLabel("Keybinds").waitFor();
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
const output = page.locator("#outputbox").first();
await expect(output).toHaveText(`"lorem ipsum"`);
});
test("the bold button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Bold " });
await button.click();
expect(await textbox.locator("p>strong").count()).toBeGreaterThan(0);
await expect(textbox.locator("p>strong").first()).toHaveCSS(
"font-family",
"MinecraftBold",
);
});
test("the italic button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Italic " });
await button.click();
expect(await textbox.locator("p>em").count()).toBeGreaterThan(0);
await expect(textbox.locator("p>em").first()).toHaveCSS(
"font-style",
"italic",
);
});
test("the strikethrough button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Strikethrough " });
await button.click();
expect(await textbox.locator("p>s").count()).toBeGreaterThan(0);
await expect(textbox.locator("p>s").first()).toHaveCSS(
"text-decoration-line",
"line-through",
);
});
test("the underline button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Underline " });
await button.click();
expect(await textbox.locator("p>u").count()).toBeGreaterThan(0);
await expect(textbox.locator("p>u").first()).toHaveCSS(
"text-decoration-line",
"underline",
);
});
test("the obfuscation button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Obfuscated " });
await button.click();
expect(await textbox.locator("p>span.obfuscated").count()).toBeGreaterThan(0);
});
test("the shadow color button should work", async ({ page }) => {
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
await textbox.fill("lorem ipsum");
await textbox.selectText();
let button = page.getByRole("button", { name: "Shadow Color" });
await button.click();
const colorInput = page.locator('input[aria-label="hex color"]');
await colorInput.fill("#ff0000");
await colorInput.press("Enter");
expect(
await textbox.locator('p>span[style*="text-shadow"]').count(),
).toBeGreaterThan(0);
await expect(
textbox.locator('p>span[style*="text-shadow"]').first(),
).toHaveAttribute("style", "text-shadow: rgb(255, 0, 0) 2px 2px 0px;");
});