2023-06-05 18:48:58 +00:00
|
|
|
// @ts-check
|
2024-07-18 01:54:03 +00:00
|
|
|
const { test, expect } = require("@playwright/test");
|
2023-06-05 18:48:58 +00:00
|
|
|
|
2024-07-24 19:48:30 +00:00
|
|
|
test("hydration", async ({ page }) => {
|
2024-07-18 01:54:03 +00:00
|
|
|
await page.goto("http://localhost:3333");
|
2023-06-05 18:48:58 +00:00
|
|
|
|
2024-07-24 19:48:30 +00:00
|
|
|
// Expect the page to contain the pending text.
|
2024-07-18 01:54:03 +00:00
|
|
|
const main = page.locator("#main");
|
2024-07-24 19:48:30 +00:00
|
|
|
await expect(main).toContainText("Server said: ...");
|
|
|
|
|
|
|
|
// Expect the page to contain the counter text.
|
2024-07-18 01:54:03 +00:00
|
|
|
await expect(main).toContainText("hello axum! 12345");
|
|
|
|
// Expect the title to contain the counter text.
|
|
|
|
await expect(page).toHaveTitle("hello axum! 12345");
|
2023-06-05 18:48:58 +00:00
|
|
|
|
|
|
|
// Click the increment button.
|
2024-07-18 01:54:03 +00:00
|
|
|
let button = page.locator("button.increment-button");
|
2023-06-05 18:48:58 +00:00
|
|
|
await button.click();
|
|
|
|
|
2024-07-24 19:48:30 +00:00
|
|
|
// Click the server button.
|
|
|
|
let serverButton = page.locator("button.server-button");
|
|
|
|
await serverButton.click();
|
|
|
|
|
2023-06-05 18:48:58 +00:00
|
|
|
// Expect the page to contain the updated counter text.
|
2024-07-18 01:54:03 +00:00
|
|
|
await expect(main).toContainText("hello axum! 12346");
|
|
|
|
// Expect the title to contain the updated counter text.
|
|
|
|
await expect(page).toHaveTitle("hello axum! 12346");
|
2023-06-05 18:48:58 +00:00
|
|
|
|
|
|
|
// Expect the page to contain the updated counter text.
|
2024-07-18 01:54:03 +00:00
|
|
|
await expect(main).toContainText("Server said: Hello from the server!");
|
2024-08-03 02:01:55 +00:00
|
|
|
|
|
|
|
// Make sure the error that was thrown on the server is shown in the error boundary on the client
|
|
|
|
const errors = page.locator("#errors");
|
|
|
|
await expect(errors).toContainText("Hmm, something went wrong.");
|
2023-06-05 18:48:58 +00:00
|
|
|
});
|