|
@@ -9,8 +9,22 @@ const root = path.resolve(__dirname, "../..");
|
|
|
const baseUrl = process.env.BOARD_VIEWER_URL || "http://127.0.0.1:8765";
|
|
const baseUrl = process.env.BOARD_VIEWER_URL || "http://127.0.0.1:8765";
|
|
|
const origin = new URL(baseUrl).origin;
|
|
const origin = new URL(baseUrl).origin;
|
|
|
const artifacts = process.env.BOARD_VIEWER_E2E_ARTIFACTS || path.resolve(process.env.TEMP || root, "board-viewer-e2e");
|
|
const artifacts = process.env.BOARD_VIEWER_E2E_ARTIFACTS || path.resolve(process.env.TEMP || root, "board-viewer-e2e");
|
|
|
-const executablePath = process.env.BOARD_VIEWER_BROWSER || "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
|
|
|
|
|
|
|
+const executablePath = process.env.BOARD_VIEWER_BROWSER || undefined;
|
|
|
|
|
+const launchArgs = String(process.env.BOARD_VIEWER_BROWSER_ARGS || "")
|
|
|
|
|
+ .split(/\s+/)
|
|
|
|
|
+ .filter(Boolean);
|
|
|
|
|
+if (launchArgs.length === 0 && process.platform === "linux") {
|
|
|
|
|
+ launchArgs.push("--disable-gpu", "--disable-dev-shm-usage", "--no-sandbox");
|
|
|
|
|
+}
|
|
|
const boardData = JSON.parse(fs.readFileSync(path.join(root, "tools/board-viewer/generated/board-data.json"), "utf8"));
|
|
const boardData = JSON.parse(fs.readFileSync(path.join(root, "tools/board-viewer/generated/board-data.json"), "utf8"));
|
|
|
|
|
+const candidateExpectation = JSON.parse(
|
|
|
|
|
+ fs.readFileSync(path.join(root, "tests/board_viewer/fixtures/candidate_count_expectation.json"), "utf8"),
|
|
|
|
|
+);
|
|
|
|
|
+const expectedGpioCandidateCount = candidateExpectation.candidate_counts.gpio;
|
|
|
|
|
+const expectedHotspotCount = candidateExpectation.ui_counts?.touchpoints
|
|
|
|
|
+ ?? boardData.touchpoints.length;
|
|
|
|
|
+const expectedPinCount = candidateExpectation.ui_counts?.pins
|
|
|
|
|
+ ?? boardData.touchpoints.reduce((total, touchpoint) => total + (touchpoint.pins?.length ?? 0), 0);
|
|
|
fs.mkdirSync(artifacts, {recursive: true});
|
|
fs.mkdirSync(artifacts, {recursive: true});
|
|
|
|
|
|
|
|
|
|
|
|
@@ -53,7 +67,10 @@ async function createPage(browser, viewport, options = {}) {
|
|
|
await route.continue();
|
|
await route.continue();
|
|
|
});
|
|
});
|
|
|
await page.goto(baseUrl, {waitUntil: "networkidle"});
|
|
await page.goto(baseUrl, {waitUntil: "networkidle"});
|
|
|
- await page.waitForFunction(() => document.querySelectorAll(".hotspot").length === 110);
|
|
|
|
|
|
|
+ await page.waitForFunction(
|
|
|
|
|
+ (count) => document.querySelectorAll(".hotspot").length === count,
|
|
|
|
|
+ expectedHotspotCount,
|
|
|
|
|
+ );
|
|
|
return {context, page, consoleErrors, requestFailures, badResponses};
|
|
return {context, page, consoleErrors, requestFailures, badResponses};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -126,7 +143,7 @@ async function assertRenderedPinPositionsMatchGeneratedData(page) {
|
|
|
const expected = Object.fromEntries(boardData.touchpoints.flatMap((touchpoint) =>
|
|
const expected = Object.fromEntries(boardData.touchpoints.flatMap((touchpoint) =>
|
|
|
touchpoint.pins.map((pin) => [pin.id, pin.view_position]),
|
|
touchpoint.pins.map((pin) => [pin.id, pin.view_position]),
|
|
|
));
|
|
));
|
|
|
- assert.equal(Object.keys(rendered).length, 472);
|
|
|
|
|
|
|
+ assert.equal(Object.keys(rendered).length, expectedPinCount);
|
|
|
assert.deepEqual(Object.keys(rendered).sort(), Object.keys(expected).sort());
|
|
assert.deepEqual(Object.keys(rendered).sort(), Object.keys(expected).sort());
|
|
|
for (const [id, point] of Object.entries(expected)) {
|
|
for (const [id, point] of Object.entries(expected)) {
|
|
|
assert.ok(Math.abs(rendered[id].x - point.x) < 1e-9, `${id} x: ${rendered[id].x} != ${point.x}`);
|
|
assert.ok(Math.abs(rendered[id].x - point.x) < 1e-9, `${id} x: ${rendered[id].x} != ${point.x}`);
|
|
@@ -140,8 +157,8 @@ async function desktopWorkflow(browser, viewport, name) {
|
|
|
const {page} = session;
|
|
const {page} = session;
|
|
|
try {
|
|
try {
|
|
|
await page.getByText("数据已校验", {exact: true}).waitFor();
|
|
await page.getByText("数据已校验", {exact: true}).waitFor();
|
|
|
- assert.equal(await page.locator(".hotspot").count(), 110);
|
|
|
|
|
- assert.equal(await page.locator(".pin-group").count(), 472);
|
|
|
|
|
|
|
+ assert.equal(await page.locator(".hotspot").count(), expectedHotspotCount);
|
|
|
|
|
+ assert.equal(await page.locator(".pin-group").count(), expectedPinCount);
|
|
|
await assertRenderedPinPositionsMatchGeneratedData(page);
|
|
await assertRenderedPinPositionsMatchGeneratedData(page);
|
|
|
assert.equal(await page.locator(".pin-group").first().getAttribute("tabindex"), "-1");
|
|
assert.equal(await page.locator(".pin-group").first().getAttribute("tabindex"), "-1");
|
|
|
assert.equal(await page.locator("#photo-layer").isDisabled(), true);
|
|
assert.equal(await page.locator("#photo-layer").isDisabled(), true);
|
|
@@ -151,44 +168,39 @@ async function desktopWorkflow(browser, viewport, name) {
|
|
|
await assertNoViewportOverflow(page);
|
|
await assertNoViewportOverflow(page);
|
|
|
await page.screenshot({path: path.join(artifacts, `${name}-initial.png`), fullPage: true});
|
|
await page.screenshot({path: path.join(artifacts, `${name}-initial.png`), fullPage: true});
|
|
|
|
|
|
|
|
- const con78 = page.locator('.hotspot[data-reference="CON78"]');
|
|
|
|
|
- const con78Box = await con78.boundingBox();
|
|
|
|
|
- assert.ok(con78Box);
|
|
|
|
|
- const connectorPosition = {x: con78Box.width / 2, y: Math.min(1, con78Box.height / 4)};
|
|
|
|
|
- await con78.hover({position: connectorPosition});
|
|
|
|
|
- await page.getByRole("tooltip").getByText("CON78", {exact: true}).waitFor();
|
|
|
|
|
- await con78.click({position: connectorPosition});
|
|
|
|
|
- await page.locator(".detail-reference").getByText("CON78", {exact: true}).waitFor();
|
|
|
|
|
|
|
+ const con18 = page.locator('.hotspot[data-reference="CON18"]');
|
|
|
|
|
+ const con18Box = await con18.boundingBox();
|
|
|
|
|
+ assert.ok(con18Box);
|
|
|
|
|
+ const connectorPosition = {x: con18Box.width / 2, y: Math.min(1, con18Box.height / 4)};
|
|
|
|
|
+ await con18.hover({position: connectorPosition});
|
|
|
|
|
+ await page.getByRole("tooltip").getByText("CON18", {exact: true}).waitFor();
|
|
|
|
|
+ await con18.click({position: connectorPosition});
|
|
|
|
|
+ await page.locator(".detail-reference").getByText("CON18", {exact: true}).waitFor();
|
|
|
await page.getByText("板正面接触针排列", {exact: true}).waitFor();
|
|
await page.getByText("板正面接触针排列", {exact: true}).waitFor();
|
|
|
await page.getByText("板正面俯视", {exact: false}).waitFor();
|
|
await page.getByText("板正面俯视", {exact: false}).waitFor();
|
|
|
await page.getByText("线缆端或对接面可能是镜像", {exact: false}).waitFor();
|
|
await page.getByText("线缆端或对接面可能是镜像", {exact: false}).waitFor();
|
|
|
- assert.deepEqual(await connectorGrid(page), [["1"], ["2"], ["3"], ["4"]]);
|
|
|
|
|
- assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 4);
|
|
|
|
|
- assert.equal(await page.locator('.pin-row[data-pad-role="shield"]').count(), 2);
|
|
|
|
|
- assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="5"]').getAttribute("data-pad-role"), "shield");
|
|
|
|
|
- await page.getByText("屏蔽固定焊盘", {exact: true}).first().waitFor();
|
|
|
|
|
- await page.getByText("上", {exact: true}).first().waitFor();
|
|
|
|
|
- await page.getByText("下", {exact: true}).first().waitFor();
|
|
|
|
|
-
|
|
|
|
|
- await selectSearchResult(page, "CON31", "CON31");
|
|
|
|
|
- assert.deepEqual(await connectorGrid(page), [["4"], ["3"], ["2"], ["1"]]);
|
|
|
|
|
- await selectSearchResult(page, "CON18", "CON18");
|
|
|
|
|
assert.deepEqual(await connectorGrid(page), [
|
|
assert.deepEqual(await connectorGrid(page), [
|
|
|
["13", "11", "9", "7", "5", "3", "1"],
|
|
["13", "11", "9", "7", "5", "3", "1"],
|
|
|
["14", "12", "10", "8", "6", "4", "2"],
|
|
["14", "12", "10", "8", "6", "4", "2"],
|
|
|
]);
|
|
]);
|
|
|
|
|
+ assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 14);
|
|
|
|
|
+ await page.getByText("上", {exact: true}).first().waitFor();
|
|
|
|
|
+ await page.getByText("下", {exact: true}).first().waitFor();
|
|
|
|
|
+
|
|
|
await selectSearchResult(page, "CON23", "CON23");
|
|
await selectSearchResult(page, "CON23", "CON23");
|
|
|
assert.deepEqual(await connectorGrid(page), [["5", "1"], ["6", "2"], ["7", "3"], ["8", "4"]]);
|
|
assert.deepEqual(await connectorGrid(page), [["5", "1"], ["6", "2"], ["7", "3"], ["8", "4"]]);
|
|
|
|
|
+ await selectSearchResult(page, "CON8", "CON8");
|
|
|
|
|
+ assert.deepEqual(await connectorGrid(page), [["8"], ["7"], ["6"], ["5"], ["4"], ["3"], ["2"], ["1"]]);
|
|
|
|
|
|
|
|
await selectSearchResult(page, "J3", "J3");
|
|
await selectSearchResult(page, "J3", "J3");
|
|
|
await page.getByText("EF2L45BG256B FPGA JTAG 调试/配置接口(专用配置脚)", {exact: true}).waitFor();
|
|
await page.getByText("EF2L45BG256B FPGA JTAG 调试/配置接口(专用配置脚)", {exact: true}).waitFor();
|
|
|
await page.locator(".category-tag").getByText("调试接口", {exact: true}).waitFor();
|
|
await page.locator(".category-tag").getByText("调试接口", {exact: true}).waitFor();
|
|
|
assert.deepEqual(await connectorGrid(page), [
|
|
assert.deepEqual(await connectorGrid(page), [
|
|
|
- ["6", "1"],
|
|
|
|
|
- ["7", "2"],
|
|
|
|
|
- ["8", "3"],
|
|
|
|
|
- ["9", "4"],
|
|
|
|
|
- ["10", "5"],
|
|
|
|
|
|
|
+ ["1", "2"],
|
|
|
|
|
+ ["3", "4"],
|
|
|
|
|
+ ["5", "6"],
|
|
|
|
|
+ ["7", "8"],
|
|
|
|
|
+ ["9", "10"],
|
|
|
]);
|
|
]);
|
|
|
const j3Pin1Primary = await page.locator('.pin-row[data-pin="1"] .pin-primary > span').allTextContents();
|
|
const j3Pin1Primary = await page.locator('.pin-row[data-pin="1"] .pin-primary > span').allTextContents();
|
|
|
assert.match(j3Pin1Primary[0], /TCK/);
|
|
assert.match(j3Pin1Primary[0], /TCK/);
|
|
@@ -228,6 +240,12 @@ async function desktopWorkflow(browser, viewport, name) {
|
|
|
const afterZoom = await page.locator("#board-svg").getAttribute("viewBox");
|
|
const afterZoom = await page.locator("#board-svg").getAttribute("viewBox");
|
|
|
assert.notEqual(afterZoom, beforeZoom);
|
|
assert.notEqual(afterZoom, beforeZoom);
|
|
|
|
|
|
|
|
|
|
+ await selectSearchResult(page, "CON78", "CON78");
|
|
|
|
|
+ assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 4);
|
|
|
|
|
+ assert.equal(await page.locator('.pin-row[data-pad-role="shield"]').count(), 2);
|
|
|
|
|
+ assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="5"]').getAttribute("data-pad-role"), "shield");
|
|
|
|
|
+ await page.getByText("屏蔽固定焊盘", {exact: true}).first().waitFor();
|
|
|
|
|
+
|
|
|
await selectSearchResult(page, "CON78.1", "CON78.1");
|
|
await selectSearchResult(page, "CON78.1", "CON78.1");
|
|
|
assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="1"]').getAttribute("tabindex"), "0");
|
|
assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="1"]').getAttribute("tabindex"), "0");
|
|
|
await page.getByText("U23 TRSF3232EIPWR", {exact: true}).first().waitFor();
|
|
await page.getByText("U23 TRSF3232EIPWR", {exact: true}).first().waitFor();
|
|
@@ -246,38 +264,34 @@ async function desktopWorkflow(browser, viewport, name) {
|
|
|
await groundPin.click();
|
|
await groundPin.click();
|
|
|
assert.ok(await page.locator(".net-highlight").count() > 20);
|
|
assert.ok(await page.locator(".net-highlight").count() > 20);
|
|
|
|
|
|
|
|
- await selectSearchResult(page, "CON30.4", "CON30.4");
|
|
|
|
|
- await page.getByText("MOTOR_EN_N", {exact: false}).first().waitFor();
|
|
|
|
|
- await page.getByText("低电平有效", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("R937 4.7K to +3V3", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("LOCATION = A10", {exact: true}).waitFor();
|
|
|
|
|
|
|
+ await selectSearchResult(page, "CON12.3", "CON12.3");
|
|
|
|
|
+ await page.getByText("FAN_GPIO1", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("LOCATION = A11", {exact: true}).waitFor();
|
|
|
|
|
+ await page.getByText("已验证直连 FPGA GPIO", {exact: false}).first().waitFor();
|
|
|
|
|
|
|
|
await selectSearchResult(page, "CON31.4", "CON31.4");
|
|
await selectSearchResult(page, "CON31.4", "CON31.4");
|
|
|
await page.getByText("开集电极", {exact: false}).first().waitFor();
|
|
await page.getByText("开集电极", {exact: false}).first().waitFor();
|
|
|
await page.getByText("FPGA high", {exact: false}).first().waitFor();
|
|
await page.getByText("FPGA high", {exact: false}).first().waitFor();
|
|
|
await page.getByText("LOCATION = E10", {exact: true}).waitFor();
|
|
await page.getByText("LOCATION = E10", {exact: true}).waitFor();
|
|
|
|
|
|
|
|
- await selectSearchResult(page, "CON58.4", "CON58.4");
|
|
|
|
|
- await page.getByText("上升沿计步脉冲", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("每个上升沿表示一步事件", {exact: false}).first().waitFor();
|
|
|
|
|
-
|
|
|
|
|
- await selectSearchResult(page, "CON65.4", "CON65.4");
|
|
|
|
|
- await page.getByText("状态选择(非有效电平)", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("不存在“高电平有效”的通用含义", {exact: false}).waitFor();
|
|
|
|
|
|
|
+ await selectSearchResult(page, "CON54.1", "CON54.1");
|
|
|
|
|
+ await page.getByText("open-drain", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("开漏", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("LOCATION = B14", {exact: true}).waitFor();
|
|
|
|
|
|
|
|
await selectSearchResult(page, "CON53.1", "CON53.1");
|
|
await selectSearchResult(page, "CON53.1", "CON53.1");
|
|
|
- await page.getByText("open-drain", {exact: false}).waitFor();
|
|
|
|
|
- await page.getByText("只拉低或释放", {exact: false}).waitFor();
|
|
|
|
|
|
|
+ await page.getByText("远端温度二极管", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("不要为 CON53.1 声明 FPGA GPIO", {exact: false}).waitFor();
|
|
|
|
|
|
|
|
await selectSearchResult(page, "CON2.5", "CON2.5");
|
|
await selectSearchResult(page, "CON2.5", "CON2.5");
|
|
|
await page.getByText("板端电源输入", {exact: false}).first().waitFor();
|
|
await page.getByText("板端电源输入", {exact: false}).first().waitFor();
|
|
|
- await page.getByText("CON2.5 +12V_VIN", {exact: true}).waitFor();
|
|
|
|
|
|
|
+ await page.getByText("CON2.5 +12V_VIN", {exact: false}).first().waitFor();
|
|
|
|
|
|
|
|
- await selectSearchResult(page, "TP9.1", "TP9.1");
|
|
|
|
|
- await page.locator(".pin-detail .detail-facts").getByText("GD32F303CGT6 U27", {exact: true}).waitFor();
|
|
|
|
|
- await page.locator(".pin-detail .detail-facts").getByText("U27.10 (PA0)", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("MCU 固件用法", {exact: true}).waitFor();
|
|
|
|
|
- await page.getByText("不要在 FPGA RTL/ADC 中声明此针", {exact: false}).waitFor();
|
|
|
|
|
|
|
+ await selectSearchResult(page, "J25.2", "J25.2");
|
|
|
|
|
+ await page.getByText("GD32F303CGT6", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("SWCLK", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("U27.37", {exact: false}).first().waitFor();
|
|
|
|
|
+ await page.getByText("不对应 FPGA RTL 或 ADC", {exact: false}).waitFor();
|
|
|
|
|
|
|
|
await page.locator("#candidate-tab").click();
|
|
await page.locator("#candidate-tab").click();
|
|
|
await page.locator("#capability-select").selectOption("pwm");
|
|
await page.locator("#capability-select").selectOption("pwm");
|
|
@@ -285,7 +299,7 @@ async function desktopWorkflow(browser, viewport, name) {
|
|
|
await pwmCandidate.locator(".candidate-key").getByText("CON31.4 · E10", {exact: true}).waitFor();
|
|
await pwmCandidate.locator(".candidate-key").getByText("CON31.4 · E10", {exact: true}).waitFor();
|
|
|
await pwmCandidate.getByText("FPGA high -> Q105", {exact: false}).waitFor();
|
|
await pwmCandidate.getByText("FPGA high -> Q105", {exact: false}).waitFor();
|
|
|
await page.locator("#capability-select").selectOption("gpio");
|
|
await page.locator("#capability-select").selectOption("gpio");
|
|
|
- assert.equal(await page.locator(".candidate-row").count(), 33);
|
|
|
|
|
|
|
+ assert.equal(await page.locator(".candidate-row").count(), expectedGpioCandidateCount);
|
|
|
assert.equal(await page.locator(".candidate-row").filter({hasText: "CON31.4"}).count(), 0);
|
|
assert.equal(await page.locator(".candidate-row").filter({hasText: "CON31.4"}).count(), 0);
|
|
|
await page.locator("#capability-select").selectOption("uart_tx");
|
|
await page.locator("#capability-select").selectOption("uart_tx");
|
|
|
await page.getByText("没有满足全部证据条件的候选", {exact: true}).waitFor();
|
|
await page.getByText("没有满足全部证据条件的候选", {exact: true}).waitFor();
|
|
@@ -377,10 +391,12 @@ async function staleWorkflow(browser) {
|
|
|
|
|
|
|
|
|
|
|
|
|
(async () => {
|
|
(async () => {
|
|
|
- const browser = await chromium.launch({headless: true, executablePath});
|
|
|
|
|
|
|
+ const launchOptions = {headless: true, args: launchArgs};
|
|
|
|
|
+ if (executablePath) launchOptions.executablePath = executablePath;
|
|
|
|
|
+ const browser = await chromium.launch(launchOptions);
|
|
|
try {
|
|
try {
|
|
|
await desktopWorkflow(browser, {width: 1920, height: 1080}, "1920x1080");
|
|
await desktopWorkflow(browser, {width: 1920, height: 1080}, "1920x1080");
|
|
|
- await desktopWorkflow(browser, {width: 1366, height: 768}, "1366x768");
|
|
|
|
|
|
|
+ await desktopWorkflow(browser, {width: 1912, height: 948}, "1912x948");
|
|
|
await mobileWorkflow(browser);
|
|
await mobileWorkflow(browser);
|
|
|
await adcCopyWorkflow(browser);
|
|
await adcCopyWorkflow(browser);
|
|
|
await staleWorkflow(browser);
|
|
await staleWorkflow(browser);
|