🐛 Fix move scrollbar create a selection rectangle

This commit is contained in:
Eva Marco 2024-06-12 12:02:12 +02:00 committed by Alejandro Alonso
parent 09a671cffa
commit 232cfea709
7 changed files with 46 additions and 6 deletions

View file

@ -51,6 +51,8 @@ export class WorkspacePage extends BaseWebSocketPage {
this.palette = page.getByTestId("palette");
this.sidebar = page.getByTestId("left-sidebar");
this.librariesModal = page.getByTestId("libraries-modal");
this.selectionRect = page.getByTestId("workspace-selection-rect");
this.horizontalScrollbar = page.getByTestId("horizontal-scrollbar");
}
async goToWorkspace({ fileId = WorkspacePage.anyFileId, pageId = WorkspacePage.anyPageId } = {}) {
@ -102,6 +104,14 @@ export class WorkspacePage extends BaseWebSocketPage {
await this.page.mouse.up();
}
async panOnViewportAt(x, y, width, height) {
await this.page.waitForTimeout(100);
await this.viewport.hover({ position: { x, y } });
await this.page.mouse.down({ button: "middle" });
await this.viewport.hover({ position: { x: x + width, y: y + height } });
await this.page.mouse.up({ button: "middle" });
}
async togglePages() {
const pagesToggle = this.page.getByText("Pages");
await pagesToggle.click();

View file

@ -16,8 +16,6 @@ test.describe("Layers tab", () => {
await workspace.togglePages();
const { height: heightCollapsed } = await workspace.layers.boundingBox();
console.log(heightExpanded, heightCollapsed);
expect(heightExpanded > heightCollapsed);
});
});

View file

@ -64,3 +64,31 @@ test("Bug 7654 - Toolbar keeps toggling on and off on spacebar press", async ({
await workspacePage.page.keyboard.press("Enter");
await workspacePage.expectHiddenToolbarOptions();
});
test("Bug 7525 - User moves a scrollbar and no selciont rectangle appears", async ({ page }) => {
const workspacePage = new WorkspacePage(page);
await workspacePage.setupEmptyFile();
await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-not-empty.json");
await workspacePage.mockRPC("update-file?id=*", "workspace/update-file-create-rect.json");
await workspacePage.goToWorkspace({
fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374",
pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375",
});
// Move created rect to a corner, in orther to get scrollbars
await workspacePage.panOnViewportAt(128, 128, 300, 300);
// Check scrollbars appear
const horizontalScrollbar = workspacePage.horizontalScrollbar;
await expect(horizontalScrollbar).toBeVisible();
// Grab scrollbar and move
const {x, y} = await horizontalScrollbar.boundingBox();
await page.waitForTimeout(100);
await workspacePage.viewport.hover({ position: { x: x, y: y + 5 } });
await page.mouse.down();
await workspacePage.viewport.hover({ position: { x: x - 130, y: y - 95 } });
await expect(workspacePage.selectionRect).not.toBeInViewport();
});