Skip to content

Commit 5053c1d

Browse files
implement e2es: test loading indicator
(exercise 04 - optional step solution)
1 parent b6fc1c0 commit 5053c1d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

e2es/ui.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ test("card generation", async ({ page }) => {
1717
"Test Description"
1818
);
1919
});
20+
21+
test("card loading indicator", async ({ page }) => {
22+
await page.goto("http://localhost:8787/");
23+
await expect(page.getByTestId("card-loading-indicator")).not.toBeVisible();
24+
await page.getByTestId("card-title-input").fill("Test Title");
25+
await page.getByTestId("card-description-input").fill("Test Description");
26+
await page.getByTestId("card-generate-btn").click();
27+
await expect(page.getByTestId("card-loading-indicator")).toBeVisible();
28+
await expect(page.getByTestId("card-loading-indicator")).not.toBeVisible();
29+
});

load-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const getLoadContext: GetLoadContext = ({ context }) => {
2323
const imageBlob = new Blob([imageArray]);
2424
ai = {
2525
async run(..._: unknown[]) {
26+
await new Promise((resolve) => setTimeout(resolve, 500));
2627
return imageBlob.stream();
2728
},
2829
} as Ai;

0 commit comments

Comments
 (0)