规范仿真模型库并完善前端交互

归档仿真模型并补充组件目录、建模规范与校验。

完善控制台、默认节点、视图适配及前端自动化测试。
This commit is contained in:
ljz committed 2026-07-29 15:44:16 +08:00
1 parent f7f1078911
commit bbc88a6bbb
71 files changed
+4574 -806

No files matched your search

@@ -0,0 +1,46 @@
import { expect, test } from "@playwright/test";
import { prepareApp } from "./fixtures";
test.beforeEach(async ({ page }) => {
await prepareApp(page);
});
test("未知图形元件使用带端口和名称的默认节点,并将动作结果写入控制台", async ({
page,
}) => {
await page.goto("/");
const paletteItem = page.getByRole("button", { name: /通用测试元件/ });
await expect(paletteItem).toBeVisible();
await paletteItem.dragTo(page.locator(".flow-canvas .react-flow__pane"));
const node = page.locator('.flow-canvas .react-flow__node[data-id="generic_sensor_1"]');
await expect(node).toBeVisible();
await expect(node.locator(".sim-node")).toHaveClass(/generic-component/);
await expect(node.locator(".node-symbol-anchor")).toHaveCount(0);
await expect(node.locator(".node-label")).toHaveText("generic_sensor_1");
await expect(node.locator(".port-handle")).toHaveCount(2);
const consolePanel = page.getByRole("complementary", {
name: "仿真控制台",
exact: true,
});
await expect(consolePanel).not.toHaveClass(/has-unread/);
await expect(consolePanel.locator(".simulation-console-unread")).toHaveCount(0);
await expect(consolePanel).not.toContainText("已添加组件");
await page.getByRole("button", { name: "生成系统 XML" }).click();
await expect(consolePanel).toContainText("XML 已生成");
const xmlBlock = consolePanel.getByLabel("生成的系统 XML");
await expect(xmlBlock).toBeVisible();
await expect(xmlBlock).toContainText('<?xml version="1.0" encoding="UTF-8"?>');
await expect(xmlBlock).toContainText('<Component id="generic_sensor_1"');
await expect(page.locator(".properties .xml-output")).toHaveCount(0);
await expect(page.locator(".properties")).not.toContainText("系统 XML");
await page.getByRole("button", { name: "检查模型" }).click();
await expect(consolePanel).toContainText(/模型检查/);
await expect(page.locator(".status-strip")).toHaveCount(0);
await expect(page.locator(".validation-section")).toHaveCount(0);
await expect(page.locator(".properties")).not.toContainText("仿真结果");
});