完善AMESim组件界面与仿真求解稳定性
This commit is contained in:
1 parent
e7177ab03e
commit
410ef535e8
34 files changed
+3340
-251
No files matched your search
@@ -201,3 +201,108 @@ test("参数表列宽可调整并在刷新后保留", async ({ page }) => {
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await expect(reloadedSeparator).toHaveAttribute("aria-valuenow", "120");
|
||||
});
|
||||
|
||||
test("组件参数公式保留原式,并在说明中显示计算值且 XML 只写数值", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
await addPneumaticTestComponent(page);
|
||||
|
||||
const expression = "3.14*10^2/4";
|
||||
const componentTable = page.getByRole("table", { name: "组件参数" });
|
||||
const pressureRow = parameterRow(componentTable, "参考压力");
|
||||
const pressureInput = page.getByLabel("参考压力", { exact: true });
|
||||
|
||||
await page.getByLabel("参考压力单位").selectOption("kPa");
|
||||
await pressureInput.fill(expression);
|
||||
await pressureInput.press("Enter");
|
||||
|
||||
await expect(pressureInput).toHaveValue(expression);
|
||||
await expect(pressureRow).not.toContainText("78.5");
|
||||
|
||||
await pressureRow.hover();
|
||||
await page.waitForTimeout(600);
|
||||
const preview = page.locator("body > #parameter-help-preview");
|
||||
await expect(preview).toBeVisible();
|
||||
await expect(preview.getByTestId("parameter-calculated-value")).toContainText(
|
||||
"78.5",
|
||||
);
|
||||
await expect(preview.getByTestId("parameter-calculated-value")).toContainText(
|
||||
"kPa",
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "生成系统 XML", exact: true }).click();
|
||||
const consolePanel = page.getByRole("complementary", {
|
||||
name: "仿真控制台",
|
||||
exact: true,
|
||||
});
|
||||
const xmlBlock = consolePanel.getByLabel("生成的系统 XML");
|
||||
await expect(xmlBlock).toContainText(
|
||||
'<Parameter name="reference_pressure" value="78500"',
|
||||
);
|
||||
await expect(xmlBlock).not.toContainText(expression);
|
||||
|
||||
await page.getByRole("button", { name: "保存工程", exact: true }).click();
|
||||
await pressureInput.fill("120");
|
||||
await pressureInput.press("Enter");
|
||||
await page.getByRole("button", { name: "加载工程", exact: true }).click();
|
||||
await page
|
||||
.locator('.flow-canvas .react-flow__node[data-id="amesim_pneumatic_test_1"]')
|
||||
.click();
|
||||
await expect(page.getByLabel("参考压力", { exact: true })).toHaveValue(
|
||||
expression,
|
||||
);
|
||||
});
|
||||
|
||||
test("非法组件参数公式显示错误并阻止 XML 生成", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await addPneumaticTestComponent(page);
|
||||
|
||||
const invalidExpression = "3.14*/4";
|
||||
const componentTable = page.getByRole("table", { name: "组件参数" });
|
||||
const pressureInput = page.getByLabel("参考压力", { exact: true });
|
||||
|
||||
await pressureInput.fill(invalidExpression);
|
||||
await pressureInput.press("Enter");
|
||||
|
||||
await expect(pressureInput).toHaveValue(invalidExpression);
|
||||
await expect(pressureInput).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(
|
||||
componentTable.locator(".parameter-table-message-row .field-error"),
|
||||
).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "生成系统 XML", exact: true }).click();
|
||||
const consolePanel = page.getByRole("complementary", {
|
||||
name: "仿真控制台",
|
||||
exact: true,
|
||||
});
|
||||
await expect(consolePanel).toContainText("XML 生成失败");
|
||||
await expect(consolePanel).toContainText("参考压力");
|
||||
await expect(consolePanel.getByLabel("生成的系统 XML")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("仿真数值设置同样保留公式,并在执行协议中使用计算值", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
|
||||
const expression = "1+2*3";
|
||||
const simulationTable = page.getByRole("table", { name: "仿真设置" });
|
||||
const stopRow = parameterRow(simulationTable, "结束时间");
|
||||
const stopInput = page.getByLabel("结束时间", { exact: true });
|
||||
await stopInput.fill(expression);
|
||||
await stopInput.press("Enter");
|
||||
|
||||
await expect(stopInput).toHaveValue(expression);
|
||||
await expect(stopRow).not.toContainText("7");
|
||||
await stopRow.hover();
|
||||
await page.waitForTimeout(600);
|
||||
await expect(
|
||||
page.getByTestId("parameter-calculated-value"),
|
||||
).toContainText("7 s");
|
||||
|
||||
await page.getByRole("button", { name: "生成系统 XML", exact: true }).click();
|
||||
const xmlBlock = page.getByLabel("生成的系统 XML");
|
||||
await expect(xmlBlock).toContainText('tStop="7"');
|
||||
await expect(xmlBlock).not.toContainText(expression);
|
||||
});
|
||||
Reference in new issue
Block a user