mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-22 09:42:03 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
|
|
@ -0,0 +1,198 @@
|
|||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { dblclick, queryAll, queryAllTexts } from "@odoo/hoot-dom";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import { createSpreadsheetDashboard } from "@spreadsheet_dashboard/../tests/helpers/dashboard_action";
|
||||
import {
|
||||
defineSpreadsheetDashboardModels,
|
||||
getDashboardServerData,
|
||||
} from "@spreadsheet_dashboard/../tests/helpers/data";
|
||||
import { contains } from "@web/../tests/web_test_helpers";
|
||||
|
||||
describe.current.tags("mobile");
|
||||
defineSpreadsheetDashboardModels();
|
||||
|
||||
const TEST_LINE_CHART_DATA = {
|
||||
type: "line",
|
||||
dataSetsHaveTitle: false,
|
||||
dataSets: [{ dataRange: "A1" }],
|
||||
legendPosition: "top",
|
||||
verticalAxisPosition: "left",
|
||||
title: { text: "" },
|
||||
};
|
||||
|
||||
const TEST_SCORECARD_CHART_DATA = {
|
||||
type: "scorecard",
|
||||
title: { text: "test" },
|
||||
keyValue: "A1",
|
||||
background: "#fff",
|
||||
baselineMode: "absolute",
|
||||
};
|
||||
|
||||
test("is empty with no figures", async () => {
|
||||
await createSpreadsheetDashboard();
|
||||
expect(".o_mobile_dashboard").toHaveCount(1);
|
||||
expect(".o_mobile_dashboard").toHaveText(
|
||||
"Only chart figures are displayed in small screens but this dashboard doesn't contain any"
|
||||
);
|
||||
});
|
||||
|
||||
test("with no available dashboard", async () => {
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard"].records = [];
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [];
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
expect(".o_mobile_dashboard").toHaveText("No available dashboard");
|
||||
});
|
||||
|
||||
test("displays figures in first sheet", async () => {
|
||||
const figure = {
|
||||
tag: "chart",
|
||||
height: 500,
|
||||
width: 500,
|
||||
col: 0,
|
||||
row: 0,
|
||||
offset: { x: 100, y: 100 },
|
||||
data: TEST_LINE_CHART_DATA,
|
||||
};
|
||||
const spreadsheetData = {
|
||||
sheets: [
|
||||
{ id: "sheet1", figures: [{ ...figure, id: "figure1" }] },
|
||||
{ id: "sheet2", figures: [{ ...figure, id: "figure2" }] },
|
||||
],
|
||||
};
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [
|
||||
{
|
||||
published_dashboard_ids: [789],
|
||||
id: 1,
|
||||
name: "Chart",
|
||||
},
|
||||
];
|
||||
serverData.models["spreadsheet.dashboard"].records = [
|
||||
{
|
||||
id: 789,
|
||||
name: "Spreadsheet with chart figure",
|
||||
json_data: JSON.stringify(spreadsheetData),
|
||||
spreadsheet_data: JSON.stringify(spreadsheetData),
|
||||
dashboard_group_id: 1,
|
||||
},
|
||||
];
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
expect(".o-chart-container").toHaveCount(1);
|
||||
});
|
||||
|
||||
test("scorecards are placed two per row", async () => {
|
||||
const figure = {
|
||||
tag: "chart",
|
||||
height: 500,
|
||||
width: 500,
|
||||
offset: { x: 100, y: 100 },
|
||||
col: 0,
|
||||
row: 0,
|
||||
};
|
||||
const spreadsheetData = {
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet1",
|
||||
figures: [
|
||||
{ ...figure, id: "figure1", data: TEST_SCORECARD_CHART_DATA },
|
||||
{ ...figure, id: "figure2", data: TEST_SCORECARD_CHART_DATA },
|
||||
{ ...figure, id: "figure3", data: TEST_SCORECARD_CHART_DATA },
|
||||
{ ...figure, id: "figure4", data: TEST_LINE_CHART_DATA },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [
|
||||
{ published_dashboard_ids: [789], id: 1, name: "Chart" },
|
||||
];
|
||||
serverData.models["spreadsheet.dashboard"].records = [
|
||||
{
|
||||
id: 789,
|
||||
name: "Spreadsheet with chart figure",
|
||||
json_data: JSON.stringify(spreadsheetData),
|
||||
spreadsheet_data: JSON.stringify(spreadsheetData),
|
||||
dashboard_group_id: 1,
|
||||
},
|
||||
];
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
const figureRows = queryAll(".o_figure_row");
|
||||
expect(figureRows).toHaveLength(3);
|
||||
expect(figureRows[0].querySelectorAll(".o-scorecard")).toHaveLength(2);
|
||||
|
||||
expect(figureRows[1].querySelectorAll(".o-scorecard")).toHaveLength(1);
|
||||
expect(figureRows[1].querySelectorAll(".o_empty_figure")).toHaveLength(1);
|
||||
|
||||
expect(figureRows[2].querySelectorAll(".o-figure-canvas")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("double clicking on a figure doesn't open the side panel", async () => {
|
||||
const figure = {
|
||||
tag: "chart",
|
||||
height: 500,
|
||||
width: 500,
|
||||
col: 0,
|
||||
row: 0,
|
||||
offset: {
|
||||
x: 100,
|
||||
y: 100,
|
||||
},
|
||||
data: TEST_LINE_CHART_DATA,
|
||||
};
|
||||
const spreadsheetData = {
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet1",
|
||||
figures: [{ ...figure, id: "figure1" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [
|
||||
{
|
||||
published_dashboard_ids: [789],
|
||||
id: 1,
|
||||
name: "Chart",
|
||||
},
|
||||
];
|
||||
serverData.models["spreadsheet.dashboard"].records = [
|
||||
{
|
||||
id: 789,
|
||||
name: "Spreadsheet with chart figure",
|
||||
json_data: JSON.stringify(spreadsheetData),
|
||||
spreadsheet_data: JSON.stringify(spreadsheetData),
|
||||
dashboard_group_id: 1,
|
||||
},
|
||||
];
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
await contains(".o-chart-container").focus();
|
||||
await dblclick(".o-chart-container");
|
||||
await animationFrame();
|
||||
expect(".o-chart-container").toHaveCount(1);
|
||||
expect(".o-sidePanel").toHaveCount(0);
|
||||
});
|
||||
|
||||
test("can switch dashboard", async () => {
|
||||
await createSpreadsheetDashboard();
|
||||
expect(".o_search_panel_current_selection").toHaveText("Dashboard CRM 1");
|
||||
await contains(".o_search_panel_current_selection").click();
|
||||
const dashboardElements = queryAll("section header.list-group-item", { root: document.body });
|
||||
expect(dashboardElements[0]).toHaveClass("active");
|
||||
expect(queryAllTexts(dashboardElements)).toEqual([
|
||||
"Dashboard CRM 1",
|
||||
"Dashboard CRM 2",
|
||||
"Dashboard Accounting 1",
|
||||
]);
|
||||
await contains(dashboardElements[1]).click();
|
||||
expect(".o_search_panel_current_selection").toHaveText("Dashboard CRM 2");
|
||||
});
|
||||
|
||||
test("can go back from dashboard selection", async () => {
|
||||
await createSpreadsheetDashboard();
|
||||
expect(".o_mobile_dashboard").toHaveCount(1);
|
||||
expect(".o_search_panel_current_selection").toHaveText("Dashboard CRM 1");
|
||||
await contains(".o_search_panel_current_selection").click();
|
||||
await contains(document.querySelector(".o_mobile_search_button")).click();
|
||||
expect(".o_search_panel_current_selection").toHaveText("Dashboard CRM 1");
|
||||
});
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { click, getFixture } from "@web/../tests/helpers/utils";
|
||||
import { createSpreadsheetDashboard } from "../utils/dashboard_action";
|
||||
import { getDashboardServerData } from "../utils/data";
|
||||
|
||||
QUnit.module("spreadsheet_dashboard > Mobile Dashboard action");
|
||||
|
||||
QUnit.test("is empty with no figures", async (assert) => {
|
||||
await createSpreadsheetDashboard();
|
||||
const fixture = getFixture();
|
||||
assert.containsOnce(fixture, ".o_mobile_dashboard");
|
||||
const content = fixture.querySelector(".o_mobile_dashboard");
|
||||
assert.deepEqual(content.innerText.split("\n"), [
|
||||
"Dashboard CRM 1",
|
||||
"Only chart figures are displayed in small screens but this dashboard doesn't contain any",
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("with no available dashboard", async (assert) => {
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard"].records = [];
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [];
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
const fixture = getFixture();
|
||||
const content = fixture.querySelector(".o_mobile_dashboard");
|
||||
assert.deepEqual(content.innerText, "No available dashboard");
|
||||
});
|
||||
|
||||
QUnit.test("displays figures in first sheet", async (assert) => {
|
||||
const figure = {
|
||||
tag: "chart",
|
||||
height: 500,
|
||||
width: 500,
|
||||
x: 100,
|
||||
y: 100,
|
||||
data: {
|
||||
type: "line",
|
||||
dataSetsHaveTitle: false,
|
||||
dataSets: ["A1"],
|
||||
legendPosition: "top",
|
||||
verticalAxisPosition: "left",
|
||||
title: "",
|
||||
},
|
||||
};
|
||||
const spreadsheetData = {
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet1",
|
||||
figures: [{ ...figure, id: "figure1" }],
|
||||
},
|
||||
{
|
||||
id: "sheet2",
|
||||
figures: [{ ...figure, id: "figure2" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [
|
||||
{
|
||||
dashboard_ids: [789],
|
||||
id: 1,
|
||||
name: "Chart",
|
||||
},
|
||||
];
|
||||
serverData.models["spreadsheet.dashboard"].records = [
|
||||
{
|
||||
id: 789,
|
||||
name: "Spreadsheet with chart figure",
|
||||
json_data: JSON.stringify(spreadsheetData),
|
||||
raw: JSON.stringify(spreadsheetData),
|
||||
dashboard_group_id: 1,
|
||||
},
|
||||
];
|
||||
const fixture = getFixture();
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
assert.containsOnce(fixture, ".o-chart-container");
|
||||
});
|
||||
|
||||
QUnit.test("can switch dashboard", async (assert) => {
|
||||
await createSpreadsheetDashboard();
|
||||
const fixture = getFixture();
|
||||
assert.strictEqual(
|
||||
fixture.querySelector(".o_search_panel_summary").innerText,
|
||||
"Dashboard CRM 1"
|
||||
);
|
||||
await click(fixture, ".o_search_panel_current_selection");
|
||||
const dashboardElements = [...document.querySelectorAll("section header.list-group-item")];
|
||||
assert.strictEqual(dashboardElements[0].classList.contains("active"), true);
|
||||
assert.deepEqual(
|
||||
dashboardElements.map((el) => el.innerText),
|
||||
["Dashboard CRM 1", "Dashboard CRM 2", "Dashboard Accounting 1"]
|
||||
);
|
||||
await click(dashboardElements[1]);
|
||||
assert.strictEqual(
|
||||
fixture.querySelector(".o_search_panel_summary").innerText,
|
||||
"Dashboard CRM 2"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("can go back from dashboard selection", async (assert) => {
|
||||
await createSpreadsheetDashboard();
|
||||
const fixture = getFixture();
|
||||
assert.containsOnce(fixture, ".o_mobile_dashboard");
|
||||
assert.strictEqual(
|
||||
fixture.querySelector(".o_search_panel_summary").innerText,
|
||||
"Dashboard CRM 1"
|
||||
);
|
||||
await click(fixture, ".o_search_panel_current_selection");
|
||||
await click(document, ".o_mobile_search_button");
|
||||
assert.strictEqual(
|
||||
fixture.querySelector(".o_search_panel_summary").innerText,
|
||||
"Dashboard CRM 1"
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue