Skip to content

Commit 7176fe4

Browse files
vincentkocKimiyu-186
authored andcommitted
test(ui): settle custodian mobile layout assertions (#116613)
(cherry picked from commit 871abad)
1 parent ddf89b4 commit 7176fe4

1 file changed

Lines changed: 29 additions & 15 deletions

File tree

‎ui/src/e2e/custodian-channel-onboarding.e2e.test.ts‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,35 @@ describeControlUiE2e("Control UI Custodian channel onboarding mocked Gateway E2E
149149
});
150150

151151
await page.setViewportSize({ height: 844, width: 390 });
152-
const mobileNudgeBox = await channelNudge.boundingBox();
153-
const mobileCtaBox = await page
154-
.getByRole("button", { name: "Set up a channel" })
155-
.boundingBox();
156-
expect(mobileNudgeBox).not.toBeNull();
157-
expect(mobileCtaBox).not.toBeNull();
158-
expect(mobileNudgeBox!.x).toBeGreaterThanOrEqual(0);
159-
expect(mobileNudgeBox!.x + mobileNudgeBox!.width).toBeLessThanOrEqual(390);
160-
expect(mobileCtaBox!.x).toBeGreaterThanOrEqual(mobileNudgeBox!.x);
161-
expect(mobileCtaBox!.x + mobileCtaBox!.width).toBeLessThanOrEqual(
162-
mobileNudgeBox!.x + mobileNudgeBox!.width,
163-
);
164-
expect(
165-
await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth),
166-
).toBe(false);
152+
await expect
153+
.poll(() =>
154+
channelNudge.evaluate((nudge) => {
155+
const cta = nudge.querySelector<HTMLElement>(".custodian__nudge-cta");
156+
if (!cta) {
157+
return null;
158+
}
159+
const nudgeBox = nudge.getBoundingClientRect();
160+
const ctaBox = cta.getBoundingClientRect();
161+
return {
162+
ctaVisible: ctaBox.width > 0 && ctaBox.height > 0,
163+
mobileMediaQuery: window.matchMedia("(max-width: 640px)").matches,
164+
noHorizontalOverflow: document.documentElement.scrollWidth <= window.innerWidth,
165+
nudgeVisible: nudgeBox.width > 0 && nudgeBox.height > 0,
166+
nudgeWithinViewport: nudgeBox.left >= 0 && nudgeBox.right <= window.innerWidth,
167+
ctaWithinNudge: ctaBox.left >= nudgeBox.left && ctaBox.right <= nudgeBox.right,
168+
viewportWidth: window.innerWidth,
169+
};
170+
}),
171+
)
172+
.toEqual({
173+
ctaVisible: true,
174+
mobileMediaQuery: true,
175+
noHorizontalOverflow: true,
176+
nudgeVisible: true,
177+
nudgeWithinViewport: true,
178+
ctaWithinNudge: true,
179+
viewportWidth: 390,
180+
});
167181
await page.screenshot({
168182
animations: "disabled",
169183
path: path.join(artifactDir, "02b-after-custodian-channel-nudge-mobile.png"),

0 commit comments

Comments
 (0)