1
0
forked from Mapan/odoo17e
odoo17e-kedaikipas58/addons/web_studio/static/tests/tours/tour_helpers.js
2024-12-10 09:04:09 +07:00

34 lines
1.0 KiB
JavaScript

/** @odoo-module */
export function assertEqual(actual, expected) {
if (actual !== expected) {
throw new Error(`Assert failed: expected: ${expected} ; got: ${actual}`);
}
}
export async function nextTick() {
await new Promise((resolve) => setTimeout(resolve));
await new Promise((resolve) => requestAnimationFrame(resolve));
}
export function stepNextTick() {
// FIXME: this probably should be handled by the tour-as-macro infrastructure
// The case is to have a dom node with a constant selector. It will trigger the next step
// even though the element will be changed after, resulting in non-deterministic bugs.
// This is especially the case in the case of inputs, where we'd want to assert their value changed
return {
trigger: "body",
run() {
return nextTick();
},
};
}
export function stepNotInStudio(trigger) {
return {
extra_trigger: "body:not(:has(.o_studio))",
trigger: trigger || "body",
isCheck: true,
};
}