fix(POSTV1-02): 修复便携版网页入口门禁
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run
This commit is contained in:
@@ -125,7 +125,12 @@ afterAll(async () => {
|
||||
|
||||
describe("TDD-WP0-BRW-001 supported browser contract", () => {
|
||||
it("cross-checks UA-CH and issues only a short-lived signed support cookie", async () => {
|
||||
const app = await createApp({ browserSupportRelease: testBrowserSupportRelease } as never);
|
||||
const app = await createApp({
|
||||
browserSupportRelease: testBrowserSupportRelease,
|
||||
productIndexHtml: "<!doctype html><title>Dada product test</title><div id=\"root\"></div>",
|
||||
} as never);
|
||||
const gate = await app.inject({ headers: { host: "127.0.0.1:43121" }, method: "GET", url: "/" });
|
||||
expect(gate.body).toContain("当前浏览器无法使用 Dada");
|
||||
const checked = await app.inject({
|
||||
headers: supportedEdge.headers,
|
||||
method: "POST",
|
||||
@@ -150,6 +155,14 @@ describe("TDD-WP0-BRW-001 supported browser contract", () => {
|
||||
|
||||
const cookie = supportCookie(checked);
|
||||
expect(cookie).toBeDefined();
|
||||
const productHtml = await app.inject({
|
||||
headers: { cookie, host: "127.0.0.1:43121", "sec-ch-ua": supportedEdge.headers["sec-ch-ua"] },
|
||||
method: "GET",
|
||||
url: "/app",
|
||||
});
|
||||
expect(productHtml.statusCode).toBe(200);
|
||||
expect(productHtml.body).toContain("Dada product test");
|
||||
expect(productHtml.body).not.toContain("当前浏览器无法使用 Dada");
|
||||
const product = await app.inject({
|
||||
headers: {
|
||||
cookie,
|
||||
|
||||
@@ -125,18 +125,20 @@ test("portable package serves the product and keeps SQLite data across API resta
|
||||
let api = startApi(configPath, dataRoot);
|
||||
try {
|
||||
await waitForHealth(api);
|
||||
const initialPage = await fetch(`http://127.0.0.1:${port}/`, { headers: { host: `127.0.0.1:${port}` } });
|
||||
assert.equal(initialPage.status, 200);
|
||||
assert.match(await initialPage.text(), /当前浏览器无法使用 Dada/);
|
||||
const support = await fetch(`http://127.0.0.1:${port}/api/v1/support/check`, {
|
||||
method: "POST",
|
||||
headers: { host: `127.0.0.1:${port}`, origin: `http://127.0.0.1:${port}`, "content-type": "application/json", "sec-ch-ua": '"Google Chrome";v="150"', "sec-ch-ua-full-version-list": '"Google Chrome";v="150.0.0.0"', "sec-ch-ua-platform": '"Windows"' },
|
||||
body: JSON.stringify({ brands: [{ brand: "Google Chrome", version: "150" }], full_version_list: [{ brand: "Google Chrome", version: "150.0.0.0" }], platform: "Windows" }),
|
||||
});
|
||||
assert.ok([200, 426].includes(support.status));
|
||||
if (support.status === 200) {
|
||||
const cookie = support.headers.get("set-cookie")?.split(";", 1)[0];
|
||||
const page = await fetch(`http://127.0.0.1:${port}/app`, { headers: { host: `127.0.0.1:${port}`, cookie } });
|
||||
assert.equal(page.status, 200);
|
||||
assert.match(await page.text(), /<div id="root"><\/div>/);
|
||||
}
|
||||
assert.equal(support.status, 200);
|
||||
const cookie = support.headers.get("set-cookie")?.split(";", 1)[0];
|
||||
assert.ok(cookie);
|
||||
const page = await fetch(`http://127.0.0.1:${port}/app`, { headers: { host: `127.0.0.1:${port}`, cookie, "sec-ch-ua": '"Google Chrome";v="150"' } });
|
||||
assert.equal(page.status, 200);
|
||||
assert.match(await page.text(), /<div id="root"><\/div>/);
|
||||
assert.ok(existsSync(join(dataRoot, "db", "dada.sqlite3")));
|
||||
await verifyWorkerStartup(configPath);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user