Replace Python numerical kernels with native C execution
This commit is contained in:
1 parent
48da6be21c
commit
3b38f73fe0
227 files changed
+16801
-75499
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { expandSimulationConsole, prepareApp, resultSnapshot, wideProject } from "./fixtures";
|
||||
|
||||
for (const diagnosticsMode of ["native", "legacy-native", "python"] as const) {
|
||||
test(`completed ${diagnosticsMode} results can be published and restored`, async ({ page }) => {
|
||||
await prepareApp(page);
|
||||
const diagnostics = diagnosticsMode === "python"
|
||||
? resultSnapshot.result.diagnostics
|
||||
: { backend: "native-c", stateCount: 1,
|
||||
...(diagnosticsMode === "native" ? { sampleCount: 3 } : {}) };
|
||||
await page.route("**/api/system-xml/simulate-stream", route => route.fulfill({
|
||||
contentType: "application/x-ndjson",
|
||||
body: JSON.stringify({ event: "result", progress: 100, phase: "completed",
|
||||
result: { ...resultSnapshot.result, diagnostics } }) + "\n",
|
||||
}));
|
||||
await page.goto("/");
|
||||
await page.locator('input[type="file"]').setInputFiles({
|
||||
name: "native-result.json", mimeType: "application/json",
|
||||
buffer: Buffer.from(JSON.stringify({ ...wideProject, edges: [...wideProject.edges, {
|
||||
id: "close-test-loop", source: "generic_sensor_4", target: "generic_sensor_1",
|
||||
sourceHandle: "port_b", targetHandle: "port_a", data: { isContactEdge: false },
|
||||
}] })),
|
||||
});
|
||||
await expect(page.getByRole("textbox", { name: "工程", exact: true })).toHaveValue(wideProject.name);
|
||||
await page.getByRole("button", { name: "运行仿真", exact: true }).click();
|
||||
await expandSimulationConsole(page);
|
||||
const consolePanel = page.getByRole("complementary", { name: "仿真控制台", exact: true });
|
||||
await expect(consolePanel).toContainText("仿真完成,已生成新的结果,共 3 个采样点");
|
||||
await expect(consolePanel).not.toContainText("仿真失败");
|
||||
if (diagnosticsMode === "python") {
|
||||
await expect(consolePanel).toContainText("最大方程残差 0");
|
||||
} else {
|
||||
await expect(consolePanel).not.toContainText("最大方程残差");
|
||||
}
|
||||
const saved = await page.evaluate(() => JSON.parse(sessionStorage.getItem("system-simulation-flow:latest-result") ?? "null"));
|
||||
expect(saved.result.diagnostics.sampleCount).toBe(3);
|
||||
expect(saved.result.series).toEqual(resultSnapshot.result.series);
|
||||
await page.reload();
|
||||
await page.getByRole("tab", { name: "结果", exact: true }).click();
|
||||
await expect(page.getByText("3 个采样点", { exact: false }).first()).toBeVisible();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user