From ae1c333e32dafa33cc3ded71f5422d11c9422c71 Mon Sep 17 00:00:00 2001 From: Florian Damhaut Date: Mon, 6 Jan 2025 16:23:18 +0100 Subject: [PATCH] fixup! update tests --- .../collaborative_history.test.ts | 1 + .../collaborative_sheet_manipulations.test.ts | 1 + tests/colors/custom_colors_plugin.test.ts | 2 + tests/figures/chart/bar_chart_plugin.test.ts | 3 +- tests/figures/chart/chart_plugin.test.ts | 3 + tests/figures/chart/charts_component.test.ts | 7 ++- .../figures/chart/combo_chart_plugin.test.ts | 3 +- .../figures/chart/common_chart_plugin.test.ts | 1 + .../chart/gauge/gauge_chart_plugin.test.ts | 4 +- tests/figures/chart/line_chart_plugin.test.ts | 3 +- tests/figures/chart/pie_chart_plugin.test.ts | 3 +- .../chart/pyramid_chart_plugin.test.ts | 3 +- .../figures/chart/radar_chart_plugin.test.ts | 3 +- .../scorecard/scorecard_chart_plugin.test.ts | 3 +- .../waterfall/waterfall_chart_plugin.test.ts | 3 +- tests/figures/figure_component.test.ts | 57 ++++++++++++------- tests/test_helpers/commands_helpers.ts | 6 ++ tests/test_helpers/constants.ts | 1 + 18 files changed, 76 insertions(+), 31 deletions(-) diff --git a/tests/collaborative/collaborative_history.test.ts b/tests/collaborative/collaborative_history.test.ts index 0721438a2a..d78c236c6e 100644 --- a/tests/collaborative/collaborative_history.test.ts +++ b/tests/collaborative/collaborative_history.test.ts @@ -421,6 +421,7 @@ describe("Collaborative local history", () => { stacked: false, dataSetsHaveTitle: false, legendPosition: "none", + fixed_position: false, }, }, { diff --git a/tests/collaborative/collaborative_sheet_manipulations.test.ts b/tests/collaborative/collaborative_sheet_manipulations.test.ts index 2a33b697e3..5ea8c82b97 100644 --- a/tests/collaborative/collaborative_sheet_manipulations.test.ts +++ b/tests/collaborative/collaborative_sheet_manipulations.test.ts @@ -596,6 +596,7 @@ describe("Collaborative Sheet manipulation", () => { background: BACKGROUND_CHART_COLOR, legendPosition: "top", aggregated: false, + fixed_position: false, }; test(`Concurrently chart creation & update and add columns`, () => { diff --git a/tests/colors/custom_colors_plugin.test.ts b/tests/colors/custom_colors_plugin.test.ts index 81b13ba939..c920f77f6a 100644 --- a/tests/colors/custom_colors_plugin.test.ts +++ b/tests/colors/custom_colors_plugin.test.ts @@ -118,6 +118,7 @@ describe("custom colors are correctly handled when editing charts", () => { legendPosition: "none", background: "#112233", aggregated: false, + fixed_position: false, }, }); expect(model.getters.getCustomColors()).toEqual(["#112233", "#123456"]); @@ -137,6 +138,7 @@ describe("custom colors are correctly handled when editing charts", () => { title: { text: "a title" }, type: "gauge", dataRange: "B1:B4", + fixed_position: false, sectionRule: { rangeMin: "0", rangeMax: "100", diff --git a/tests/figures/chart/bar_chart_plugin.test.ts b/tests/figures/chart/bar_chart_plugin.test.ts index c988faadbb..edbdf41407 100644 --- a/tests/figures/chart/bar_chart_plugin.test.ts +++ b/tests/figures/chart/bar_chart_plugin.test.ts @@ -21,7 +21,7 @@ describe("bar chart", () => { auxiliaryRange: "Sheet1!A1:A4", legendPosition: "bottom", cumulative: true, - fixed_position: true, + fixed_position: false, labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, @@ -46,6 +46,7 @@ describe("bar chart", () => { stacked: true, axesDesign: {}, showValues: false, + fixed_position: false, }); }); diff --git a/tests/figures/chart/chart_plugin.test.ts b/tests/figures/chart/chart_plugin.test.ts index 05c7fb35cd..ccc2293b9a 100644 --- a/tests/figures/chart/chart_plugin.test.ts +++ b/tests/figures/chart/chart_plugin.test.ts @@ -1638,6 +1638,7 @@ describe("Chart without labels", () => { type: "bar", stacked: false, aggregated: false, + fixed_position: false, }; test("The legend is displayed even when there is only one dataSet or no label", () => { @@ -1713,6 +1714,7 @@ describe("Chart design configuration", () => { labelRange: "A3", stacked: false, aggregated: false, + fixed_position: false, }; test("Legend position", () => { @@ -2430,6 +2432,7 @@ describe("Chart aggregate labels", () => { type: "bar", stacked: false, aggregated: false, + fixed_position: false, }; aggregatedModel = new Model({ sheets: [ diff --git a/tests/figures/chart/charts_component.test.ts b/tests/figures/chart/charts_component.test.ts index 22d70d7dc6..e65d0a3fab 100644 --- a/tests/figures/chart/charts_component.test.ts +++ b/tests/figures/chart/charts_component.test.ts @@ -162,8 +162,11 @@ describe("charts", () => { height: 335, tag: "chart", width: 536, - x: 0, - y: 0, + anchor: { col: 0, row: 0 }, + offset: { + x: 0, + y: 0, + }, }, ]); }); diff --git a/tests/figures/chart/combo_chart_plugin.test.ts b/tests/figures/chart/combo_chart_plugin.test.ts index 7a209e2d81..88d9a5a810 100644 --- a/tests/figures/chart/combo_chart_plugin.test.ts +++ b/tests/figures/chart/combo_chart_plugin.test.ts @@ -19,7 +19,7 @@ describe("combo chart", () => { auxiliaryRange: "Sheet1!A1:A4", legendPosition: "bottom", cumulative: true, - fixed_position: true, + fixed_position: false, labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, @@ -43,6 +43,7 @@ describe("combo chart", () => { aggregated: true, axesDesign: {}, showValues: false, + fixed_position: false, }); }); diff --git a/tests/figures/chart/common_chart_plugin.test.ts b/tests/figures/chart/common_chart_plugin.test.ts index c61282fd41..a3c3934787 100644 --- a/tests/figures/chart/common_chart_plugin.test.ts +++ b/tests/figures/chart/common_chart_plugin.test.ts @@ -116,6 +116,7 @@ describe("Single cell chart background color", () => { }, width: 123, height: 321, + fixed_position: true, }); model.dispatch("DUPLICATE_SHEET", { sheetIdTo: secondSheetId, diff --git a/tests/figures/chart/gauge/gauge_chart_plugin.test.ts b/tests/figures/chart/gauge/gauge_chart_plugin.test.ts index 2a2792b868..e44c10a3b2 100644 --- a/tests/figures/chart/gauge/gauge_chart_plugin.test.ts +++ b/tests/figures/chart/gauge/gauge_chart_plugin.test.ts @@ -123,7 +123,7 @@ describe("datasource tests", function () { auxiliaryRange: "Sheet1!A1:A4", legendPosition: "bottom", cumulative: true, - fixed_position: true, + fixed_position: false, labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, @@ -142,6 +142,7 @@ describe("datasource tests", function () { title: { text: "hello there" }, dataRange: "Sheet1!B1:B4", sectionRule: expect.any(Object), + fixed_position: false, }); }); @@ -490,6 +491,7 @@ describe("Chart design configuration", () => { title: { text: "My chart" }, type: "gauge", sectionRule: deepCopy(defaultSectionRule), + fixed_position: false, }; }); diff --git a/tests/figures/chart/line_chart_plugin.test.ts b/tests/figures/chart/line_chart_plugin.test.ts index ca75520aa2..76970b21f8 100644 --- a/tests/figures/chart/line_chart_plugin.test.ts +++ b/tests/figures/chart/line_chart_plugin.test.ts @@ -14,7 +14,7 @@ describe("line chart", () => { legendPosition: "bottom", cumulative: true, labelsAsText: true, - fixed_position: true, + fixed_position: false, dataSetsHaveTitle: true, aggregated: true, stacked: true, @@ -34,6 +34,7 @@ describe("line chart", () => { labelRange: "Sheet1!A1:A4", legendPosition: "bottom", dataSetsHaveTitle: true, + fixed_position: false, aggregated: true, stacked: true, labelsAsText: true, diff --git a/tests/figures/chart/pie_chart_plugin.test.ts b/tests/figures/chart/pie_chart_plugin.test.ts index 5fba65fc51..ca79a55acd 100644 --- a/tests/figures/chart/pie_chart_plugin.test.ts +++ b/tests/figures/chart/pie_chart_plugin.test.ts @@ -16,7 +16,7 @@ describe("pie chart", () => { labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, - fixed_position: true, + fixed_position: false, stacked: true, firstValueAsSubtotal: true, showConnectorLines: false, @@ -37,6 +37,7 @@ describe("pie chart", () => { aggregated: true, isDoughnut: false, showValues: false, + fixed_position: false, }); }); diff --git a/tests/figures/chart/pyramid_chart_plugin.test.ts b/tests/figures/chart/pyramid_chart_plugin.test.ts index 2015db1e42..299177ba84 100644 --- a/tests/figures/chart/pyramid_chart_plugin.test.ts +++ b/tests/figures/chart/pyramid_chart_plugin.test.ts @@ -14,7 +14,7 @@ describe("population pyramid chart", () => { legendPosition: "bottom", cumulative: true, labelsAsText: true, - fixed_position: true, + fixed_position: false, dataSetsHaveTitle: true, aggregated: true, stacked: false, @@ -39,6 +39,7 @@ describe("population pyramid chart", () => { axesDesign: {}, horizontal: true, showValues: false, + fixed_position: false, }); }); diff --git a/tests/figures/chart/radar_chart_plugin.test.ts b/tests/figures/chart/radar_chart_plugin.test.ts index 83f75d31db..c9e9721e4a 100644 --- a/tests/figures/chart/radar_chart_plugin.test.ts +++ b/tests/figures/chart/radar_chart_plugin.test.ts @@ -21,7 +21,7 @@ describe("radar chart", () => { legendPosition: "bottom", cumulative: true, labelsAsText: true, - fixed_position: true, + fixed_position: false, dataSetsHaveTitle: true, aggregated: true, stacked: true, @@ -45,6 +45,7 @@ describe("radar chart", () => { fillArea: true, stacked: true, showValues: true, + fixed_position: false, }); }); diff --git a/tests/figures/chart/scorecard/scorecard_chart_plugin.test.ts b/tests/figures/chart/scorecard/scorecard_chart_plugin.test.ts index 8a43fff545..5f190cd189 100644 --- a/tests/figures/chart/scorecard/scorecard_chart_plugin.test.ts +++ b/tests/figures/chart/scorecard/scorecard_chart_plugin.test.ts @@ -87,7 +87,7 @@ describe("datasource tests", function () { auxiliaryRange: "Sheet1!A1:A4", legendPosition: "bottom", cumulative: true, - fixed_position: true, + fixed_position: false, labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, @@ -109,6 +109,7 @@ describe("datasource tests", function () { baselineMode: DEFAULT_SCORECARD_BASELINE_MODE, baselineColorUp: DEFAULT_SCORECARD_BASELINE_COLOR_UP, baselineColorDown: DEFAULT_SCORECARD_BASELINE_COLOR_DOWN, + fixed_position: false, }); }); diff --git a/tests/figures/chart/waterfall/waterfall_chart_plugin.test.ts b/tests/figures/chart/waterfall/waterfall_chart_plugin.test.ts index 1e13a6faae..58254180b6 100644 --- a/tests/figures/chart/waterfall/waterfall_chart_plugin.test.ts +++ b/tests/figures/chart/waterfall/waterfall_chart_plugin.test.ts @@ -302,7 +302,7 @@ describe("Waterfall chart", () => { auxiliaryRange: "Sheet1!A1:A4", legendPosition: "bottom", cumulative: true, - fixed_position: true, + fixed_position: false, labelsAsText: true, dataSetsHaveTitle: true, aggregated: true, @@ -330,6 +330,7 @@ describe("Waterfall chart", () => { axesDesign: {}, verticalAxisPosition: "left", showValues: false, + fixed_position: false, }); }); }); diff --git a/tests/figures/figure_component.test.ts b/tests/figures/figure_component.test.ts index 4fc9c19eb1..39b083b872 100644 --- a/tests/figures/figure_component.test.ts +++ b/tests/figures/figure_component.test.ts @@ -392,7 +392,7 @@ describe("figures", () => { createFigure(model, { id, offset: { x: 16 * cellWidth, y: 4 * cellHeight } }); await nextTick(); await dragElement(figureSelector, { x: 0, y: 3 * cellHeight }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 16 * cellWidth, y: 17 * cellHeight, // initial position + drag offset + scroll offset }); @@ -402,7 +402,7 @@ describe("figures", () => { createFigure(model, { id, offset: { x: 16 * cellWidth, y: 16 * cellHeight } }); await nextTick(); await dragElement(figureSelector, { x: 0, y: -3 * cellHeight }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 16 * cellWidth, y: 3 * cellHeight, // initial position + drag offset - scroll offset }); @@ -416,7 +416,7 @@ describe("figures", () => { }); await nextTick(); await dragElement(figureSelector, { x: 1, y: 0 }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 16 * cellWidth + 1, y: 4 * cellHeight, // initial position - scroll offset }); @@ -426,7 +426,7 @@ describe("figures", () => { createFigure(model, { id, offset: { x: 4 * cellWidth, y: 16 * cellHeight } }); await nextTick(); await dragElement(figureSelector, { x: 3 * cellWidth, y: 0 }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 17 * cellWidth, // initial position + drag offset + scroll offset y: 16 * cellHeight, }); @@ -436,7 +436,7 @@ describe("figures", () => { createFigure(model, { id, offset: { x: 16 * cellWidth, y: 16 * cellHeight } }); await nextTick(); await dragElement(figureSelector, { x: -3 * cellWidth, y: 0 }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 3 * cellWidth, // initial position + drag offset - scroll offset y: 16 * cellHeight, }); @@ -450,7 +450,7 @@ describe("figures", () => { }); await nextTick(); await dragElement(figureSelector, { x: 0, y: 1 }, undefined, true); - expect(model.getters.getFigure(sheetId, id)).toMatchObject({ + expect(model.getters.getFigure(sheetId, id)?.offset).toMatchObject({ x: 4 * cellWidth, // initial position - scroll offset y: 16 * cellHeight + 1, }); @@ -479,13 +479,12 @@ describe("figures", () => { triggerWheelEvent(figureEl, { deltaY: wheelY, deltaX: wheelX }); triggerMouseEvent(figureEl, "pointerup"); await nextTick(); - - expect(model.getters.getFigure(model.getters.getActiveSheetId(), "someuuid")).toMatchObject( - { - x: 200 + wheelX, - y: 100 + wheelY, - } - ); + expect( + model.getters.getFigure(model.getters.getActiveSheetId(), "someuuid")!.offset + ).toMatchObject({ + x: 200 + wheelX, + y: 100 + wheelY, + }); } ); @@ -823,7 +822,10 @@ describe("figures", () => { }); await nextTick(); await dragElement(".o-figure[data-id=f1]", { x: mouseMove, y: 0 }, undefined, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ x: expectedResult, y: 0 }); + expect(model.getters.getFigure(sheetId, "f1")?.offset).toMatchObject({ + x: expectedResult, + y: 0, + }); } ); @@ -858,7 +860,10 @@ describe("figures", () => { }); await nextTick(); await dragElement(".o-figure[data-id=f1]", { x: 0, y: mouseMove }, undefined, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ x: 0, y: expectedResult }); + expect(model.getters.getFigure(sheetId, "f1")?.offset).toMatchObject({ + x: 0, + y: expectedResult, + }); } ); }); @@ -890,7 +895,10 @@ describe("figures", () => { model.dispatch("SELECT_FIGURE", { id: "f1" }); await nextTick(); await dragAnchor(anchor, mouseMove, 0, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ ...expectedResult }); + const figure = model.getters.getFigure(sheetId, "f1")!; + expect({ x: figure.offset.x, width: figure.width }).toMatchObject({ + ...expectedResult, + }); }); } ); @@ -921,7 +929,10 @@ describe("figures", () => { model.dispatch("SELECT_FIGURE", { id: "f1" }); await nextTick(); await dragAnchor(anchor, mouseMove, 0, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ ...expectedResult }); + const figure = model.getters.getFigure(sheetId, "f1")!; + expect({ x: figure.offset.x, width: figure.width }).toMatchObject({ + ...expectedResult, + }); }); } ); @@ -952,7 +963,10 @@ describe("figures", () => { model.dispatch("SELECT_FIGURE", { id: "f1" }); await nextTick(); await dragAnchor(anchor, 0, mouseMove, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ ...expectedResult }); + const figure = model.getters.getFigure(sheetId, "f1")!; + expect({ y: figure.offset.y, height: figure.height }).toMatchObject({ + ...expectedResult, + }); }); } ); @@ -983,7 +997,10 @@ describe("figures", () => { model.dispatch("SELECT_FIGURE", { id: "f1" }); await nextTick(); await dragAnchor(anchor, 0, mouseMove, true); - expect(model.getters.getFigure(sheetId, "f1")).toMatchObject({ ...expectedResult }); + const figure = model.getters.getFigure(sheetId, "f1")!; + expect({ y: figure.offset.y, height: figure.height }).toMatchObject({ + ...expectedResult, + }); }); } ); @@ -1515,7 +1532,7 @@ describe("figures", () => { setViewportOffset(model, 2 * DEFAULT_CELL_WIDTH, 0); await nextTick(); await dragElement( - ".o-figure[data-id=f1]", + '.o-figure[data-id="f1"]', { x: 2 * DEFAULT_CELL_WIDTH - 1, y: 0 }, undefined, true diff --git a/tests/test_helpers/commands_helpers.ts b/tests/test_helpers/commands_helpers.ts index 342aec649f..2454182337 100644 --- a/tests/test_helpers/commands_helpers.ts +++ b/tests/test_helpers/commands_helpers.ts @@ -184,6 +184,7 @@ export function createChart( cumulative: ("cumulative" in data && data.cumulative) || false, showSubTotals: ("showSubTotals" in data && data.showSubTotals) || false, showConnectorLines: ("showConnectorLines" in data && data.showConnectorLines) || false, + fixed_position: data.fixed_position || false, }; return model.dispatch("CREATE_CHART", { id, @@ -213,6 +214,7 @@ export function createComboChart( background: data.background, legendPosition: data.legendPosition || "top", aggregated: ("aggregated" in data && data.aggregated) || false, + fixed_position: data.fixed_position || false, }, }); } @@ -240,6 +242,7 @@ export function createRadarChart( aggregated: ("aggregated" in data && data.aggregated) || false, fillArea: data.fillArea || false, stacked: data.stacked || false, + fixed_position: data.fixed_position || false, }, }); } @@ -273,6 +276,7 @@ export function createScorecardChart( baselineColorUp: data.baselineColorUp || DEFAULT_SCORECARD_BASELINE_COLOR_UP, background: data.background, humanize: data.humanize || false, + fixed_position: data.fixed_position || false, }, }); } @@ -294,6 +298,7 @@ export function createGaugeChart( background: data.background, title: data.title || { text: "" }, dataRange: data.dataRange || "", + fixed_position: data.fixed_position || false, sectionRule: data.sectionRule || { rangeMin: "0", rangeMax: "100", @@ -339,6 +344,7 @@ export function createGeoChart( colorScale: data.colorScale, missingValueColor: data.missingValueColor, region: data.region, + fixed_position: data.fixed_position || false, }, }); } diff --git a/tests/test_helpers/constants.ts b/tests/test_helpers/constants.ts index 49662ec7d1..96ee36f90c 100644 --- a/tests/test_helpers/constants.ts +++ b/tests/test_helpers/constants.ts @@ -21,6 +21,7 @@ export const TEST_CHART_DATA = { background: BACKGROUND_CHART_COLOR, stacked: false, legendPosition: "top" as const, + fixed_position: false, }, combo: { type: "combo" as const,