[FIX] web: add more details when an error dialog is detected
Before this commit, when the clickbot detected an error dialog, it stopped the test and throw an error saying that an error dialog was detected. This information is not enough to check why, and how, the error dialog was produced. Now, we also log the content of the error dialog as well as all the information of the last rpc that was in error. closes odoo/odoo#160103 closes odoo/odoo#160272 X-original-commit: 4f26b324a30c5120ea60b6b42fef6cd6000d2859 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
@@ -23,6 +23,7 @@ const STUDIO_SYSTRAY_ICON_SELECTOR = ".o_web_studio_navbar_item:not(.o_disabled)
|
||||
let isEnterprise;
|
||||
let appsMenusOnly = false;
|
||||
let calledRPC;
|
||||
let errorRPC;
|
||||
let actionCount;
|
||||
let env;
|
||||
let studioCount;
|
||||
@@ -46,6 +47,7 @@ function setup() {
|
||||
env.bus.addEventListener("RPC:RESPONSE", onRPCResponse);
|
||||
actionCount = 0;
|
||||
calledRPC = {};
|
||||
errorRPC = undefined;
|
||||
studioCount = 0;
|
||||
testedApps = [];
|
||||
testedMenus = [];
|
||||
@@ -63,6 +65,9 @@ function onRPCRequest({ detail }) {
|
||||
|
||||
function onRPCResponse({ detail }) {
|
||||
delete calledRPC[detail.data.id];
|
||||
if (detail.error) {
|
||||
errorRPC = { ...detail };
|
||||
}
|
||||
}
|
||||
|
||||
function uiUpdate() {
|
||||
@@ -128,11 +133,22 @@ async function waitForCondition(stopCondition) {
|
||||
}
|
||||
return size > 0;
|
||||
}
|
||||
|
||||
while (!stopCondition() || hasPendingRPC() || hasScheduledTask()) {
|
||||
function errorDialog() {
|
||||
if (document.querySelector(".o_error_dialog")) {
|
||||
throw new Error("Error dialog detected");
|
||||
if (errorRPC) {
|
||||
browser.console.error(
|
||||
"A RPC in error was detected, maybe it's related to the error dialog : " +
|
||||
JSON.stringify(errorRPC)
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
"Error dialog detected" + document.querySelector(".o_error_dialog").innerHTML
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
while (errorDialog() || !stopCondition() || hasPendingRPC() || hasScheduledTask()) {
|
||||
if (timeLimit <= 0) {
|
||||
let msg = `Timeout, the clicked element took more than ${
|
||||
initialTime / 1000
|
||||
|
||||
@@ -79,7 +79,14 @@ export function makeFakeRPCService(mockRPC) {
|
||||
env.bus.trigger("RPC:RESPONSE", { data, settings, result });
|
||||
resolve(result);
|
||||
})
|
||||
.catch(reject);
|
||||
.catch((error) => {
|
||||
env.bus.trigger("RPC:RESPONSE", {
|
||||
data,
|
||||
settings,
|
||||
error,
|
||||
});
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
rpcProm.abort = (rejectError = true) => {
|
||||
if (rejectError) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { ListRenderer } from "@web/views/list/list_renderer";
|
||||
import { onWillStart, onWillUpdateProps } from "@odoo/owl";
|
||||
import { errorService } from "@web/core/errors/error_service";
|
||||
import { makeServerError } from "@web/../tests/helpers/mock_server";
|
||||
|
||||
let serverData;
|
||||
let clickEverywhereDef;
|
||||
@@ -317,6 +319,67 @@ QUnit.module("clickbot", (hooks) => {
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("clickbot show rpc error when an error dialog is detected", async (assert) => {
|
||||
let clickBotStarted = false;
|
||||
registry.category("services").add("error", errorService);
|
||||
serverData.actions = {
|
||||
1001: {
|
||||
id: 1,
|
||||
name: "App1",
|
||||
res_model: "foo",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"]],
|
||||
},
|
||||
};
|
||||
serverData.menus = {
|
||||
root: { id: "root", children: [1], name: "root", appID: "root" },
|
||||
1: { id: 1, children: [], name: "App1", appID: 1, actionID: 1001, xmlid: "app1" },
|
||||
};
|
||||
patchWithCleanup(browser, {
|
||||
console: {
|
||||
log: (msg) => {
|
||||
if (msg === "test successful") {
|
||||
assert.step(msg);
|
||||
clickEverywhereDef.resolve();
|
||||
}
|
||||
},
|
||||
error: (msg) => {
|
||||
assert.step(msg.toString());
|
||||
clickEverywhereDef.resolve();
|
||||
},
|
||||
},
|
||||
});
|
||||
let id = 1;
|
||||
await createWebClient({
|
||||
serverData,
|
||||
mockRPC: async function (route, args) {
|
||||
if (args.method === "web_search_read") {
|
||||
if (clickBotStarted) {
|
||||
if (id === 3) {
|
||||
// click on the Second Filter
|
||||
throw makeServerError({
|
||||
message:
|
||||
"This is a server Error, it should be displayed in an error dialog",
|
||||
});
|
||||
}
|
||||
id++;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
clickBotStarted = true;
|
||||
|
||||
clickEverywhereDef = makeDeferred();
|
||||
window.clickEverywhere();
|
||||
await clickEverywhereDef;
|
||||
await nextTick();
|
||||
assert.verifySteps([
|
||||
'A RPC in error was detected, maybe it\'s related to the error dialog : {"data":{"id":6,"jsonrpc":"2.0","method":"call","params":{"model":"foo","method":"web_search_read","args":[],"kwargs":{"specification":{"foo":{}},"offset":0,"order":"","limit":80,"context":{"lang":"en","uid":7,"tz":"taht","bin_size":true},"count_limit":10001,"domain":["|",["bar","=",false],"&",["date",">=","2024-04-01"],["date","<=","2024-04-30"]]}}},"settings":{"silent":false},"error":{"name":"RPC_ERROR","type":"server","code":200,"data":{"name":"odoo.exceptions.UserError","debug":"traceback","arguments":[],"context":{}},"exceptionName":"odoo.exceptions.UserError","message":"This is a server Error, it should be displayed in an error dialog","errorEvent":{"isTrusted":true}}}',
|
||||
"Error while testing App1 app1",
|
||||
'Error: Error dialog detected<header class="modal-header"><h4 class="modal-title text-break">Odoo Error</h4><button type="button" class="btn-close" aria-label="Close" tabindex="-1"></button></header><footer class="modal-footer justify-content-around justify-content-sm-start flex-wrap gap-1 w-100" style="order:2"><button class="btn btn-primary o-default-button">Close</button><button class="btn btn-secondary"><i class="fa fa-clipboard mr8"></i>Copy error to clipboard</button></footer><main class="modal-body"><div role="alert"><p class="text-prewrap"><p><b>An error occurred</b></p><p>Please use the copy button to report the error to your support service.</p></p><button class="btn btn-link">See details</button></div></main>',
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("clickbot test waiting render after clicking filter", async (assert) => {
|
||||
let clickBotStarted = false;
|
||||
serverData.actions = {
|
||||
|
||||
Reference in New Issue
Block a user