Skip to content

fix(e2e): wait for clean gates before admission rounds - #15

Merged
TN019 merged 16 commits into
mainfrom
fix/clean-gates-before-rounds
Dec 1, 2026
Merged

TN019 merged 16 commits into
mainfrom
fix/clean-gates-before-rounds

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

The double-admission rounds started while lights and turnstiles from the previous round could still be active, so a round could be judged on leftover state, and the screenshot could catch the gates after they had already reset.

What changed

  • e2e/real-double-admission.spec.ts: before every round, wait up to 10 seconds until all four gates have their light off and their turnstile locked. Before the before-fix screenshot, wait until Gate 1 and Gate 2 are both green and open; before the fixed screenshot, wait until one is green and open and the other red and locked. Raise the test timeout to 12 minutes for the 200-try worst case.
  • scripts/screenshots.sh: SCREENSHOT_PAIRS=double-admission captures only the two double-admission pairs and needs only their two refs; the default all still requires every ref.
  • Retake the four double-admission PNGs and update the screenshot table: the before-fix pair caught the double admission on try 51, and the fixed pair shows Gate 1 green and open with Gate 2 red and locked after 30 tries.

How to verify

With Docker and a Gatepost checkout:

SCREENSHOT_PAIRS=double-admission GATEPOST_DIR=../gatepost \
DOUBLE_ADMISSION_BEFORE_REF=<before-fix-rev> DOUBLE_ADMISSION_FIXED_REF=<fixed-rev> \
scripts/screenshots.sh

The script ends with double-admission screenshot pairs captured; no gatepost-sim-devices containers remain.


背景

双闸机放行的每一轮在开始时,上一轮的指示灯和转闸可能还没复位,于是某一轮可能是按残留状态判定的;截图也可能拍到闸机已经复位之后的画面。

改动

  • e2e/real-double-admission.spec.ts:每轮开始前最多等待 10 秒,直到四台闸机的灯全部熄灭、转闸全部锁定。拍修复前截图之前,等 Gate 1 和 Gate 2 都亮绿灯且转闸打开;拍修复后截图之前,等一台绿灯打开、另一台红灯锁定。为应对最多 200 次尝试的情况,测试超时提高到 12 分钟。
  • scripts/screenshots.sh:设置 SCREENSHOT_PAIRS=double-admission 时只拍两对双闸机截图,也只需要这两个版本变量;默认的 all 仍要求设置全部版本。
  • 重拍四张双闸机截图并更新截图表格:修复前的一对在第 51 次尝试时拍到重复放行;修复后的一对在 30 次尝试后显示 Gate 1 绿灯打开、Gate 2 红灯锁定。

怎么验证

安装 Docker 并准备 Gatepost 检出:

SCREENSHOT_PAIRS=double-admission GATEPOST_DIR=../gatepost \
DOUBLE_ADMISSION_BEFORE_REF=<before-fix-rev> DOUBLE_ADMISSION_FIXED_REF=<fixed-rev> \
scripts/screenshots.sh

脚本最后输出 double-admission screenshot pairs captured; no gatepost-sim-devices containers remain.

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Mateo Rossi · reviewer

relayUntil is a bridge timestamp, compared here with the browser's Date.now(). Is that safe?


relayUntil 是 bridge 的时间戳,这里却和浏览器的 Date.now() 比较,这样稳妥吗?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

It is the same comparison the lane uses to draw the turnstile (relayUntil > Date.now()), so the test waits for what the page shows as locked. The light must also be OFF before a round starts.


通道绘制转闸时用的就是同样的比较(relayUntil > Date.now()),所以测试等待的正是页面上显示为锁定的状态。另外,每轮开始前还要求灯已经是 OFF。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ben Carter · reviewer

The table says the race showed on try 51. Will that number hold?


表格里写竞态出现在第 51 次尝试。这个数字会一直不变吗?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

No, it varies from run to run; the table records this capture. The spec allows up to 200 tries and fails if no try admits at both gates.


不会,每次运行都不一样,表格记的是这一次截图的情况。用例最多允许 200 次尝试,如果没有一次两台都放行,就会失败。

@TN019
TN019 merged commit f679e16 into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the fix/clean-gates-before-rounds branch December 1, 2026 00:16
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