62 lines
2.1 KiB
PHP
62 lines
2.1 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$base = "/var/www/html/api/ambre-pw-tests";
|
|
|
|
// Improved spec with shorter timeouts
|
|
$spec = <<<'JS'
|
|
const { test, expect } = require("@playwright/test");
|
|
|
|
const CAPABILITIES = [
|
|
{ name: "PDF", msg: "Genere un PDF sur: demo" },
|
|
{ name: "Word", msg: "Genere un document Word sur: demo" },
|
|
{ name: "PPT", msg: "Genere une presentation sur: demo" },
|
|
{ name: "Mermaid", msg: "Genere un schema mermaid pour: demo" },
|
|
{ name: "Image", msg: "Genere une image: demo" },
|
|
{ name: "Code", msg: "Ecris le code python pour: fibonacci" },
|
|
{ name: "Traduire", msg: "Traduis en anglais: bonjour" },
|
|
{ name: "Ping", msg: "ping" },
|
|
];
|
|
|
|
test("8 capabilities wevia chat v2", async ({ page }) => {
|
|
test.setTimeout(240000);
|
|
|
|
await page.goto("/wevia.html");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.waitForTimeout(1200);
|
|
await page.screenshot({ path: "output/v2-00-initial.png" });
|
|
console.log("📸 Initial state captured");
|
|
|
|
const input = page.locator("#msgInput");
|
|
|
|
for (let i = 0; i < CAPABILITIES.length; i++) {
|
|
const cap = CAPABILITIES[i];
|
|
const num = String(i + 1).padStart(2, "0");
|
|
console.log(`[${num}] ${cap.name}: ${cap.msg}`);
|
|
|
|
try {
|
|
await input.click({ timeout: 5000 });
|
|
await input.fill(cap.msg);
|
|
await page.waitForTimeout(300);
|
|
await input.press("Enter");
|
|
|
|
// Wait for response message to appear (shorter timeout)
|
|
await page.waitForTimeout(15000); // 15s fixed wait per test
|
|
|
|
await page.screenshot({ path: `output/v2-${num}-${cap.name}.png` });
|
|
console.log(` ✅ ${cap.name} screenshot`);
|
|
} catch (e) {
|
|
console.log(` ⚠️ ${cap.name} error: ${e.message.substring(0, 80)}`);
|
|
}
|
|
}
|
|
|
|
await page.screenshot({ path: "output/v2-99-final.png", fullPage: true });
|
|
console.log("✅ Test 8/8 terminé");
|
|
});
|
|
JS;
|
|
file_put_contents("$base/tests/chat-capabilities-v2.spec.js", $spec);
|
|
|
|
// Remove old spec to not rerun
|
|
@unlink("$base/tests/chat-capabilities.spec.js");
|
|
|
|
echo json_encode(["ok"=>true, "new_spec"=>filesize("$base/tests/chat-capabilities-v2.spec.js")]);
|