chore: establish local platform baseline

This commit is contained in:
Codex Local
2026-08-26 06:41:54 +08:00
commit 29bdf4900f
575 changed files with 95644 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
const path = require("path");
const fs = require("fs");
const root = process.env.PLAYWRIGHT_REQUIRE_FROM;
if (!root) throw new Error("PLAYWRIGHT_REQUIRE_FROM is required");
const { chromium } = require(path.join(root, "playwright"));
const chromePath = process.env.CHROME_PATH || "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
const outputDir = path.resolve(process.env.UI_SCREENSHOT_DIR || "test/e2e/screenshots/operations");
fs.mkdirSync(outputDir, { recursive: true });
(async () => {
const browser = await chromium.launch({ executablePath: chromePath, headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 1100 } });
const failures = [];
page.on("pageerror", (error) => failures.push(`pageerror: ${error.message}`));
page.on("console", (message) => { if (message.type() === "error") failures.push(`console: ${message.text()}`); });
page.on("response", (response) => { if (response.status() >= 400) failures.push(`http ${response.status()}: ${response.url()}`); });
await page.goto("http://localhost:3100", { waitUntil: "networkidle" });
const login = page.getByRole("button", { name: "登录研发环境" });
if (await login.isVisible()) {
await login.click();
await page.locator("#username").fill("owner");
await page.locator("#password").fill("LocalOnly123!");
await page.locator("#kc-login").click();
}
await page.waitForURL("http://localhost:3100/**", { timeout: 15000 });
const workspace = page.getByRole("region", { name: "用量费用与额度工作台" });
await workspace.getByRole("heading", { name: "用量、费用与额度" }).waitFor({ state: "visible", timeout: 10000 });
await workspace.scrollIntoViewIfNeeded();
const overflow = await workspace.evaluate((element) => element.scrollWidth > element.clientWidth + 1);
if (overflow) failures.push("billing workspace has horizontal overflow");
const inputs = await workspace.locator("input, select, textarea, button").count();
if (inputs < 20) failures.push(`billing workspace controls were not rendered: ${inputs}`);
await workspace.screenshot({ path: path.join(outputDir, "ops-billing-workspace.png") });
await browser.close();
if (failures.length) throw new Error(failures.join("\n"));
process.stdout.write(`Billing UI browser smoke passed. Screenshot: ${outputDir}\n`);
})().catch((error) => { process.stderr.write(`${error.stack || error}\n`); process.exitCode = 1; });