Skip to content

Commit

Permalink
fixup! update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fdamhaut committed Jan 6, 2025
1 parent fda685a commit ae1c333
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 31 deletions.
1 change: 1 addition & 0 deletions tests/collaborative/collaborative_history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ describe("Collaborative local history", () => {
stacked: false,
dataSetsHaveTitle: false,
legendPosition: "none",
fixed_position: false,
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`, () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/colors/custom_colors_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/bar_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -46,6 +46,7 @@ describe("bar chart", () => {
stacked: true,
axesDesign: {},
showValues: false,
fixed_position: false,
});
});

Expand Down
3 changes: 3 additions & 0 deletions tests/figures/chart/chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -1713,6 +1714,7 @@ describe("Chart design configuration", () => {
labelRange: "A3",
stacked: false,
aggregated: false,
fixed_position: false,
};

test("Legend position", () => {
Expand Down Expand Up @@ -2430,6 +2432,7 @@ describe("Chart aggregate labels", () => {
type: "bar",
stacked: false,
aggregated: false,
fixed_position: false,
};
aggregatedModel = new Model({
sheets: [
Expand Down
7 changes: 5 additions & 2 deletions tests/figures/chart/charts_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
]);
});
Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/combo_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,6 +43,7 @@ describe("combo chart", () => {
aggregated: true,
axesDesign: {},
showValues: false,
fixed_position: false,
});
});

Expand Down
1 change: 1 addition & 0 deletions tests/figures/chart/common_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe("Single cell chart background color", () => {
},
width: 123,
height: 321,
fixed_position: true,
});
model.dispatch("DUPLICATE_SHEET", {
sheetIdTo: secondSheetId,
Expand Down
4 changes: 3 additions & 1 deletion tests/figures/chart/gauge/gauge_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -142,6 +142,7 @@ describe("datasource tests", function () {
title: { text: "hello there" },
dataRange: "Sheet1!B1:B4",
sectionRule: expect.any(Object),
fixed_position: false,
});
});

Expand Down Expand Up @@ -490,6 +491,7 @@ describe("Chart design configuration", () => {
title: { text: "My chart" },
type: "gauge",
sectionRule: deepCopy(defaultSectionRule),
fixed_position: false,
};
});

Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/line_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -34,6 +34,7 @@ describe("line chart", () => {
labelRange: "Sheet1!A1:A4",
legendPosition: "bottom",
dataSetsHaveTitle: true,
fixed_position: false,
aggregated: true,
stacked: true,
labelsAsText: true,
Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/pie_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,6 +37,7 @@ describe("pie chart", () => {
aggregated: true,
isDoughnut: false,
showValues: false,
fixed_position: false,
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/pyramid_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,6 +39,7 @@ describe("population pyramid chart", () => {
axesDesign: {},
horizontal: true,
showValues: false,
fixed_position: false,
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/radar_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -45,6 +45,7 @@ describe("radar chart", () => {
fillArea: true,
stacked: true,
showValues: true,
fixed_position: false,
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/scorecard/scorecard_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/figures/chart/waterfall/waterfall_chart_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -330,6 +330,7 @@ describe("Waterfall chart", () => {
axesDesign: {},
verticalAxisPosition: "left",
showValues: false,
fixed_position: false,
});
});
});
57 changes: 37 additions & 20 deletions tests/figures/figure_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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
});
Expand All @@ -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
});
Expand All @@ -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,
});
Expand All @@ -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,
});
Expand All @@ -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,
});
Expand Down Expand Up @@ -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,
});
}
);

Expand Down Expand Up @@ -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,
});
}
);

Expand Down Expand Up @@ -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,
});
}
);
});
Expand Down Expand Up @@ -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,
});
});
}
);
Expand Down Expand Up @@ -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,
});
});
}
);
Expand Down Expand Up @@ -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,
});
});
}
);
Expand Down Expand Up @@ -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,
});
});
}
);
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit ae1c333

Please sign in to comment.