Skip to content

Commit

Permalink
[FIX] chart: Remove forwardport comments
Browse files Browse the repository at this point in the history
In a haste to close a tiresome forward port, I forgot to address some of
the `TODO` comments I left myself...

closes #2122

Task: 3210689
Signed-off-by: Pierre Rousseau (pro) <[email protected]>
  • Loading branch information
rrahir committed Mar 1, 2023
1 parent 7081532 commit d60858f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
...(this.getChartDefinition() as T),
...updateDefinition,
};
// TODORAR add a putain de test - c'est faux de nouveau ...
return this.env.model.dispatch("UPDATE_CHART", {
definition,
id: this.figureId,
Expand All @@ -111,7 +110,6 @@ export class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
throw new Error("Chart not defined.");
}
const definition = getChartDefinitionFromContextCreation(context, type);
// TODORAR add a putain de test - c'est faux de nouveau ...
this.env.model.dispatch("UPDATE_CHART", {
definition,
id: this.figureId,
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/core/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ export class ChartPlugin extends CorePlugin<ChartState> implements ChartState {
}

getChartIds(sheetId: UID) {
// TODORAR refaire ce shit truc
// on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
// return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
return Object.keys(this.charts[sheetId] || {});
}

Expand Down
29 changes: 29 additions & 0 deletions tests/components/charts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
createChart,
createGaugeChart,
createScorecardChart,
createSheet,
paste,
setStyle,
updateChart,
Expand Down Expand Up @@ -545,6 +546,34 @@ describe("figures", () => {
expect((mockChartData.options!.title as any).text).toBe("hello");
});

test("updating a chart from another sheet does not change it s sheetId", async () => {
createTestChart("basicChart");
await nextTick();

expect(fixture.querySelector(".o-sidePanel .o-sidePanelBody .o-chart")).toBeFalsy();
await simulateClick(".o-figure");
await simulateClick(".o-chart-menu-item");
await simulateClick(".o-menu div[data-name='edit']");

createSheet(model, { sheetId: "42", activate: true });
await nextTick();
const chartType = fixture.querySelectorAll(".o-input")[0] as HTMLSelectElement;
setInputValueAndTrigger(chartType, "pie", "change");
await nextTick();

expect(model.getters.getChart(sheetId, chartId)?.sheetId).toBe(sheetId);

const dataSeries = fixture.querySelectorAll(
".o-sidePanel .o-sidePanelBody .o-chart .o-data-series"
)[0] as HTMLInputElement;
const dataSeriesValues = dataSeries.querySelector("input");
const hasTitle = dataSeries.querySelector("input[type=checkbox]") as HTMLInputElement;
setInputValueAndTrigger(dataSeriesValues, "B2:B5", "change");
triggerMouseEvent(hasTitle, "click");
await nextTick();
expect(model.getters.getChart(sheetId, chartId)?.sheetId).toBe(sheetId);
});

test.each(["basicChart", "scorecard", "gauge"])(
"deleting chart %s will close sidePanel",
async (chartType: string) => {
Expand Down

0 comments on commit d60858f

Please sign in to comment.