Skip to content

Commit 9050d9b

Browse files
clawsweeperroboclaw-botTakhoffman
authored
fix(ui): align configured automation trigger status (#126784)
Vertically center the configured trigger label with the Advanced heading and cover the rendered geometry in Chromium. Co-authored-by: RoboClaw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent 6132c6f commit 9050d9b

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expectDefined } from "@openclaw/normalization-core";
2+
import { afterEach, describe, expect, it } from "vitest";
3+
import "../../styles/base.css";
4+
import "../../styles/settings.css";
5+
import "../../styles/cron.css";
6+
7+
const hasBrowserLayout = !navigator.userAgent.toLowerCase().includes("jsdom");
8+
const alignmentTolerancePx = 1.25;
9+
10+
afterEach(() => {
11+
document.body.replaceChildren();
12+
});
13+
14+
function centerY(bounds: DOMRect) {
15+
return bounds.top + bounds.height / 2;
16+
}
17+
18+
async function nextFrame() {
19+
await new Promise<void>((resolve) => {
20+
requestAnimationFrame(() => resolve());
21+
});
22+
}
23+
24+
describe.skipIf(!hasBrowserLayout)("cron editor browser layout", () => {
25+
it("vertically centers the configured trigger status with the Advanced heading", async () => {
26+
const details = document.createElement("details");
27+
details.className = "cron-advanced";
28+
details.open = true;
29+
details.innerHTML = `
30+
<summary class="settings-section__heading cron-advanced__summary">Advanced</summary>
31+
`;
32+
document.body.append(details);
33+
34+
const summary = expectDefined(
35+
details.querySelector<HTMLElement>(".cron-advanced__summary"),
36+
"Advanced summary",
37+
);
38+
const heading = document.createRange();
39+
heading.selectNode(expectDefined(summary.firstChild, "Advanced heading text"));
40+
41+
summary.insertAdjacentHTML(
42+
"beforeend",
43+
`
44+
<span class="cron-trigger-summary">
45+
<svg viewBox="0 0 24 24" aria-hidden="true">
46+
<path d="M6 3v12"></path>
47+
<path d="M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"></path>
48+
</svg>
49+
Trigger configured
50+
</span>
51+
`,
52+
);
53+
await nextFrame();
54+
55+
const status = expectDefined(
56+
details.querySelector<HTMLElement>(".cron-trigger-summary"),
57+
"configured trigger status",
58+
);
59+
const headingCenter = centerY(heading.getBoundingClientRect());
60+
const statusCenter = centerY(status.getBoundingClientRect());
61+
62+
expect(Math.abs(statusCenter - headingCenter)).toBeLessThanOrEqual(alignmentTolerancePx);
63+
});
64+
});

‎ui/src/styles/cron.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@
722722
color: var(--accent-2);
723723
font-size: var(--control-ui-text-xs);
724724
font-weight: 600;
725+
vertical-align: middle;
725726
}
726727

727728
.cron-trigger-summary svg {

0 commit comments

Comments
 (0)