feat(forge): assistant IA partage et plein ecran Forge/Editer (#101)
This commit is contained in:
@@ -381,6 +381,77 @@ test("utils.js saveFile restores the save button when the request fails", () =>
|
||||
assert.match(utilsSrc, /console\.error\("Save error:", err\);\s*\n\s*resetSaveButton\(\);/);
|
||||
});
|
||||
|
||||
// ── #101: Forge uses the shared AI assistant + native fullscreen ──
|
||||
test("editor-poc.html opens the shared AI assistant from its AI button", () => {
|
||||
assert.ok(!/id="ai-panel"/.test(forgeSrc), "Forge mini AI panel markup must be gone");
|
||||
assert.match(forgeSrc, /postMessage\(\{ type: 'forge-open-ai' \}, '\*'\)/);
|
||||
assert.match(forgeSrc, /btnAI\.addEventListener\('click', openAssistant\)/);
|
||||
});
|
||||
|
||||
test("sync.js routes forge-open-ai to the BooksLM assistant", () => {
|
||||
const handler = syncSrc.match(/if \(e\.data\.type === 'forge-open-ai'\) \{([\s\S]*?)\n \}/);
|
||||
assert.ok(handler, "forge-open-ai handler not found");
|
||||
assert.match(handler[1], /import\('\.\/bookslm\.js'\)/);
|
||||
assert.match(handler[1], /openForCurrentContext\(\)/);
|
||||
});
|
||||
|
||||
test("editor-poc.html AI calls use the assistant's configured provider/model", () => {
|
||||
const pick = forgeSrc.match(/function aiPickerSelection\(\) \{([\s\S]*?)\n \}/);
|
||||
assert.ok(pick, "aiPickerSelection not found");
|
||||
assert.match(pick[1], /obsigate_ai_picker/);
|
||||
assert.match(forgeSrc, /var pick = aiPickerSelection\(\);/);
|
||||
assert.match(forgeSrc, /Object\.keys\(pick\)\.forEach/);
|
||||
});
|
||||
|
||||
test("editor-poc.html fixes AI endpoint names and translate param", () => {
|
||||
assert.match(forgeSrc, /'ai-longer':\s*\{ ep: 'make-longer'/);
|
||||
assert.match(forgeSrc, /'ai-shorter':\s*\{ ep: 'make-shorter'/);
|
||||
assert.match(forgeSrc, /'ai-translate':\s*\{ ep: 'translate', extra: \{ target_lang: 'en' \}/);
|
||||
});
|
||||
|
||||
test("editor-poc.html ghost completion follows the configured provider", () => {
|
||||
assert.match(forgeSrc, /ghostBody\.provider = ghostPick\.provider \|\| 'ollama';/);
|
||||
assert.match(forgeSrc, /ghostBody\.model = ghostPick\.model;/);
|
||||
});
|
||||
|
||||
test("editor-poc.html has a native fullscreen button", () => {
|
||||
assert.match(forgeSrc, /id="btn-fullscreen"/);
|
||||
assert.match(forgeSrc, /document\.documentElement\.requestFullscreen/);
|
||||
assert.match(forgeSrc, /document\.addEventListener\('fullscreenchange'/);
|
||||
});
|
||||
|
||||
test("viewer.js allows fullscreen in the Forge iframe", () => {
|
||||
assert.match(viewerSrc, /iframe\.setAttribute\("allow", "fullscreen"\)/);
|
||||
});
|
||||
|
||||
test("index.html has an editor fullscreen button with i18n title", () => {
|
||||
assert.match(indexSrc, /id="editor-fullscreen"/);
|
||||
assert.match(indexSrc, /data-i18n-attr="title:editor\.fullscreen"/);
|
||||
});
|
||||
|
||||
test("utils.js wires the editor fullscreen button and exits on close", () => {
|
||||
assert.match(utilsSrc, /function toggleEditorFullscreen\(\)/);
|
||||
assert.match(utilsSrc, /function updateFullscreenButton\(\)/);
|
||||
assert.match(utilsSrc, /document\.addEventListener\("fullscreenchange", updateFullscreenButton\)/);
|
||||
const close = utilsSrc.match(/function closeEditor\(\) \{([\s\S]*?)\n\}/);
|
||||
assert.ok(close, "closeEditor not found");
|
||||
assert.match(close[1], /document\.exitFullscreen\(\)/);
|
||||
});
|
||||
|
||||
test("style.css makes the editor fill the screen in fullscreen", () => {
|
||||
assert.match(cssSrc, /\.editor-container:fullscreen \{/);
|
||||
assert.match(cssSrc, /\.editor-container:fullscreen \{[\s\S]*?height: 100vh;/);
|
||||
});
|
||||
|
||||
test("locales expose the fullscreen labels (FR + EN)", () => {
|
||||
const fr = JSON.parse(read("frontend", "locales", "fr.json"));
|
||||
const en = JSON.parse(read("frontend", "locales", "en.json"));
|
||||
for (const key of ["editor.fullscreen", "editor.exit_fullscreen"]) {
|
||||
assert.ok(fr[key], `fr.json missing ${key}`);
|
||||
assert.ok(en[key], `en.json missing ${key}`);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`\n${testCount - failCount}/${testCount} tests passed`);
|
||||
if (failCount > 0) {
|
||||
console.error(`${failCount} test(s) failed`);
|
||||
|
||||
Reference in New Issue
Block a user