From 5a20b60234745f885ef0b612d0f85817babfbd08 Mon Sep 17 00:00:00 2001 From: "Laurent Stukkens (LTU)" Date: Tue, 20 Sep 2022 18:59:58 +0000 Subject: [PATCH] [IMP] hr_timesheet: add tests on TimesheetFloatToggleField This commit add tests that ensures that the toggling is working as expected when a factor is used. task-2990758 closes odoo/odoo#100626 Signed-off-by: Laurent Stukkens (ltu) --- .../tests/timesheet_uom_widgets_tests.js | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/addons/hr_timesheet/static/tests/timesheet_uom_widgets_tests.js b/addons/hr_timesheet/static/tests/timesheet_uom_widgets_tests.js index 511726709a7..6b4f1227b98 100644 --- a/addons/hr_timesheet/static/tests/timesheet_uom_widgets_tests.js +++ b/addons/hr_timesheet/static/tests/timesheet_uom_widgets_tests.js @@ -6,34 +6,35 @@ import { companyService } from "@web/webclient/company_service"; import { timesheetUomService } from "../src/services/timesheet_uom_service"; import { uiService } from "@web/core/ui/ui_service"; import { makeView, setupViewRegistries} from "@web/../tests/views/helpers"; -import { getFixture, patchWithCleanup } from "@web/../tests/helpers/utils"; +import { click, getFixture, patchWithCleanup } from "@web/../tests/helpers/utils"; const serviceRegistry = registry.category("services"); QUnit.module("Timesheet UOM Widgets", (hooks) => { - const serverData = { - models: { - 'account.analytic.line': { - fields: { - unit_amount: { string: "Unit Amount", type: "float" }, - }, - records: [ - { id: 1, unit_amount: 8 } - ], - }, - }, - views: { - "account.analytic.line,false,list": ` - - - - `, - }, - }; + let serverData; let target; hooks.beforeEach(async function (assert) { setupViewRegistries(); target = getFixture(); + serverData = { + models: { + 'account.analytic.line': { + fields: { + unit_amount: { string: "Unit Amount", type: "float" }, + }, + records: [ + { id: 1, unit_amount: 8 } + ], + }, + }, + views: { + "account.analytic.line,false,list": ` + + + + `, + }, + }; serviceRegistry.add("ui", uiService); serviceRegistry.add("timesheet_uom", timesheetUomService); serviceRegistry.add("company", companyService, { force: true }); @@ -80,6 +81,25 @@ QUnit.module("Timesheet UOM Widgets", (hooks) => { assert.containsOnce(target, 'div[name="unit_amount"]:contains("1")', "TimesheetFloatToggleField should take `timesheet_uom_factor` into account"); }); + QUnit.test("ranges are working properly in TimesheetFloatToggleField", async function (assert) { + serverData.models["account.analytic.line"].records[0].unit_amount = 1; + serverData.views["account.analytic.line,false,list"] = serverData.views["account.analytic.line,false,list"].replace('