fix: 忽略空图片并收紧预览警告断言

This commit is contained in:
que01 committed 2026-10-23 14:32:01 +08:00
1 parent 34504c0b44
commit a1b29cedee
4 files changed
+34 -9

No files matched your search

+3 -1
View File
@@ -98,7 +98,9 @@ test.beforeEach(({ page }) => {
const isWarning =
message.type() === "warning" ||
(message.type() === "error" &&
(text.startsWith("Warning:") || text.includes("non-boolean attribute")));
(text.startsWith("Warning:") ||
text.includes("non-boolean attribute") ||
text.includes("empty string")));
if (isWarning) warnings.push(text);
});
});
+22 -1
View File
@@ -1,7 +1,28 @@
import fs from "node:fs";
import { test, expect } from "@playwright/test";
import { test, expect, type Page } from "@playwright/test";
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
const consoleWarnings = new WeakMap<Page, string[]>();
test.beforeEach(({ page }) => {
const warnings: string[] = [];
consoleWarnings.set(page, warnings);
page.on("console", (message) => {
const text = message.text();
const isWarning =
message.type() === "warning" ||
(message.type() === "error" &&
(text.startsWith("Warning:") ||
text.includes("non-boolean attribute") ||
text.includes("empty string")));
if (isWarning) warnings.push(text);
});
});
test.afterEach(({ page }) => {
expect(consoleWarnings.get(page) ?? []).toEqual([]);
});
const templateContent = JSON.parse(
fs.readFileSync("../../packages/template-acheng-campus-food/template.json", "utf8"),
);