109 lines
4.3 KiB
PHP
109 lines
4.3 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$base = "/var/www/html/api/ambre-pw-tests";
|
|
|
|
// V4 spec — use send button click + wait for assistant message count to increment
|
|
$spec = <<<'JS'
|
|
const { test, expect } = require("@playwright/test");
|
|
|
|
const CAPABILITIES = [
|
|
{ name: "PDF", msg: "Genere un PDF sur: WEVIA enterprise demo", needle: ".pdf" },
|
|
{ name: "Word", msg: "Genere un document Word sur: strategie pharma", needle: ".docx" },
|
|
{ name: "PPT", msg: "Genere une presentation sur: pitch investor", needle: ".pptx" },
|
|
{ name: "Mermaid", msg: "Genere un schema mermaid pour: workflow vente", needle: "graph TD" },
|
|
{ name: "Image", msg: "Genere une image: paysage montagne", needle: ".svg" },
|
|
{ name: "Code", msg: "Ecris le code python pour: fibonacci", needle: ".py" },
|
|
{ name: "Traduire", msg: "Traduis en anglais: bonjour merci", needle: "English:" },
|
|
{ name: "Ping", msg: "ping", needle: "WEVIA Engine" },
|
|
];
|
|
|
|
test("8 capabilities v4 video proof", async ({ page }) => {
|
|
test.setTimeout(480000);
|
|
|
|
await page.goto("/wevia.html");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.waitForTimeout(2000);
|
|
await page.screenshot({ path: "output/v4-00-initial.png", fullPage: false });
|
|
console.log("📸 Initial 1920x1080");
|
|
|
|
for (let i = 0; i < CAPABILITIES.length; i++) {
|
|
const cap = CAPABILITIES[i];
|
|
const num = String(i + 1).padStart(2, "0");
|
|
console.log(`\n[${num}/8] ${cap.name}: ${cap.msg}`);
|
|
|
|
try {
|
|
// Count assistant messages BEFORE sending
|
|
const beforeCount = await page.evaluate(() =>
|
|
document.querySelectorAll(".msg.assistant").length
|
|
);
|
|
|
|
// Focus input aggressively, clear, fill
|
|
const input = page.locator("#msgInput");
|
|
await input.click({ force: true, timeout: 5000 });
|
|
await page.keyboard.press("Control+A");
|
|
await page.keyboard.press("Delete");
|
|
await page.waitForTimeout(200);
|
|
await input.fill(cap.msg);
|
|
await page.waitForTimeout(300);
|
|
|
|
// Click send button (more reliable than Enter)
|
|
const sendBtn = await page.locator(".send-btn, #sendBtn, button[onclick*=send], button.send").first();
|
|
try {
|
|
await sendBtn.click({ force: true, timeout: 3000 });
|
|
} catch (e) {
|
|
// fallback Enter
|
|
await input.press("Enter");
|
|
}
|
|
console.log(` 📤 Sent (msg count before: ${beforeCount})`);
|
|
|
|
// Wait for NEW assistant message to appear + contain needle
|
|
const waitStart = Date.now();
|
|
let found = false;
|
|
let msgAdded = false;
|
|
while (Date.now() - waitStart < 45000) {
|
|
const afterCount = await page.evaluate(() =>
|
|
document.querySelectorAll(".msg.assistant").length
|
|
);
|
|
if (afterCount > beforeCount) {
|
|
msgAdded = true;
|
|
const bodyText = await page.evaluate(() => document.body.innerText);
|
|
if (bodyText.includes(cap.needle)) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
await page.waitForTimeout(1000);
|
|
}
|
|
const elapsed = ((Date.now() - waitStart) / 1000).toFixed(1);
|
|
|
|
if (found) console.log(` ✅ "${cap.needle}" found after ${elapsed}s (msg added: ${msgAdded})`);
|
|
else console.log(` ⚠️ needle not found · ${elapsed}s · msg added: ${msgAdded}`);
|
|
|
|
// Scroll to bottom
|
|
await page.evaluate(() => {
|
|
const msgs = document.getElementById("messages");
|
|
if (msgs) msgs.scrollTop = msgs.scrollHeight;
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
});
|
|
await page.waitForTimeout(1500);
|
|
|
|
// Full page screenshot
|
|
await page.screenshot({ path: `output/v4-${num}-${cap.name}.png`, fullPage: true });
|
|
console.log(` 📸 v4-${num}-${cap.name}.png`);
|
|
|
|
} catch (e) {
|
|
console.log(` ❌ ${e.message.substring(0, 100)}`);
|
|
}
|
|
}
|
|
|
|
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
|
await page.waitForTimeout(2000);
|
|
await page.screenshot({ path: "output/v4-99-final.png", fullPage: true });
|
|
console.log("\n✅ Test V4 8/8 terminé");
|
|
});
|
|
JS;
|
|
file_put_contents("$base/tests/chat-capabilities-v4.spec.js", $spec);
|
|
@unlink("$base/tests/chat-capabilities-v3.spec.js");
|
|
|
|
echo json_encode(["ok"=>true, "spec_size"=>filesize("$base/tests/chat-capabilities-v4.spec.js")]);
|