|
1 | 1 | import { App, Component, xml } from "@odoo/owl";
|
2 | 2 | import { Model, Spreadsheet } from "../../src";
|
| 3 | +import { DEFAULT_CELL_HEIGHT, DEFAULT_CELL_WIDTH } from "../../src/constants"; |
3 | 4 | import { figureRegistry } from "../../src/registries";
|
4 | 5 | import { CreateFigureCommand, Figure, SpreadsheetChildEnv, UID } from "../../src/types";
|
5 | 6 | import {
|
@@ -202,4 +203,20 @@ describe("figures", () => {
|
202 | 203 | await nextTick();
|
203 | 204 | expect(figure.classList).not.toContain("o-dragging");
|
204 | 205 | });
|
| 206 | + |
| 207 | + test("Figures are cropped to avoid overlap with headers", async () => { |
| 208 | + const figureId = "someuuid"; |
| 209 | + createFigure(model, { id: figureId, x: 100, y: 20, height: 200, width: 100 }); |
| 210 | + await nextTick(); |
| 211 | + const figure = fixture.querySelector(".o-figure-wrapper")!; |
| 212 | + expect(window.getComputedStyle(figure).width).toBe("111px"); // width + borders |
| 213 | + expect(window.getComputedStyle(figure).height).toBe("211px"); // height + borders |
| 214 | + model.dispatch("SET_VIEWPORT_OFFSET", { |
| 215 | + offsetX: 2 * DEFAULT_CELL_WIDTH, |
| 216 | + offsetY: 3 * DEFAULT_CELL_HEIGHT, |
| 217 | + }); |
| 218 | + await nextTick(); |
| 219 | + expect(window.getComputedStyle(figure).width).toBe("18px"); // width + borders - 2 * DEFAULT_CELL_WIDTH |
| 220 | + expect(window.getComputedStyle(figure).height).toBe("161px"); // height + offset - 2 * DEFAULT_CELL_WIDTH |
| 221 | + }); |
205 | 222 | });
|
0 commit comments