C内核流量计算方法优化,前端文件名称读取优化
This commit is contained in:
1 parent
5d5a2e1843
commit
808c484f5b
94 files changed
+20163
-4418
No files matched your search
@@ -211,6 +211,114 @@ test.beforeEach(async ({ page }) => {
|
||||
}, chartWindowSnapshot);
|
||||
});
|
||||
|
||||
for (const quantity of ["pressure", "absolute_pressure"]) {
|
||||
for (const kind of ["single", "multi", "mixed"] as const) {
|
||||
test(`${quantity} 的 ${kind} 图默认 Pa,绝压换算及单位持久化不改变原始数据`, async ({ page }) => {
|
||||
await page.addInitScript(({ snapshot, pressureQuantity }) => {
|
||||
const pressure = snapshot.result.variables.find(
|
||||
(variable) => variable.key === "generic_sensor_1.pressure",
|
||||
);
|
||||
if (pressure) pressure.quantity = pressureQuantity;
|
||||
window.sessionStorage.setItem(
|
||||
"system-simulation-flow:latest-result",
|
||||
JSON.stringify(snapshot),
|
||||
);
|
||||
}, { snapshot: chartWindowSnapshot, pressureQuantity: quantity });
|
||||
await page.goto("/");
|
||||
await openResults(page);
|
||||
|
||||
const pressureVariable = page
|
||||
.locator(".results-variable-list button")
|
||||
.filter({ hasText: "压力" })
|
||||
.first();
|
||||
await expect(pressureVariable.locator("small")).toHaveText("Pa");
|
||||
const chartWindow = page.locator(
|
||||
`.result-chart-window[data-chart-kind="${kind}"]`,
|
||||
);
|
||||
if (kind === "single") {
|
||||
await pressureVariable.click();
|
||||
} else {
|
||||
await page.getByRole("button", {
|
||||
name: kind === "multi" ? "新建同单位多曲线对比窗口" : "新建异单位上下对比窗口",
|
||||
exact: true,
|
||||
}).click();
|
||||
if (kind === "mixed") {
|
||||
await page.locator(".results-variable-list button")
|
||||
.filter({ hasText: "数值" }).first().dragTo(chartWindow);
|
||||
}
|
||||
await pressureVariable.dragTo(chartWindow);
|
||||
}
|
||||
const chart = chartWindow.locator('svg[data-result-chart="true"]');
|
||||
const unitSelect = chartWindow.getByRole("combobox", {
|
||||
name: kind === "mixed"
|
||||
? "generic_sensor_1.pressure纵轴单位"
|
||||
: kind === "multi" ? "多曲线纵轴单位" : "压力纵轴单位",
|
||||
exact: true,
|
||||
});
|
||||
const showUnits = async () => {
|
||||
if (kind === "mixed") {
|
||||
await chartWindow.getByRole("button", {
|
||||
name: "管理多曲线窗口中的曲线", exact: true,
|
||||
}).click();
|
||||
}
|
||||
};
|
||||
const readPressureRange = () => chart.evaluate((element) => {
|
||||
const ranges = element.getAttribute("data-view-y-ranges");
|
||||
return ranges
|
||||
? JSON.parse(ranges)["generic_sensor_1.pressure"] as number[]
|
||||
: [
|
||||
Number(element.getAttribute("data-view-y-min")),
|
||||
Number(element.getAttribute("data-view-y-max")),
|
||||
];
|
||||
});
|
||||
await showUnits();
|
||||
await expect(unitSelect).toHaveValue("Pa");
|
||||
await expect(unitSelect.locator('option[value="barA"]')).toHaveCount(0);
|
||||
await expect(chart.locator(".result-chart-unit")).toContainText(["Pa"]);
|
||||
const pascalRange = await readPressureRange();
|
||||
expect(pascalRange[0]).toBeCloseTo(98400, 6);
|
||||
expect(pascalRange[1]).toBeCloseTo(121600, 6);
|
||||
|
||||
await unitSelect.selectOption("bar");
|
||||
await expect(unitSelect).toHaveValue("bar");
|
||||
const barRange = await readPressureRange();
|
||||
expect(barRange[0]).toBeCloseTo(0.984, 6);
|
||||
expect(barRange[1]).toBeCloseTo(1.216, 6);
|
||||
if (kind === "multi") {
|
||||
await expect(chartWindow.locator(".result-chart-window-title")).toContainText("bar");
|
||||
await chartWindow.getByRole("button", {
|
||||
name: "管理多曲线窗口中的曲线", exact: true,
|
||||
}).click();
|
||||
await expect(chartWindow.locator(".result-chart-multi-menu-label small")).toContainText("bar");
|
||||
}
|
||||
|
||||
const storedPressure = await page.evaluate(() => {
|
||||
const snapshot = JSON.parse(sessionStorage.getItem(
|
||||
"system-simulation-flow:latest-result",
|
||||
) ?? "null");
|
||||
return {
|
||||
values: snapshot.result.series["generic_sensor_1.pressure"],
|
||||
final: snapshot.result.final["generic_sensor_1.pressure"],
|
||||
unit: snapshot.result.variables.find(
|
||||
(variable: { key: string }) => variable.key === "generic_sensor_1.pressure",
|
||||
).unit,
|
||||
};
|
||||
});
|
||||
expect(storedPressure).toEqual({
|
||||
values: [100000, 110000, 120000], final: 120000, unit: "Pa",
|
||||
});
|
||||
|
||||
await page.reload();
|
||||
await openResults(page);
|
||||
await showUnits();
|
||||
await expect(unitSelect).toHaveValue("bar");
|
||||
expect(await readPressureRange()).toEqual(barRange);
|
||||
await unitSelect.selectOption("Pa");
|
||||
expect(await readPressureRange()).toEqual(pascalRange);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test("机械状态事件力点不参与连续曲线纵轴,但原始数据与非力状态保持不变", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in new issue
Block a user