初始提交
This commit is contained in:
55
mail_enterprise/static/tests/messaging_menu_patch.test.js
Normal file
55
mail_enterprise/static/tests/messaging_menu_patch.test.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
click,
|
||||
contains,
|
||||
defineMailModels,
|
||||
patchUiSize,
|
||||
SIZES,
|
||||
start,
|
||||
} from "@mail/../tests/mail_test_helpers";
|
||||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { methods } from "@web_mobile/js/services/core";
|
||||
import { mockUserAgent } from "@odoo/hoot-mock";
|
||||
|
||||
describe.current.tags("mobile");
|
||||
defineMailModels();
|
||||
|
||||
test("'backbutton' event should close messaging menu", async () => {
|
||||
mockUserAgent("android");
|
||||
patchUiSize({ size: SIZES.SM });
|
||||
// simulate the feature is available on the current device
|
||||
// component must and will be destroyed before the overrideBackButton is unpatched
|
||||
patchWithCleanup(methods, {
|
||||
overrideBackButton({ enabled }) {},
|
||||
});
|
||||
await start();
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
|
||||
await contains(".o-mail-MessagingMenu");
|
||||
// simulate 'backbutton' event triggered by the mobile app
|
||||
const backButtonEvent = new Event("backbutton");
|
||||
document.dispatchEvent(backButtonEvent);
|
||||
await contains(".o-mail-MessagingMenu", { count: 0 });
|
||||
});
|
||||
|
||||
test("[technical] messaging menu should properly override the back button", async () => {
|
||||
mockUserAgent("android");
|
||||
patchUiSize({ size: SIZES.SM });
|
||||
// simulate the feature is available on the current device
|
||||
// component must and will be destroyed before the overrideBackButton is unpatched
|
||||
let overrideBackButton = false;
|
||||
patchWithCleanup(methods, {
|
||||
overrideBackButton({ enabled }) {
|
||||
overrideBackButton = enabled;
|
||||
},
|
||||
});
|
||||
await start();
|
||||
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
await contains(".o-mail-MessagingMenu");
|
||||
expect(overrideBackButton).toBe(true);
|
||||
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
await contains(".o-mail-MessagingMenu", { count: 0 });
|
||||
expect(overrideBackButton).toBe(false);
|
||||
});
|
||||
Reference in New Issue
Block a user