初始提交

This commit is contained in:
2026-11-04 19:58:07 +08:00
commit 53b7d22429
829 changed files with 469986 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { registry } from "@web/core/registry";
import { deliverAIResults, setupAIResults } from "@ai/../tests/tours/ai_tour_helpers";
/**
* This tour sends the user message and asserts the graph view opens
* with the date-groupby facet active.
*/
registry.category("web_tour.tours").add("ai_open_menu_graph_tour", {
steps: () => [
{
trigger: ".o_navbar button[title='Ask AI']",
run: "click",
},
setupAIResults(),
{
trigger: ".o-mail-ChatWindow .o-mail-Composer-input",
run: "edit graph view of contacts per month",
},
{
trigger: ".o-mail-ChatWindow .o-mail-Composer button[title^='Send']:enabled",
run: "click",
},
deliverAIResults(),
// Graph view must open via the action emitted by _ai_tool_open_menu_graph.
{
trigger: ".o_action_manager .o_graph_view",
},
// `applyAISearch` -> `createNewGroupBy('create_date', {interval:'month'})`
{
trigger: ".o_searchview .o_facet_values:contains(Created on: Month)",
},
deliverAIResults(),
{
trigger: ".o-mail-ChatWindow .o-mail-Message-body:contains(Here is your graph)",
},
],
});

View File

@@ -0,0 +1,40 @@
const callbacks = [];
/** Listen for replies captured by the mocked IAP submission. */
export function setupAIResults(trigger = ".o-mail-ChatWindow") {
return {
content: "Listen for mocked IAP results",
trigger,
async run() {
callbacks.length = 0;
const busService = odoo.__WOWL_DEBUG__.root.env.services.bus_service;
// Each tour subscribes once and closes its browser afterward, so no manual unsubscribe is needed.
busService.subscribe("ai.test/callbacks_ready", (callback) => {
callbacks.push(callback);
});
await busService.start();
},
};
}
/** Deliver this round's mocked callbacks, including its optional chat-title reply. */
export function deliverAIResults() {
return {
content: "Deliver the mocked IAP results for this round",
trigger: "body",
async run({ waitUntil }) {
await waitUntil(() => callbacks.length > 0);
const batch = callbacks.splice(0);
for (const callback of batch) {
const response = await fetch("/ai/completion_result_ready", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(callback),
});
if (!response.ok) {
throw new Error(await response.text());
}
}
},
};
}