Skip to content

test(e2e): verify real venue controls - #10

Merged
TN019 merged 13 commits into
mainfrom
test/real-venue-controls
Dec 1, 2026
Merged

TN019 merged 13 commits into
mainfrom
test/real-venue-controls

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

The power and network buttons had only been checked against a fake Docker API. They need an end-to-end check against real containers and a real hub, and the page should show a failed Docker action instead of swallowing it.

What changed

  • scripts/real-controls.mjs: connects to the bridge WebSocket and, against a running entrance, unplugs Gate 2 and checks with docker inspect that it left gatepost-sim-devices_venue, scans GP-000000000020 and requires a local green decision with the network LED off, and asserts that the hub logs never show that scan. It then plugs Gate 2 back in, scans fresh tickets until the network LED comes back on (dumping gate, hub and bridge logs if it does not), cuts and restores Gate 3's power, waits for its device connections, and requires no bridge errors.
  • scripts/e2e-gatepost.sh controls: refuses to run while an entrance is active, starts one with GATEPOST_REF, runs real-controls.mjs, shuts it down, and fails if any container remains.
  • scripts/hub-proxy.py prints each forwarded request, which the controls check reads from the hub logs.
  • Make scripts/bridge-entrypoint.sh executable so the image ENTRYPOINT can start.
  • e2e/entrance.spec.ts: with fake gates there is no Compose container, so Cut power must show an Error: alert while the lane still offers Cut power.
  • web/src/main.tsx: the header shows Docker: available, unavailable or checking with the full message as a tooltip, next to the bridge state; the e2e test checks the short text.
  • READMEs: document the controls mode, the entrypoint's socket group handling, the docker field in snapshots, and how to choose the Gate 3 revisions for scripts/screenshots.sh.

How to verify

pnpm test
pnpm build
PORT=28080 DEVICE_PORT=7600 node bridge/dist/server.js &
node scripts/fake-gates.mjs &
pnpm test:e2e

With Docker and a Gatepost checkout at ../gatepost that has the hub client:

GATEPOST_REF=main scripts/e2e-gatepost.sh controls

The script prints a PASS line for each step, ending with PASS no bridge action errors, and exits non-zero if any container is left.


背景

电源和网络按钮之前只针对模拟的 Docker API 测过,需要对真实容器和真实 hub 做一次端到端检查;页面也应该把失败的 Docker 操作显示出来,而不是悄无声息。

改动

  • scripts/real-controls.mjs:连接 bridge 的 WebSocket,针对运行中的入口执行:拔掉 Gate 2 的网线,并用 docker inspect 确认它已离开 gatepost-sim-devices_venue;扫 GP-000000000020,要求网络灯熄灭时由闸机在本地给出绿灯;并断言 hub 日志里没有出现这次扫码。随后重新接入 Gate 2,换新票连续扫码,直到网络灯重新亮起(一直不亮就输出闸机、hub 和 bridge 的日志);接着切断再恢复 Gate 3 的电源,等它的设备连接恢复;最后要求 bridge 没有报错。
  • scripts/e2e-gatepost.sh controls:已有入口在运行时拒绝执行;否则用 GATEPOST_REF 启动入口,运行 real-controls.mjs,关闭入口,如有容器残留则报错。
  • scripts/hub-proxy.py 打印每一条转发的请求,controls 检查就是从 hub 日志里读这些内容。
  • 给 scripts/bridge-entrypoint.sh 加上可执行权限,镜像的 ENTRYPOINT 才能启动。
  • e2e/entrance.spec.ts:用假闸机时没有 Compose 容器,所以点击 Cut power 后必须出现含 Error: 的提示,而通道上仍显示 Cut power。
  • web/src/main.tsx:页头在 bridge 状态旁显示 Docker: available、unavailable 或 checking,完整信息放在悬停提示里;e2e 测试检查这段简短文字。
  • README:补充 controls 模式、入口脚本如何处理 socket 的组、快照中的 docker 字段,以及如何为 scripts/screenshots.sh 选择 Gate 3 的两个版本。

怎么验证

pnpm test
pnpm build
PORT=28080 DEVICE_PORT=7600 node bridge/dist/server.js &
node scripts/fake-gates.mjs &
pnpm test:e2e

安装 Docker,并在 ../gatepost 准备带 hub 客户端的 Gatepost 检出:

GATEPOST_REF=main scripts/e2e-gatepost.sh controls

脚本每完成一步打印一行 PASS,最后一行是 PASS no bridge action errors;如有容器残留,以非零状态退出。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Yuki Tanaka · reviewer

The offline step asserts the hub never saw SCAN GP-000000000020. Where does that line come from?


离线那一步断言 hub 从没收到 SCAN GP-000000000020。这行内容是从哪里来的?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

From hub-proxy.py, which now prints every request it forwards. The script takes the hub container's logs before the scan and checks that the new part does not contain it.


来自 hub-proxy.py,它现在会打印转发的每条请求。脚本在扫码前记下 hub 容器的日志,再检查之后新增的部分里没有这一行。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · reviewer

In the fake-gate run, is the alert assertion relying on Cut power having no container to act on?


在假闸机的测试里,那条提示的断言是不是依赖 Cut power 找不到可操作的容器?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

Yes. Without the Compose project the power action fails, either because no container matches or because no Docker socket is reachable. Either way the bridge sends an error message, and the test checks that it reaches the page's alert.


是的。没有 Compose 项目时,电源操作一定会失败:要么找不到匹配的容器,要么连不上 Docker socket。无论哪种情况,bridge 都会发送 error 消息,测试检查这条消息确实显示在页面的提示里。

@TN019
TN019 merged commit d430d35 into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the test/real-venue-controls branch December 1, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant