fix: islands not working with basePath (#2496)
This commit is contained in:
+28
-2
@@ -28,11 +28,12 @@ import { EscapeIsland } from "./fixtures_islands/EscapeIsland.tsx";
|
||||
import * as path from "@std/path";
|
||||
import { setBuildCache } from "../src/app.ts";
|
||||
import { getBuildCache } from "../src/app.ts";
|
||||
import type { FreshConfig } from "../src/config.ts";
|
||||
|
||||
await buildProd(allIslandApp);
|
||||
|
||||
function testApp() {
|
||||
const app = new App();
|
||||
function testApp(config?: FreshConfig) {
|
||||
const app = new App(config);
|
||||
setBuildCache(app, getBuildCache(allIslandApp));
|
||||
return app;
|
||||
}
|
||||
@@ -575,6 +576,31 @@ Deno.test({
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "islands - in base path",
|
||||
fn: async () => {
|
||||
const selfCounter = getIsland("SelfCounter.tsx");
|
||||
|
||||
const app = testApp({ basePath: "/foo" })
|
||||
.use(staticFiles())
|
||||
.island(selfCounter, "SelfCounter", SelfCounter)
|
||||
.get("/", (ctx) =>
|
||||
ctx.render(
|
||||
<Doc>
|
||||
<SelfCounter />
|
||||
</Doc>,
|
||||
));
|
||||
|
||||
await withBrowserApp(app, async (page, address) => {
|
||||
await page.goto(`${address}/foo`, { waitUntil: "load" });
|
||||
await page.locator(".ready").wait();
|
||||
|
||||
await page.locator(".increment").click();
|
||||
await waitForText(page, ".output", "1");
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "fsRoutes - load islands from group folder",
|
||||
fn: async () => {
|
||||
|
||||
Reference in New Issue
Block a user