Skip to content

Commit 1ce5855

Browse files
committed
add playwright base_path test
1 parent fa47696 commit 1ce5855

File tree

12 files changed

+113
-8
lines changed

12 files changed

+113
-8
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ members = [
108108
"packages/playwright-tests/liveview",
109109
"packages/playwright-tests/web",
110110
"packages/playwright-tests/fullstack",
111+
"packages/playwright-tests/fullstack-base-path",
111112
"packages/playwright-tests/fullstack-mounted",
112113
"packages/playwright-tests/fullstack-routing",
113114
"packages/playwright-tests/suspense-carousel",

packages/playwright-tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
playwright-report
22
/web/dist/
3+
test-results/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
const { test, expect } = require("@playwright/test");
3+
4+
test("should return 404 at the root URL", async ({ page }) => {
5+
const response = await page.goto('http://localhost:8080');
6+
expect(response).not.toBeNull();
7+
expect(response.status()).toBe(404);
8+
});
9+
10+
test("should display 'Hello World!' content at /base-path", async ({ page }) => {
11+
await page.goto("http://localhost:8080/base-path");
12+
const main = page.locator("#main");
13+
await expect(main).toContainText("Hello World!");
14+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
const { test, expect } = require("@playwright/test");
3+
4+
test("should return 404 at the root URL", async ({ page }) => {
5+
const response = await page.goto('http://localhost:4444');
6+
expect(response).not.toBeNull();
7+
expect(response.status()).toBe(404);
8+
});
9+
10+
test("should display 'Hello World!' content at /base-path", async ({ page }) => {
11+
await page.goto("http://localhost:4444/base-path");
12+
const main = page.locator("#main");
13+
await expect(main).toContainText("Hello World!");
14+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.dioxus
2+
dist
3+
target
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "dioxus-playwright-fullstack-base-path-test"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
dioxus = { workspace = true, features = ["fullstack"] }
11+
tokio = { workspace = true, features = ["full"], optional = true }
12+
13+
[features]
14+
default = []
15+
server = ["dioxus/server", "dep:tokio"]
16+
web = ["dioxus/web"]
17+
18+
[[bin]]
19+
name = "fullstack-base-path"
20+
path = "src/main.rs"
21+
22+
[[bin]]
23+
name = "fullstack-base-path-ssg"
24+
path = "src/ssg.rs"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[application]
2+
[web.app]
3+
base_path = "base-path"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Regression test for https://github.com/DioxusLabs/dioxus/pull/3958
2+
3+
use dioxus::prelude::*;
4+
5+
fn main() {
6+
launch(|| {
7+
rsx! {
8+
"Hello World!"
9+
}
10+
});
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for https://github.com/DioxusLabs/dioxus/pull/3958
2+
3+
use dioxus::prelude::*;
4+
5+
fn main() {
6+
launch(|| {
7+
rsx! {
8+
"Hello World!"
9+
}
10+
});
11+
}
12+
13+
#[server(endpoint = "static_routes")]
14+
async fn static_routes() -> Result<Vec<String>, ServerFnError> {
15+
Ok(vec!["/".to_string()])
16+
}

0 commit comments

Comments
 (0)