The viewport label was already wired to interface.showViewName; unhide the toggle and verify it shows/hides the view name. Co-Authored-By: Claude Code <noreply@anthropic.com>
45 lines
2.2 KiB
JavaScript
45 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Focused case: toggle Interface -> 显示视图名称 and observe the viewport label.
|
|
*
|
|
* node tools/web/complete/probe-viewname-preference.mjs --base-url http://127.0.0.1:5176
|
|
*/
|
|
import { ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene } from "../course/lib/lesson-recorder.mjs";
|
|
|
|
const args = parseArgs();
|
|
const BASE = args.baseUrl || "http://127.0.0.1:5176";
|
|
const browser = await launchBrowser(args.gpu);
|
|
const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE });
|
|
page.setDefaultTimeout(60_000);
|
|
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
|
const label = async () => page.evaluate(() => Array.from(document.querySelectorAll('.viewport-view-label')).map((node) => node.textContent));
|
|
const openPrefs = async () => {
|
|
await page.getByRole("button", { name: "编辑", exact: true }).click();
|
|
await page.getByRole("menuitem", { name: "偏好设置", exact: true }).click();
|
|
await page.getByRole("dialog", { name: "Web Blender 偏好设置" }).waitFor({ timeout: 30_000 });
|
|
};
|
|
try {
|
|
await openFile(page, ASSETS.studio);
|
|
await waitScene(page, { objects: 6, timeout: 240_000 });
|
|
log("before", JSON.stringify(await label()));
|
|
await openPrefs();
|
|
const checkbox = page.getByRole("checkbox", { name: "显示视图名称", exact: true });
|
|
await checkbox.waitFor({ timeout: 30_000 });
|
|
log("checkbox", JSON.stringify({ checked: await checkbox.isChecked(), disabled: await checkbox.isDisabled() }));
|
|
await checkbox.uncheck();
|
|
await page.getByRole("button", { name: "关闭偏好设置", exact: true }).click();
|
|
await page.waitForTimeout(800);
|
|
log("unchecked", JSON.stringify(await label()));
|
|
await openPrefs();
|
|
await page.getByRole("checkbox", { name: "显示视图名称", exact: true }).check();
|
|
await page.getByRole("button", { name: "关闭偏好设置", exact: true }).click();
|
|
await page.waitForTimeout(800);
|
|
log("checked", JSON.stringify(await label()));
|
|
} catch (error) {
|
|
log("probe error", error instanceof Error ? error.message : String(error));
|
|
} finally {
|
|
log("consoleErrors", JSON.stringify(consoleErrors.slice(-8)));
|
|
await context.close();
|
|
await browser.close();
|
|
}
|