chore: 清理审计脚本和临时文件,更新.gitignore
This commit is contained in:
@@ -55,3 +55,10 @@ Thumbs.db
|
||||
# SQLite WAL/SHM
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
|
||||
# Audit & screenshot scratch files
|
||||
_audit.cjs
|
||||
_audit/
|
||||
_e2e_test.cjs
|
||||
_screenshot_audit.cjs
|
||||
_shots2/
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
const { chromium } = require("playwright-core");
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
executablePath: "C:/Program Files/Google/Chrome/Application/chrome.exe",
|
||||
args: ["--disable-blink-features=AutomationControlled"],
|
||||
});
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||
const errors = [];
|
||||
page.on("console", msg => {
|
||||
if (msg.type() === "error") errors.push(`CONSOLE: ${msg.text()}`);
|
||||
});
|
||||
page.on("pageerror", err => errors.push(`PAGEERROR: ${err.message}`));
|
||||
|
||||
const BASE = "http://127.0.0.1:5175";
|
||||
|
||||
// Login first via API
|
||||
const loginResp = await page.request.post("http://127.0.0.1:8010/api/auth/login", {
|
||||
data: { phone: "13943441149", password: "Test1234" },
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
const loginData = await loginResp.json();
|
||||
const token = loginData.access_token;
|
||||
|
||||
// Inject token into localStorage
|
||||
await page.goto(BASE + "/login", { waitUntil: "networkidle" });
|
||||
await page.evaluate(t => {
|
||||
localStorage.setItem("token", t);
|
||||
localStorage.setItem("access_token", t);
|
||||
localStorage.setItem("zj_token", t);
|
||||
}, token);
|
||||
|
||||
const routes = [
|
||||
"/", "/courseware", "/courseware/create", "/animation", "/exercise",
|
||||
"/lesson-plan", "/exam", "/essay-grade", "/mindmap", "/materials",
|
||||
"/resources", "/community", "/classroom", "/assistant", "/profile",
|
||||
"/admin", "/search",
|
||||
];
|
||||
|
||||
for (const route of routes) {
|
||||
const routeErrors = [];
|
||||
page.removeAllListeners("console");
|
||||
page.removeAllListeners("pageerror");
|
||||
page.on("console", msg => { if (msg.type() === "error") routeErrors.push(msg.text()); });
|
||||
page.on("pageerror", err => routeErrors.push(err.message));
|
||||
|
||||
try {
|
||||
await page.goto(BASE + route, { waitUntil: "networkidle", timeout: 15000 });
|
||||
await page.waitForTimeout(1500);
|
||||
|
||||
// Check for empty/blank pages
|
||||
const bodyText = await page.evaluate(() => document.body.innerText.trim());
|
||||
const isEmpty = bodyText.length < 10;
|
||||
const hasRouterView = await page.evaluate(() => {
|
||||
const app = document.querySelector("#app");
|
||||
return app && app.children.length > 0;
|
||||
});
|
||||
|
||||
// Filter expected errors (401/403 for admin views)
|
||||
const realErrors = routeErrors.filter(e =>
|
||||
!e.includes("401") && !e.includes("403") &&
|
||||
!e.includes("Failed to fetch") &&
|
||||
!e.includes("NetworkError")
|
||||
);
|
||||
|
||||
const status = realErrors.length === 0 && !isEmpty && hasRouterView ? "OK" : "CHECK";
|
||||
const errSummary = realErrors.length > 0 ? ` ERR:[${realErrors.slice(0,2).join(" | ").substring(0,100)}]` : "";
|
||||
const emptyFlag = isEmpty ? " BLANK" : "";
|
||||
console.log(`${status} ${route.padEnd(20)} ${bodyText.length}chars${emptyFlag}${errSummary}`);
|
||||
} catch (e) {
|
||||
console.log(`FAIL ${route.padEnd(20)} ${e.message.substring(0, 80)}`);
|
||||
}
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
Reference in New Issue
Block a user