mirror of
https://github.com/maputnik/editor.git
synced 2026-08-29 16:37:25 +00:00
Adopted changes to have a sidebar that's dragable
This commit is contained in:
@@ -122,6 +122,8 @@ export class Assertable<T> {
|
||||
// Value assertions (auto-retrying for Query targets).
|
||||
shouldEqual = (value: any) => this.assertValue((actual) => expect(actual).toBe(value));
|
||||
|
||||
shouldBeGreaterThan = (value: number) => this.assertValue((actual) => expect(actual).toBeGreaterThan(value));
|
||||
|
||||
shouldInclude = (value: any) =>
|
||||
this.assertValue((actual) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
@@ -349,6 +351,15 @@ export class PlaywrightHelper {
|
||||
await this.page.mouse.up();
|
||||
},
|
||||
|
||||
/** Presses at the centre of an element and drags it by the given offset. */
|
||||
dragBy: async (testId: string, deltaX: number, deltaY = 0) => {
|
||||
const { x, y } = await centerOf(this.testId(testId));
|
||||
await this.page.mouse.move(x, y);
|
||||
await this.page.mouse.down();
|
||||
await this.page.mouse.move(x + deltaX, y + deltaY, { steps: 10 });
|
||||
await this.page.mouse.up();
|
||||
},
|
||||
|
||||
clickCenter: async (testId: string) => {
|
||||
const { x, y } = await centerOf(this.testId(testId));
|
||||
await this.page.mouse.move(x, y);
|
||||
@@ -446,6 +457,13 @@ export class PlaywrightHelper {
|
||||
|
||||
inputValue: (testId: string) => new Query<string>(() => this.testId(testId).first().inputValue()),
|
||||
|
||||
elementWidth: (testId: string) =>
|
||||
new Query<number>(async () => {
|
||||
const box = await this.testId(testId).first().boundingBox();
|
||||
if (!box) throw new Error(`Element "${testId}" has no bounding box`);
|
||||
return box.width;
|
||||
}),
|
||||
|
||||
elementsText: (testId: string) => new Query<string>(() => this.testId(testId).first().innerText()),
|
||||
|
||||
locationHash: () => new Query<string>(async () => new URL(this.page.url()).hash),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { beforeEach, describe, test } from "./utils/fixtures";
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
describe("sidebar resize", () => {
|
||||
const { given, get, when, then } = new MaputnikDriver();
|
||||
|
||||
beforeEach(async () => {
|
||||
await given.setupMockBackedResponses();
|
||||
await when.setStyle("layer");
|
||||
});
|
||||
|
||||
test("dragging the outer handle widens the sidebar", async () => {
|
||||
const initialWidth = await get.elementWidth("sidebar-panel").get();
|
||||
|
||||
await when.dragBy("sidebar-resize-handle", 100);
|
||||
|
||||
await then(get.elementWidth("sidebar-panel")).shouldBeGreaterThan(initialWidth + 50);
|
||||
});
|
||||
|
||||
test("dragging the inner handle widens the layer list", async () => {
|
||||
const initialWidth = await get.elementWidth("layer-list-panel").get();
|
||||
|
||||
await when.dragBy("inner-resize-handle", 50);
|
||||
|
||||
await then(get.elementWidth("layer-list-panel")).shouldBeGreaterThan(initialWidth + 20);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user