Fix Devii open-trigger race and close two flaky e2e waits
DevPlace CI / test (push) Failing after 1h30m15s

DeviiTerminal bound [data-devii-open] click listeners only after the
async /devii/session fetch resolved, silently dropping early clicks.
Switch to a single delegated document listener bound in the
constructor, matching the ModalManager/dp-lightbox pattern.

The steal-confirm and comment-vote e2e tests asserted DOM state right
after a click with no wait for the triggering POST to land, racing the
server under CI load. Wrap those clicks in page.expect_response.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-16 02:02:34 +02:00
co-authored by Claude Sonnet 5
parent fa8751a4ca
commit 8db0efff29
3 changed files with 19 additions and 10 deletions
+11 -7
View File
@@ -10,6 +10,7 @@ export class DeviiTerminal {
this.avatar = null;
this.bindEscapeTrigger();
this.bindDoubleClickTrigger();
this.bindOpenTrigger();
this.ready = this.init();
}
@@ -29,16 +30,19 @@ export class DeviiTerminal {
this.element.setAttribute("avatar", "devii");
document.body.appendChild(this.element);
this.bindTriggers();
this.maybeAutoOpen();
}
bindTriggers() {
document.querySelectorAll("[data-devii-open]").forEach((trigger) => {
trigger.addEventListener("click", (event) => {
event.preventDefault();
this.open(trigger.dataset.deviiPrompt || "");
});
bindOpenTrigger() {
document.addEventListener("click", (event) => {
const trigger = event.target.closest("[data-devii-open]");
if (!trigger) return;
event.preventDefault();
this.open(trigger.dataset.deviiPrompt || "");
});
}
maybeAutoOpen() {
const stored = this.element && this.element.hasStoredState && this.element.hasStoredState();
if (document.querySelector("[data-devii-autoopen]") && !stored) {
this.open();