feat(server): add isPartial to context types (#1977)
This commit is contained in:
@@ -1423,3 +1423,77 @@ Deno.test("errors on duplicate partial name", async () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("normal visit to handler page", async () => {
|
||||
await withFakeServe(
|
||||
"./tests/fixture_partials/main.ts",
|
||||
async (server) => {
|
||||
const html = await server.getHtml("/isPartial/handler");
|
||||
assertEquals(JSON.parse(html.querySelector("pre")!.textContent!), {
|
||||
isPartial: false,
|
||||
notSetFromMiddleware: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("normal visit to async page", async () => {
|
||||
await withFakeServe(
|
||||
"./tests/fixture_partials/main.ts",
|
||||
async (server) => {
|
||||
const html = await server.getHtml("/isPartial/async");
|
||||
assertEquals(JSON.parse(html.querySelector("pre")!.textContent!), {
|
||||
isPartial: false,
|
||||
notSetFromMiddleware: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("partials visit to handler page", async () => {
|
||||
await withPageName(
|
||||
"./tests/fixture_partials/main.ts",
|
||||
async (page, address) => {
|
||||
await page.goto(`${address}/isPartial`);
|
||||
await page.waitForSelector(".output");
|
||||
|
||||
const href = await page.$eval(".handler-update-link", (el) => el.href);
|
||||
await page.click(".handler-update-link");
|
||||
await page.waitForSelector("pre");
|
||||
|
||||
assertEquals(href, await page.url());
|
||||
await assertNoPageComments(page);
|
||||
const result = await page.$eval("pre", (el) => {
|
||||
return el.textContent;
|
||||
});
|
||||
assertEquals(JSON.parse(result), {
|
||||
isPartial: true,
|
||||
setFromMiddleware: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("partials visit to async page", async () => {
|
||||
await withPageName(
|
||||
"./tests/fixture_partials/main.ts",
|
||||
async (page, address) => {
|
||||
await page.goto(`${address}/isPartial`);
|
||||
await page.waitForSelector(".output");
|
||||
|
||||
const href = await page.$eval(".async-update-link", (el) => el.href);
|
||||
await page.click(".async-update-link");
|
||||
await page.waitForSelector("pre");
|
||||
|
||||
assertEquals(href, await page.url());
|
||||
await assertNoPageComments(page);
|
||||
const result = await page.$eval("pre", (el) => {
|
||||
return el.textContent;
|
||||
});
|
||||
assertEquals(JSON.parse(result), {
|
||||
isPartial: true,
|
||||
setFromMiddleware: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user