fix: clarify board grid editing affordances
This commit is contained in:
1 parent
2f28f45ff1
commit
36de8131c8
9 files changed
+214
-20
No files matched your search
@@ -156,7 +156,7 @@ describe("fixed grid item behavior", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("uses the whole tile as the focusable move surface without a grab button", () => {
|
||||
test("uses the whole tile as the focusable move surface with a visual drag affordance", () => {
|
||||
getWeatherMock().advancedOptions.title = " Balcony forecast ";
|
||||
renderWeather(root);
|
||||
|
||||
@@ -165,7 +165,7 @@ describe("fixed grid item behavior", () => {
|
||||
expect(entry.getAttribute("aria-label")).toBe("Balcony forecast, column 1, row 1");
|
||||
expect(entry.tabIndex).toBe(0);
|
||||
expect(entry.getAttribute("aria-describedby")).not.toBeNull();
|
||||
expect(container.querySelector('[data-testid="board-grid-drag-handle"]')).toBeNull();
|
||||
expect(container.querySelector('[data-testid="board-grid-drag-affordance"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
test("renders a view-only 1x1 card at the fixed 200px logical size", () => {
|
||||
|
||||
@@ -7,23 +7,43 @@ const first: SectionGridPlacement = { id: "first", type: "item", x: 0, y: 0, w:
|
||||
const second: SectionGridPlacement = { id: "second", type: "item", x: 1, y: 0, w: 1, h: 1 };
|
||||
const third: SectionGridPlacement = { id: "third", type: "item", x: 2, y: 0, w: 2, h: 1 };
|
||||
const initial = [first, second, third];
|
||||
const bounds = { columnCount: 4 };
|
||||
|
||||
describe("grid drop swapping", () => {
|
||||
test("swaps equally-sized items when one takes the other's exact slot", () => {
|
||||
const current: SectionGridPlacement[] = [{ ...first, x: 1 }, { ...second, y: 1 }, third];
|
||||
|
||||
expect(getDropSwapPlacements(initial, current, "first")).toEqual([{ ...first, x: 1 }, { ...second, x: 0 }, third]);
|
||||
expect(getDropSwapPlacements(initial, current, "first", bounds)).toEqual([
|
||||
{ ...first, x: 1 },
|
||||
{ ...second, x: 0 },
|
||||
third,
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps push behavior for different sizes or partial placement", () => {
|
||||
test("swaps different-sized items when both destinations remain valid", () => {
|
||||
const wide: SectionGridPlacement = { id: "wide", type: "item", x: 0, y: 0, w: 2, h: 1 };
|
||||
const compact: SectionGridPlacement = { id: "compact", type: "item", x: 2, y: 0, w: 1, h: 1 };
|
||||
const current = [
|
||||
{ ...wide, x: 2 },
|
||||
{ ...compact, y: 1 },
|
||||
];
|
||||
|
||||
expect(getDropSwapPlacements([wide, compact], current, "wide", bounds)).toEqual([
|
||||
{ ...wide, x: 2 },
|
||||
{ ...compact, x: 0 },
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps push behavior when a swap would overlap another item or exceed the section", () => {
|
||||
const differentSize: SectionGridPlacement[] = [{ ...first, x: 2 }, second, { ...third, y: 1 }];
|
||||
const partialPlacement: SectionGridPlacement[] = [{ ...third, x: 1 }, first, { ...second, y: 1 }];
|
||||
|
||||
expect(getDropSwapPlacements(initial, differentSize, "first")).toBeNull();
|
||||
expect(getDropSwapPlacements(initial, partialPlacement, "third")).toBeNull();
|
||||
expect(getDropSwapPlacements(initial, differentSize, "first", bounds)).toBeNull();
|
||||
expect(getDropSwapPlacements(initial, partialPlacement, "third", bounds)).toBeNull();
|
||||
expect(getDropSwapPlacements(initial, [{ ...third, x: 1 }, first, second], "third", { columnCount: 2 })).toBeNull();
|
||||
});
|
||||
|
||||
test("does nothing when the item did not move", () => {
|
||||
expect(getDropSwapPlacements(initial, initial, "first")).toBeNull();
|
||||
expect(getDropSwapPlacements(initial, initial, "first", bounds)).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user