Page MenuHomeSealhub

route-test.ts
No OneTemporary

route-test.ts

import { curryImportPath } from "../utils/import-path.js";
import { formatWithPrettier } from "../utils/prettier.js";
export async function testTemplate(
action_name: string,
new_file_fullpath: string
) {
const rel = curryImportPath(new_file_fullpath);
const content = `import { withProdApp } from "${rel(
"src/back/test_utils/with-prod-app.js"
)}";
import { VERY_LONG_TEST_TIMEOUT, webhintURL } from "${rel(
"src/back/test_utils/webhint.js"
)}";
import { ${action_name}URL } from "${rel("src/back/routes/urls.js")}";
import { getBrowser } from "${rel("src/back/test_utils/browser-creator.js")}";
import type { Browser, BrowserContext, Page } from "@playwright/test";
describe("${action_name} webhint", () => {
it(
"doesn't crash",
async function () {
return withProdApp(async ({ base_url, rest_api }) => {
await rest_api.get(${action_name}URL);
await webhintURL(base_url + ${action_name}URL);
// alternatively you can use webhintHTML for faster but less precise scans
// or for scanning responses of requests that use some form of authorization:
// const response = await rest_api.get(${action_name}URL);
// await webhintHTML(response);
});
}
).timeout(VERY_LONG_TEST_TIMEOUT);
});
describe("${action_name}", () => {
let page: Page;
let browser: Browser;
let context: BrowserContext;
beforeEach(async () => {
browser = await getBrowser();
context = await browser.newContext();
page = await context.newPage();
});
afterEach(async () => {
await context.close();
});
it(
"works as expected",
async function () {
return withProdApp(async ({ base_url }) => {
await page.goto(base_url + ${action_name}URL);
});
}
).timeout(VERY_LONG_TEST_TIMEOUT);
});
`;
return formatWithPrettier(content);
}

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 16:50 (7 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599964
Default Alt Text
route-test.ts (1 KB)

Event Timeline