Files
odoo_source/addons/test_mail/static/tests/mobile/activity_tests.js
T
Romain Estievenart a10967214b [FIX] mail, test_mail: h-scroll broken on small screen
This commit add the missing `o_action_delegate_scroll` on the activity
view controller on small screen device to scroll the activity view
content only instead of the whole controller (i.e. control panel
included).

Steps to reproduce:

1. Open Project on small screen device like a smartphone
2. Open a Project like 'Office Design'
3. Switch to the Activity view and try to scroll horizontally
 => The whole activity controller currently scroll => bug

closes odoo/odoo#110531

X-original-commit: e4d6a8ad14abee72d61fd01d8b601acc6bfa2c49
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Signed-off-by: Romain Estievenart (res) <res@odoo.com>
2023-01-20 21:56:48 +01:00

50 lines
2.1 KiB
JavaScript

/** @odoo-module **/
import { start } from "@mail/../tests/helpers/test_utils";
import { prepareTarget } from "web.test_utils";
QUnit.module("test_mail", () => {
QUnit.module("activity view mobile");
QUnit.test("horizontal scroll applies only to the content, not to the whole controller", async (assert) => {
const viewPort = prepareTarget();
viewPort.style.position = "initial";
viewPort.style.width = "initial";
const { openView } = await start();
await openView({
res_model: "mail.test.activity",
views: [[false, "activity"]],
});
const o_view_controller = document.querySelector(".o_view_controller");
const o_content = o_view_controller.querySelector(".o_content");
const o_cp_item = o_view_controller.querySelector(".o_control_panel .breadcrumb-item.active");
const initialXCpItem = o_cp_item.getBoundingClientRect().x;
const o_header_cell = o_content.querySelector(".o_activity_type_cell");
const initialXHeaderCell = o_header_cell.getBoundingClientRect().x;
assert.hasClass(o_view_controller, "o_action_delegate_scroll",
"the 'o_view_controller' should be have the 'o_action_delegate_scroll'.");
assert.strictEqual(window.getComputedStyle(o_view_controller).overflow, "hidden",
"the view controller should have overflow hidden");
assert.strictEqual(window.getComputedStyle(o_content).overflow, "auto",
"the view content should have the overflow auto");
assert.strictEqual(o_content.scrollLeft, 0, "the o_content should not have scroll value");
// Horizontal scroll
o_content.scrollLeft = 100;
assert.strictEqual(o_content.scrollLeft, 100,
"the o_content should be 100 due to the overflow auto");
assert.ok(o_header_cell.getBoundingClientRect().x < initialXHeaderCell,
"the gantt header cell x position value should be lower after the scroll");
assert.strictEqual(o_cp_item.getBoundingClientRect().x, initialXCpItem,
"the item x position of the control panel button should be the same after the scroll");
viewPort.style.position = "";
viewPort.style.width = "";
});
});