fix(editor): Wait for animated zoom-in transition to settle (#35244)

This commit is contained in:
Nikhil Kuriakose 2026-07-31 14:59:21 +05:30 committed by GitHub
parent 5b314258b5
commit d512f5c8de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,35 +76,40 @@ export class CanvasComposer {
async zoomInAndCheckNodes(): Promise<void> {
await this.n8n.canvas.getCanvasNodes().first().waitFor();
const initialNodeSize = await this.n8n.page.evaluate(() => {
const firstNode = document.querySelector('[data-test-id="canvas-node"]');
if (!firstNode) {
throw new Error('Canvas node not found during initial measurement');
}
return firstNode.getBoundingClientRect().width;
});
const measureFirstNodeWidth = async () =>
await this.n8n.page.evaluate(() => {
const firstNode = document.querySelector('[data-test-id="canvas-node"]');
if (!firstNode) {
throw new Error('Canvas node not found during measurement');
}
return firstNode.getBoundingClientRect().width;
});
// Wait for the animated fit-to-view to settle before capturing the baseline.
let previousWidth = Number.NaN;
await expect
.poll(async () => {
const width = await measureFirstNodeWidth();
const settled = width === previousWidth;
previousWidth = width;
return settled;
})
.toBe(true);
const initialNodeSize = await measureFirstNodeWidth();
for (let i = 0; i < 4; i++) {
await this.n8n.canvas.clickZoomInButton();
}
const finalNodeSize = await this.n8n.page.evaluate(() => {
const firstNode = document.querySelector('[data-test-id="canvas-node"]');
if (!firstNode) {
throw new Error('Canvas node not found during final measurement');
}
return firstNode.getBoundingClientRect().width;
});
// Validate zoom increased node sizes by at least 50%
const zoomWorking = finalNodeSize > initialNodeSize * 1.5;
if (!zoomWorking) {
throw new Error(
"Zoom functionality not working: nodes didn't scale properly. " +
`Initial: ${initialNodeSize.toFixed(1)}px, Final: ${finalNodeSize.toFixed(1)}px`,
);
}
// Poll the width until the animated zoom transition settles.
await expect
.poll(measureFirstNodeWidth, {
message:
"Zoom functionality not working: nodes didn't scale properly. " +
`Initial: ${initialNodeSize.toFixed(1)}px`,
})
.toBeGreaterThan(initialNodeSize * 1.5);
}
/**