74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$base = "/var/www/html/api/ambre-pw-tests";
|
|
$spec = <<<'JS'
|
|
const { test, expect } = require("@playwright/test");
|
|
|
|
test("debug router click flow", async ({ page }) => {
|
|
test.setTimeout(120000);
|
|
|
|
// Capture console logs
|
|
const logs = [];
|
|
page.on("console", msg => {
|
|
logs.push(`[${msg.type()}] ${msg.text().substring(0, 300)}`);
|
|
});
|
|
|
|
// Inject diagnostic script
|
|
await page.addInitScript(() => {
|
|
window.__ambre_fetch_calls = [];
|
|
const origFetch = window.fetch;
|
|
window.fetch = function(...args) {
|
|
window.__ambre_fetch_calls.push({url: args[0], body: args[1] && args[1].body ? args[1].body.toString().substring(0, 200) : null});
|
|
return origFetch.apply(this, args);
|
|
};
|
|
});
|
|
|
|
await page.goto("/wevia.html");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.waitForTimeout(1500);
|
|
|
|
// Send PDF
|
|
const input = page.locator("#msgInput");
|
|
await input.fill("Genere un PDF sur: test debug");
|
|
await input.press("Enter");
|
|
await page.waitForTimeout(8000);
|
|
|
|
// Dump state
|
|
const state = await page.evaluate(() => ({
|
|
busy: typeof busy !== "undefined" ? busy : "undefined",
|
|
pendingFile: typeof pendingFile !== "undefined" ? pendingFile : "undefined",
|
|
fetch_calls: window.__ambre_fetch_calls || [],
|
|
msg_input_disabled: document.getElementById("msgInput").disabled,
|
|
msg_input_value: document.getElementById("msgInput").value,
|
|
assistant_count: document.querySelectorAll(".msg.assistant").length,
|
|
user_count: document.querySelectorAll(".msg.user").length,
|
|
has_router: !!window._ambre_gen_pat,
|
|
}));
|
|
|
|
console.log("=== STATE AFTER PDF SEND ===");
|
|
console.log(JSON.stringify(state, null, 2));
|
|
|
|
// Now try 2nd message
|
|
await input.fill("Genere un document Word sur: test2");
|
|
await input.press("Enter");
|
|
await page.waitForTimeout(8000);
|
|
|
|
const state2 = await page.evaluate(() => ({
|
|
busy: typeof busy !== "undefined" ? busy : "undefined",
|
|
fetch_calls_count: (window.__ambre_fetch_calls || []).length,
|
|
last_fetch: (window.__ambre_fetch_calls || []).slice(-3),
|
|
assistant_count: document.querySelectorAll(".msg.assistant").length,
|
|
user_count: document.querySelectorAll(".msg.user").length,
|
|
}));
|
|
console.log("=== STATE AFTER WORD SEND ===");
|
|
console.log(JSON.stringify(state2, null, 2));
|
|
|
|
// Write logs to file
|
|
require("fs").writeFileSync("output/debug-console.log", logs.join("\n"));
|
|
});
|
|
JS;
|
|
file_put_contents("$base/tests/debug-flow.spec.js", $spec);
|
|
// Remove v5 to not rerun
|
|
@unlink("$base/tests/chat-capabilities-v5.spec.js");
|
|
echo json_encode(["ok"=>true, "size"=>filesize("$base/tests/debug-flow.spec.js")]);
|