Skip to content

Commit 027debc

Browse files
committed
fix the e2e tests for now (they will be made better eventually)
1 parent e64d521 commit 027debc

4 files changed

Lines changed: 34 additions & 21 deletions

File tree

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export default defineConfig({
55
command: "npm run build && npm run preview",
66
port: 4173,
77
},
8+
fullyParallel: true,
89
testDir: "src/tests/e2e",
910
});

src/lib/components/text/ShadowColorButton.svelte

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
}: Props = $props();
2727
</script>
2828

29-
<label bind:this={labelElement} {dir}>
30-
<button
31-
aria-label="Shadow Color"
32-
{@attach tooltip}
33-
class="p-1 {small
34-
? 'text-sm'
35-
: 'text-lg'} rounded-md bg-zinc-800 font-medium hover:bg-white/3">
29+
<button
30+
aria-label="Shadow Color"
31+
{@attach tooltip}
32+
class="p-1 {small
33+
? 'text-sm'
34+
: 'text-lg'} rounded-md font-medium hover:bg-white/3">
35+
<label bind:this={labelElement} {dir}>
3636
<IconShadow />
37-
</button>
38-
</label>
37+
</label>
38+
</button>

src/routes/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@
559559
<div
560560
class="font-minecraft w-full grow overflow-auto bg-zinc-800 first:focus:outline-none"
561561
spellcheck="false"
562+
id="wysiwyg-box"
562563
bind:this={element}>
563564
</div>
564565

src/tests/e2e/basic.test.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ test("home page loads", async ({ page }) => {
1212

1313
test("blank text updates with formatted output", async ({ page }) => {
1414
await page.getByLabel("Keybinds").waitFor();
15-
const textbox = page.getByRole("textbox").nth(1);
16-
await textbox.click();
15+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
1716
await textbox.fill("lorem ipsum");
1817
const output = page.locator("#outputbox").first();
1918
await expect(output).toHaveText(`"lorem ipsum"`);
2019
});
2120

2221
test("the bold button should work", async ({ page }) => {
23-
const textbox = page.getByRole("textbox").nth(1);
24-
await textbox.click();
22+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
2523
await textbox.fill("lorem ipsum");
2624
await textbox.selectText();
2725
let button = page.getByRole("button", { name: "Bold " });
@@ -34,8 +32,7 @@ test("the bold button should work", async ({ page }) => {
3432
});
3533

3634
test("the italic button should work", async ({ page }) => {
37-
const textbox = page.getByRole("textbox").nth(1);
38-
await textbox.click();
35+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
3936
await textbox.fill("lorem ipsum");
4037
await textbox.selectText();
4138
let button = page.getByRole("button", { name: "Italic " });
@@ -48,8 +45,7 @@ test("the italic button should work", async ({ page }) => {
4845
});
4946

5047
test("the strikethrough button should work", async ({ page }) => {
51-
const textbox = page.getByRole("textbox").nth(1);
52-
await textbox.click();
48+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
5349
await textbox.fill("lorem ipsum");
5450
await textbox.selectText();
5551
let button = page.getByRole("button", { name: "Strikethrough " });
@@ -62,8 +58,7 @@ test("the strikethrough button should work", async ({ page }) => {
6258
});
6359

6460
test("the underline button should work", async ({ page }) => {
65-
const textbox = page.getByRole("textbox").nth(1);
66-
await textbox.click();
61+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
6762
await textbox.fill("lorem ipsum");
6863
await textbox.selectText();
6964
let button = page.getByRole("button", { name: "Underline " });
@@ -76,11 +71,27 @@ test("the underline button should work", async ({ page }) => {
7671
});
7772

7873
test("the obfuscation button should work", async ({ page }) => {
79-
const textbox = page.getByRole("textbox").nth(1);
80-
await textbox.click();
74+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
8175
await textbox.fill("lorem ipsum");
8276
await textbox.selectText();
8377
let button = page.getByRole("button", { name: "Obfuscated " });
8478
await button.click();
8579
expect(await textbox.locator("p>span.obfuscated").count()).toBeGreaterThan(0);
8680
});
81+
82+
test("the shadow color button should work", async ({ page }) => {
83+
const textbox = page.locator("#wysiwyg-box>[role=textbox]").first();
84+
await textbox.fill("lorem ipsum");
85+
await textbox.selectText();
86+
let button = page.getByRole("button", { name: "Shadow Color" });
87+
await button.click();
88+
const colorInput = page.locator('input[aria-label="hex color"]');
89+
await colorInput.fill("#ff0000");
90+
await colorInput.press("Enter");
91+
expect(
92+
await textbox.locator('p>span[style*="text-shadow"]').count(),
93+
).toBeGreaterThan(0);
94+
await expect(
95+
textbox.locator('p>span[style*="text-shadow"]').first(),
96+
).toHaveAttribute("style", "text-shadow: rgb(255, 0, 0) 2px 2px 0px;");
97+
});

0 commit comments

Comments
 (0)