mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 13:39:44 +02:00
fix(editor): Wait for animated zoom-in transition to settle (#35244)
This commit is contained in:
parent
5b314258b5
commit
d512f5c8de
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user