[REF] web: factorize makeDialogTestEnv helper
With this commit, the many identical implementation of `makeDialogTestEnv` are removed in favor of a single helper function. Part-of: odoo/odoo#127565
This commit is contained in:
@@ -4,22 +4,13 @@ import { registry } from "@web/core/registry";
|
||||
import { uiService } from "@web/core/ui/ui_service";
|
||||
import { hotkeyService } from "@web/core/hotkeys/hotkey_service";
|
||||
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
|
||||
import { makeTestEnv } from "../helpers/mock_env";
|
||||
import { makeDialogTestEnv } from "../helpers/mock_env";
|
||||
import { click, getFixture, makeDeferred, mount, nextTick, triggerHotkey } from "../helpers/utils";
|
||||
import { makeFakeDialogService } from "../helpers/mock_services";
|
||||
|
||||
const serviceRegistry = registry.category("services");
|
||||
let target;
|
||||
|
||||
async function makeDialogTestEnv() {
|
||||
const env = await makeTestEnv();
|
||||
env.dialogData = {
|
||||
isActive: true,
|
||||
close: () => {},
|
||||
};
|
||||
return env;
|
||||
}
|
||||
|
||||
QUnit.module("Components", (hooks) => {
|
||||
hooks.beforeEach(async (assert) => {
|
||||
target = getFixture();
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useService } from "@web/core/utils/hooks";
|
||||
import { uiService } from "@web/core/ui/ui_service";
|
||||
import { hotkeyService } from "@web/core/hotkeys/hotkey_service";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { makeTestEnv } from "../helpers/mock_env";
|
||||
import { makeDialogTestEnv } from "../helpers/mock_env";
|
||||
import {
|
||||
click,
|
||||
destroy,
|
||||
@@ -22,15 +22,6 @@ const serviceRegistry = registry.category("services");
|
||||
let parent;
|
||||
let target;
|
||||
|
||||
async function makeDialogTestEnv() {
|
||||
const env = await makeTestEnv();
|
||||
env.dialogData = {
|
||||
isActive: true,
|
||||
close: () => {},
|
||||
};
|
||||
return env;
|
||||
}
|
||||
|
||||
QUnit.module("Components", (hooks) => {
|
||||
hooks.beforeEach(async () => {
|
||||
target = getFixture();
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { registry } from "@web/core/registry";
|
||||
import { uiService } from "@web/core/ui/ui_service";
|
||||
import { hotkeyService } from "@web/core/hotkeys/hotkey_service";
|
||||
import { makeTestEnv } from "../../helpers/mock_env";
|
||||
import { makeDialogTestEnv } from "../../helpers/mock_env";
|
||||
import { makeFakeDialogService, makeFakeLocalizationService } from "../../helpers/mock_services";
|
||||
import { click, getFixture, mount, nextTick, patchWithCleanup } from "../../helpers/utils";
|
||||
|
||||
@@ -20,15 +20,6 @@ let target;
|
||||
let env;
|
||||
const serviceRegistry = registry.category("services");
|
||||
|
||||
async function makeDialogTestEnv() {
|
||||
const env = await makeTestEnv();
|
||||
env.dialogData = {
|
||||
isActive: true,
|
||||
close() {},
|
||||
};
|
||||
return env;
|
||||
}
|
||||
|
||||
QUnit.module("Error dialogs", {
|
||||
async beforeEach() {
|
||||
target = getFixture();
|
||||
|
||||
@@ -132,3 +132,18 @@ export async function makeTestEnv(config = {}) {
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test environment for dialog tests
|
||||
*
|
||||
* @param {*} config
|
||||
* @returns {Promise<OdooEnv>}
|
||||
*/
|
||||
export async function makeDialogTestEnv(config = {}) {
|
||||
const env = await makeTestEnv(config);
|
||||
env.dialogData = {
|
||||
isActive: true,
|
||||
close() {},
|
||||
};
|
||||
return env;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user