Skip to content

Commit 1ed16f3

Browse files
committed
tests(web-host): e2e test echo foo
1 parent d398c6a commit 1ed16f3

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

packages/web-host/src/components/Repl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export function Repl({
9292
className="border border-gray-300 rounded-md p-2 w-full pr-10"
9393
onFocus={() => setInputFocus(true)}
9494
onBlur={() => setInputFocus(false)}
95+
placeholder="Type a command..."
9596
/>
9697
</div>
9798
<button

packages/web-host/src/components/ReplHistory.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Fragment } from "react";
2+
13
import type { ReplHistoryEntry } from "../types";
24
import { cn } from "../utils/css";
35

@@ -16,7 +18,7 @@ export function ReplHistory({
1618
<div ref={ref} className={cn(className)} {...props}>
1719
{history.map((entry, index) => (
1820
// biome-ignore lint/suspicious/noArrayIndexKey: no unique key
19-
<div key={index}>
21+
<Fragment key={index}>
2022
{"stdin" in entry && entry.stdin && (
2123
<pre
2224
className="bg-gray-50 whitespace-pre-wrap word-break-word"
@@ -43,7 +45,7 @@ export function ReplHistory({
4345
{entry.stderr}
4446
</pre>
4547
)}
46-
</div>
48+
</Fragment>
4749
))}
4850
</div>
4951
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, type Page, test } from "@playwright/test";
2+
3+
async function getLastStd(page: Page, type: "stdin" | "stdout" | "stderr") {
4+
return await page.locator(`[data-stdtype='${type}']`).last();
5+
}
6+
7+
test("echo foo - enter", async ({ page }) => {
8+
await page.goto("/#repl");
9+
const input = await page.getByPlaceholder("Type a command...");
10+
await input.fill("echo foo");
11+
await input.press("Enter");
12+
const stdin = await getLastStd(page, "stdin");
13+
await expect(stdin).toHaveText("echo foo");
14+
const stdout = await getLastStd(page, "stdout");
15+
await expect(stdout).toHaveText("foo");
16+
});
17+
18+
test("echo foo - run", async ({ page }) => {
19+
await page.goto("/#repl");
20+
const input = await page.getByPlaceholder("Type a command...");
21+
await input.fill("echo foo");
22+
await page.getByRole("button", { name: "Run", exact: true }).click();
23+
const stdin = await getLastStd(page, "stdin");
24+
await expect(stdin).toHaveText("echo foo");
25+
const stdout = await getLastStd(page, "stdout");
26+
await expect(stdout).toHaveText("foo");
27+
});

0 commit comments

Comments
 (0)