[IMP] web: use of a default OS for tests
The purpose of this commit is to have a test environment that does not depend on the OS of the machine on which the Odoo server is deployed. Because the navigator.platform is deprecated, we will use the navigator.userAgent to identify the OS.
This commit is contained in:
@@ -16,7 +16,7 @@ export function isBrowserChrome() {
|
||||
}
|
||||
|
||||
export function isMacOS() {
|
||||
return Boolean(browser.navigator.platform.match(/Mac/i));
|
||||
return Boolean(browser.navigator.userAgent.match(/Mac/i));
|
||||
}
|
||||
|
||||
export function isMobileOS() {
|
||||
|
||||
@@ -139,12 +139,6 @@ QUnit.test("hook", async (assert) => {
|
||||
QUnit.test("non-MacOS usability", async (assert) => {
|
||||
assert.expect(6);
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "OdooOS",
|
||||
},
|
||||
});
|
||||
|
||||
const hotkey = env.services.hotkey;
|
||||
const key = "q";
|
||||
|
||||
@@ -186,7 +180,7 @@ QUnit.test("MacOS usability", async (assert) => {
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "Mac",
|
||||
userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -491,12 +485,6 @@ QUnit.test("registrations and elements belong to the correct UI owner", async (a
|
||||
QUnit.test("replace the overlayModifier for non-MacOs", async (assert) => {
|
||||
assert.expect(3);
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "OdooOS",
|
||||
},
|
||||
});
|
||||
|
||||
const hotkeyService = serviceRegistry.get("hotkey");
|
||||
patchWithCleanup(hotkeyService, {
|
||||
overlayModifier: "alt+shift",
|
||||
@@ -531,7 +519,7 @@ QUnit.test("replace the overlayModifier for MacOs", async (assert) => {
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "Mac",
|
||||
userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -199,6 +199,7 @@ export function triggerHotkey(hotkey, addOverlayModParts = false, eventAttrs = {
|
||||
}
|
||||
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", eventAttrs));
|
||||
window.dispatchEvent(new KeyboardEvent("keyup", eventAttrs));
|
||||
}
|
||||
|
||||
export async function legacyExtraNextTick() {
|
||||
|
||||
@@ -113,6 +113,9 @@ function patchBrowserWithCleanup() {
|
||||
originalRemoveEventListener(...arguments);
|
||||
});
|
||||
},
|
||||
navigator: {
|
||||
userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(X11; Linux x86_64)"),
|
||||
},
|
||||
// in tests, we never want to interact with the real url or reload the page
|
||||
location: mockLocation,
|
||||
history: {
|
||||
|
||||
@@ -406,12 +406,6 @@ QUnit.test("data-command-category", async (assert) => {
|
||||
});
|
||||
|
||||
QUnit.test("display shortcuts correctly for non-MacOS ", async (assert) => {
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "OdooOS",
|
||||
},
|
||||
});
|
||||
|
||||
class MyComponent extends Component {}
|
||||
MyComponent.components = { TestComponent };
|
||||
MyComponent.template = xml`
|
||||
@@ -448,7 +442,7 @@ QUnit.test("display shortcuts correctly for non-MacOS ", async (assert) => {
|
||||
QUnit.test("display shortcuts correctly for MacOS ", async (assert) => {
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "Mac",
|
||||
userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -488,12 +482,6 @@ QUnit.test("display shortcuts correctly for MacOS ", async (assert) => {
|
||||
QUnit.test(
|
||||
"display shortcuts correctly for non-MacOS with a new overlayModifier",
|
||||
async (assert) => {
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "OdooOS",
|
||||
},
|
||||
});
|
||||
|
||||
const hotkeyService = serviceRegistry.get("hotkey");
|
||||
patchWithCleanup(hotkeyService, {
|
||||
overlayModifier: "alt+control",
|
||||
@@ -523,7 +511,7 @@ QUnit.test(
|
||||
QUnit.test("display shortcuts correctly for MacOS with a new overlayModifier", async (assert) => {
|
||||
patchWithCleanup(browser, {
|
||||
navigator: {
|
||||
platform: "Mac",
|
||||
userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user