Download scripts/verify-browser-e2e.mjs from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 22.5 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/verify-browser-e2e.mjs
- Command line
-
hf download hf://VanyaJ/bada-terminal/scripts/verify-browser-e2e.mjs
-
curl -L -o verify-browser-e2e.mjs https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/verify-browser-e2e.mjs
22.5 kB
| /** | |
| * @file scripts/verify-browser-e2e.mjs | |
| * @description Google Chrome Headless CDP๋ฅผ ํ์ฉํ 5๋จ๊ณ ๋ํํ ํ๋ฅด์๋ ํฉ์ฑ(Persona Synthesis) E2E ๊ฒ์ฆ๊ธฐ. | |
| */ | |
| import { spawn } from 'node:child_process'; | |
| import path from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); | |
| const htmlPath = 'file://' + path.join(rootDir, 'artifacts/bong-app.html'); | |
| const chromePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; | |
| console.log('๐งช [Browser E2E] ์ค์ Google Chrome ๋ธ๋ผ์ฐ์ ๊ธฐ๋ ๋ฐ 5๋จ๊ณ ํ๋ฅด์๋ ํฉ์ฑ ์๋๋ฆฌ์ค ๊ฒ์ฆ ์์...'); | |
| const chromeProc = spawn(chromePath, [ | |
| '--headless=new', | |
| '--remote-debugging-port=9222', | |
| '--disable-gpu', | |
| '--no-first-run', | |
| '--no-default-browser-check', | |
| htmlPath | |
| ]); | |
| await new Promise(res => setTimeout(res, 1200)); | |
| let hasErrors = false; | |
| try { | |
| const listRes = await fetch('http://127.0.0.1:9222/json/list'); | |
| const targets = await listRes.json(); | |
| const pageTarget = targets.find(t => t.type === 'page'); | |
| if (!pageTarget || !pageTarget.webSocketDebuggerUrl) { | |
| throw new Error('CDP Debugger WebSocket ์๋ํฌ์ธํธ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.'); | |
| } | |
| const ws = new WebSocket(pageTarget.webSocketDebuggerUrl); | |
| await new Promise((res, rej) => { ws.onopen = res; ws.onerror = rej; }); | |
| let msgId = 1; | |
| const pendingRequests = new Map(); | |
| ws.onmessage = (event) => { | |
| const data = JSON.parse(event.data); | |
| if (data.method === 'Runtime.exceptionThrown') { | |
| console.error('๐ฅ [Browser Error] ์์ธ ๋ฐ์:', data.params.exceptionDetails); | |
| hasErrors = true; | |
| } | |
| if (data.id && pendingRequests.has(data.id)) { | |
| const resolver = pendingRequests.get(data.id); | |
| pendingRequests.delete(data.id); | |
| resolver(data.result); | |
| } | |
| }; | |
| function sendCommand(method, params = {}) { | |
| return new Promise((resolve) => { | |
| const id = msgId++; | |
| pendingRequests.set(id, resolve); | |
| ws.send(JSON.stringify({ id, method, params })); | |
| }); | |
| } | |
| await sendCommand('Runtime.enable'); | |
| await sendCommand('Page.enable'); | |
| async function evalCode(expression) { | |
| const res = await sendCommand('Runtime.evaluate', { expression, returnByValue: true, awaitPromise: true }); | |
| return res.result ? res.result.value : undefined; | |
| } | |
| // 1. ์ด๊ธฐ ์ ์ ๋ชจ๋ฌ 3๋จ๊ณ ํต๊ณผ ๋ฐ [์ฒซ ์จ ๋ถ์ด๋ฃ๊ณ ๋๋จ๊ธฐ] ๊ฒ์ฆ | |
| const initial = await evalCode(`({ | |
| overlayActive: document.getElementById('genesis-modal-overlay')?.classList.contains('active'), | |
| step1Active: document.getElementById('genesis-step-1')?.classList.contains('active') | |
| })`); | |
| if (!initial?.overlayActive || !initial?.step1Active) { | |
| throw new Error('์ด๊ธฐ ์ํ ๊ฒ์ฆ ์คํจ: ์ ์ ๋ชจ๋ฌ ๋๋ Step 1์ด ํ์ฑํ๋์ง ์์์ต๋๋ค: ' + JSON.stringify(initial)); | |
| } | |
| console.log(' โ 0-1๋จ๊ณ: ํ์์ ์๊ฐ(The Genesis) ๋ง๋ฒ์ฌ ํ์ฑํ ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // Step 1 โ Step 2 | |
| await evalCode(`document.getElementById('btn-genesis-step1-next')?.click()`); | |
| await new Promise(r => setTimeout(r, 150)); | |
| // Step 2 โ Step 3 | |
| await evalCode(`document.getElementById('btn-genesis-step2-next')?.click()`); | |
| await new Promise(r => setTimeout(r, 150)); | |
| // Step 3 ๊ฒ์ฆ: Mories ์ฐ๊ฒฐ ํ์ธ ๋ฐ BADA WebSocket ํ์ธ ๋ฒํผ ํ์ฌ ๋ฐ ๋์ ๊ฒ์ฆ | |
| const step3Buttons = await evalCode(`({ | |
| hasMoriesBtn: !!document.getElementById('btn-genesis-test-mories'), | |
| hasWsBtn: !!document.getElementById('btn-genesis-test-ws'), | |
| hasMoriesFeedback: !!document.getElementById('genesis-mories-feedback'), | |
| hasWsFeedback: !!document.getElementById('genesis-ws-feedback') | |
| })`); | |
| if (!step3Buttons?.hasMoriesBtn || !step3Buttons?.hasWsBtn) { | |
| throw new Error('Step 3 ํ ์คํธ ๋ฒํผ ๋๋ฝ: ' + JSON.stringify(step3Buttons)); | |
| } | |
| // Mories ์ฐ๊ฒฐ ํ์ธ ๋ฒํผ ํด๋ฆญ ํ ์คํธ | |
| await evalCode(`document.getElementById('btn-genesis-test-mories')?.click()`); | |
| await new Promise(r => setTimeout(r, 100)); | |
| const moriesFeedbackCheck = await evalCode(`({ | |
| display: document.getElementById('genesis-mories-feedback')?.style.display, | |
| text: document.getElementById('genesis-mories-feedback')?.innerText || '' | |
| })`); | |
| if (moriesFeedbackCheck?.display === 'none' || !moriesFeedbackCheck?.text) { | |
| throw new Error('Mories ์ฐ๊ฒฐ ํ์ธ ํผ๋๋ฐฑ ๋ฏธํ์: ' + JSON.stringify(moriesFeedbackCheck)); | |
| } | |
| console.log(' โ 0-1.5๋จ๊ณ: Step 3 Mories ๋ฐ BADA WebSocket ์ง๋จ ๋ฒํผ ํ์ฌ ๋ฐ ์๊ฐ ํผ๋๋ฐฑ ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // [์ฒซ ์จ ๋ถ์ด๋ฃ๊ณ ๋๋จ๊ธฐ] ํด๋ฆญ | |
| await evalCode(`document.getElementById('btn-genesis-launch')?.click()`); | |
| await new Promise(r => setTimeout(r, 600)); | |
| const awakeningCheck = await evalCode(`({ | |
| overlayActive: document.getElementById('genesis-modal-overlay')?.classList.contains('active'), | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| isOnboarding: window.isOnboardingActive?.() || false, | |
| step: window.getOnboardingState?.()?.step || '' | |
| })`); | |
| if (awakeningCheck?.overlayActive) { | |
| throw new Error('๋๋จ๊ธฐ ํ ๋ชจ๋ฌ ๋ซ๊ธฐ ์คํจ: ' + JSON.stringify(awakeningCheck)); | |
| } | |
| if (!awakeningCheck?.dialogueText.includes('์ฒซ ์จ') && !awakeningCheck?.dialogueText.includes('๋น์ ์ ๋ญ๋ผ๊ณ ๋ถ๋ฅด๋ฉด')) { | |
| throw new Error('์ฒซ ์จ ๋ฐํ ํ ์คํธ ๋ถ์ผ์น: ' + JSON.stringify(awakeningCheck)); | |
| } | |
| if (awakeningCheck?.step !== 'ask_user_name') { | |
| throw new Error('์จ๋ณด๋ฉ Step 1 ์ํ ์ง์ ์คํจ: ' + JSON.stringify(awakeningCheck)); | |
| } | |
| console.log(' โ 0-2๋จ๊ณ: [์ฒซ ์จ ๋ถ์ด๋ฃ๊ณ ๋๋จ๊ธฐ] ์๋ค๋งํฑ ์ก์ ๋ฐ Step 1("ask_user_name") ๋ฐํ ํ์ธ'); | |
| // 2. Step 1: "๊ธฐ๋ด์ด์ผ" ํ ์คํธ ์ ๋ ฅ โ Step 2 (๊ด๊ณ ์คํ์ผ ์ง๋ฌธ) ์ ํ ๊ฒ์ฆ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '๊ธฐ๋ด์ด์ผ'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 400)); | |
| const step1Result = await evalCode(`({ | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| step: window.getOnboardingState?.()?.step || '', | |
| userName: window.getOnboardingState?.()?.profile?.userName || '' | |
| })`); | |
| if (!step1Result?.userName.includes('๊ธฐ๋ด')) { | |
| throw new Error('Step 1 ์ฌ์ฉ์ ์ด๋ฆ ์ถ์ถ ์คํจ: ' + JSON.stringify(step1Result)); | |
| } | |
| if (step1Result?.step !== 'ask_relationship_style') { | |
| throw new Error('Step 1 โ Step 2 ์ํ ์ ์ด ์คํจ: ' + JSON.stringify(step1Result)); | |
| } | |
| if (!step1Result?.dialogueText.includes('๊ธฐ๋ด') || !step1Result?.dialogueText.includes('์ด๋ค ์ฌ์ด')) { | |
| throw new Error('Step 2 ์ง๋ฌธ ๋ฐํ ๋ถ์ผ์น: ' + JSON.stringify(step1Result)); | |
| } | |
| console.log(` โ 1๋จ๊ณ (ask_user_name): ์ฌ์ฉ์ ์ด๋ฆ '${step1Result.userName}' ์ถ์ถ ๋ฐ Step 2(๊ด๊ณ ์คํ์ผ ์ง๋ฌธ) ์์ ์ฑ๊ณต`); | |
| // 3. Step 2: "์น๊ทผํ ์น๊ตฌ" ํ ์คํธ ์ ๋ ฅ โ Step 3 (๋ก๋ด ์ด๋ฆ ์๋ช ์ง๋ฌธ) ์ ํ ๊ฒ์ฆ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '์น๊ทผํ ์น๊ตฌ'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 400)); | |
| const step2Result = await evalCode(`({ | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| step: window.getOnboardingState?.()?.step || '', | |
| relStyle: window.getOnboardingState?.()?.profile?.relationshipStyle || '' | |
| })`); | |
| if (step2Result?.step !== 'decide_robot_name') { | |
| throw new Error('Step 2 โ Step 3 ์ํ ์ ์ด ์คํจ: ' + JSON.stringify(step2Result)); | |
| } | |
| if (!step2Result?.dialogueText.includes('์ค์ค๋ก๋ฅผ ๋ญ๋ผ๊ณ ๋ถ๋ฅด๋ฉด') && !step2Result?.dialogueText.includes('๋ฃจ๋')) { | |
| throw new Error('Step 3 ์ง๋ฌธ ๋ฐํ ๋ถ์ผ์น: ' + JSON.stringify(step2Result)); | |
| } | |
| console.log(` โ 2๋จ๊ณ (ask_relationship_style): ๊ด๊ณ ์คํ์ผ '${step2Result.relStyle}' ์ ์ฅ ๋ฐ Step 3(๋ก๋ด ์ด๋ฆ ์๋ช ์ง๋ฌธ) ์์ ์ฑ๊ณต`); | |
| // 4. Step 3: "๋ฃจ๋๋ก ํ์" ํ ์คํธ ์ ๋ ฅ โ ์๋จ ์์ด์ ํธ ๋ฑ์ง ์ค์๊ฐ ๊ฐฑ์ ๋ฐ Step 4 ์ ํ ๊ฒ์ฆ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '๋ฃจ๋๋ก ํ์'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 400)); | |
| const step3Result = await evalCode(`({ | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| step: window.getOnboardingState?.()?.step || '', | |
| robotName: window.getOnboardingState?.()?.profile?.robotName || '', | |
| agentBadgeText: document.getElementById('agent-name-text')?.innerText || '', | |
| docTitle: document.title || '' | |
| })`); | |
| if (step3Result?.robotName !== '๋ฃจ๋') { | |
| throw new Error('Step 3 ๋ก๋ด ์ด๋ฆ ์ถ์ถ ์คํจ: ' + JSON.stringify(step3Result)); | |
| } | |
| if (step3Result?.agentBadgeText !== '๋ฃจ๋') { | |
| throw new Error('์๋จ ์์ด์ ํธ ๋ฑ์ง ์ด๋ฆ ์ค์๊ฐ ๊ฐฑ์ ์คํจ: ' + JSON.stringify(step3Result)); | |
| } | |
| if (step3Result?.step !== 'tune_persona_tone') { | |
| throw new Error('Step 3 โ Step 4 ์ํ ์ ์ด ์คํจ: ' + JSON.stringify(step3Result)); | |
| } | |
| if (!step3Result?.dialogueText.includes('๋ฃจ๋') || !step3Result?.dialogueText.includes('๋งํฌ์ ์ฑ๊ฒฉ')) { | |
| throw new Error('Step 4 ์ง๋ฌธ ๋ฐํ ๋ถ์ผ์น: ' + JSON.stringify(step3Result)); | |
| } | |
| console.log(` โ 3๋จ๊ณ (decide_robot_name): ๋ก๋ด ์ด๋ฆ '${step3Result.robotName}' ํ์ , ์๋จ ๋ฑ์ง ์ค์๊ฐ ๊ฐฑ์ ๋ฐ Step 4(ํ๋ฅด์๋ ํค ์ง๋ฌธ) ์์ ์ฑ๊ณต`); | |
| // 5. Step 4: "๊ท์ฝ๊ฒ ํด์ค" ํ ์คํธ ์ ๋ ฅ โ Step 5 (ํ์ ์ถํ, celebrating ๊ฐ์ , ์ธ์ง๊ณต๊ฐ ์๊ตฌ ์ ์ฅ) ๊ฒ์ฆ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '๊ท์ฝ๊ฒ ํด์ค'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 500)); | |
| const step4Result = await evalCode(`({ | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| step: window.getOnboardingState?.()?.step || '', | |
| personaTone: window.getOnboardingState?.()?.profile?.personaTone || '', | |
| isOnboarding: window.isOnboardingActive?.() || false, | |
| emotionText: document.getElementById('emotion-text')?.innerText || '', | |
| savedCogSpace: localStorage.getItem('bong_cognitive_space') ? JSON.parse(localStorage.getItem('bong_cognitive_space')) : null, | |
| savedConfig: localStorage.getItem('bong_genesis_config') ? JSON.parse(localStorage.getItem('bong_genesis_config')) : null | |
| })`); | |
| if (step4Result?.step !== 'completed') { | |
| throw new Error('์จ๋ณด๋ฉ ์๋ฃ(completed) ์ํ ๋๋ฌ ์คํจ: ' + JSON.stringify(step4Result)); | |
| } | |
| if (step4Result?.isOnboarding !== false) { | |
| throw new Error('์จ๋ณด๋ฉ ์๋ฃ ํ ์ผ๋ฐ ๋ํ ๋ชจ๋ ์ ํ ์คํจ (isOnboarding์ด false๊ฐ ์๋)'); | |
| } | |
| if (!step4Result?.dialogueText.includes('๋ชจ๋ ์กฐ์จ์ด ๋๋ฌ์ต๋๋ค') && !step4Result?.dialogueText.includes('๋ฃจ๋์ ๋๋ค')) { | |
| throw new Error('Step 5 ์ถํ ๋ฐํ ๋ถ์ผ์น: ' + JSON.stringify(step4Result)); | |
| } | |
| if (step4Result?.emotionText !== 'CELEBRATING') { | |
| throw new Error('celebrating ๊ฐ์ ์ ํ ์คํจ: ' + step4Result?.emotionText); | |
| } | |
| if (!step4Result?.savedCogSpace || step4Result?.savedCogSpace?.persona?.name !== '๋ฃจ๋') { | |
| throw new Error('CognitiveSpace ์๊ตฌ ์ ์ฅ ๊ฒ์ฆ ์คํจ: ' + JSON.stringify(step4Result?.savedCogSpace)); | |
| } | |
| console.log(' โ 4 & 5๋จ๊ณ (tune_persona_tone & celebrate_birth): ํ๋ฅด์๋ ํค ํ์ , celebrating ๊ฐ์ ์ ์ด ๋ฐ CognitiveSpace ์๊ตฌ ์ ์ฅ ์๋ฃ'); | |
| // 6. 8์ข ๊ฐ์ (happy, thinking, worried, celebrating, curious, sleeping, alert, neutral) 60fps ์๊ฐ ๋ ๋๋ง ๋ฐ ๋๊ธฐํ ๊ฒ์ฆ | |
| const emotionsToTest = ['happy', 'thinking', 'worried', 'celebrating', 'curious', 'sleeping', 'alert', 'neutral']; | |
| for (const emo of emotionsToTest) { | |
| await evalCode(`window.BongAppShellBridge.updateState({ currentEmotion: '${emo}' })`); | |
| await new Promise(r => setTimeout(r, 60)); | |
| const emoCheck = await evalCode(`({ | |
| badgeText: document.getElementById('emotion-text')?.innerText || '', | |
| hasSvg: !!document.querySelector('#avatar-container svg'), | |
| hasLeftEye: !!document.querySelector('#avatar-container #avatar-left-eye'), | |
| hasMouth: !!document.querySelector('#avatar-container #avatar-mouth'), | |
| hasCheeks: !!document.querySelector('#avatar-container .bong-cheeks') | |
| })`); | |
| if (emoCheck?.badgeText?.toLowerCase() !== emo.toLowerCase()) { | |
| throw new Error(`๊ฐ์ ํ๊ทธ ๋ฑ์ง ๋๊ธฐํ ์คํจ (${emo}): ` + JSON.stringify(emoCheck)); | |
| } | |
| if (!emoCheck?.hasSvg || !emoCheck?.hasLeftEye || !emoCheck?.hasMouth || !emoCheck?.hasCheeks) { | |
| throw new Error(`SVG ์ค์๊ฐ ๋ ๋๋ง ์คํจ (${emo}): ` + JSON.stringify(emoCheck)); | |
| } | |
| } | |
| console.log(' โ 6๋จ๊ณ: 8์ข ๊ฐ์ (happy, thinking, worried, celebrating, curious, sleeping, alert, neutral) 60fps ์ค์๊ฐ ๋ฒกํฐ SVG ๋ ๋๋ง ๊ฒ์ฆ ์๋ฃ'); | |
| // 7. ๋๋ฐ์ด์ค ๋๊ตฌ 0.01์ด ์ต์ฐ์ ์ฆ์ ๊ฐ๋ก์ฑ๊ธฐ(Pre-emptive Intercept) ๊ฒ์ฆ | |
| // 7-1. ์ฌ์ง ์ดฌ์ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '์ฌ์ง ์ฐ์ด์ค'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| const cameraResult = await evalCode(`document.getElementById('dialogue-bubble')?.innerText || ''`); | |
| if (!cameraResult.includes('๐ธ') && !cameraResult.includes('์ฌ์ง')) { | |
| throw new Error('๋๋ฐ์ด์ค ์นด๋ฉ๋ผ ๊ฐ๋ก์ฑ๊ธฐ ์คํจ: ' + cameraResult); | |
| } | |
| console.log(' โ 7-1๋จ๊ณ: [์ฌ์ง ์ดฌ์] 0.01์ด ์ต์ฐ์ ์ฆ์ ๊ฐ๋ก์ฑ๊ธฐ ๋ฐ ์๋ต ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // 7-2. ํ์ด๋จธ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '10๋ถ ํ์ด๋จธ ์์ํด์ค'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| const timerResult = await evalCode(`document.getElementById('dialogue-bubble')?.innerText || ''`); | |
| if (!timerResult.includes('โฐ') || !timerResult.includes('10๋ถ')) { | |
| throw new Error('๋๋ฐ์ด์ค ํ์ด๋จธ ๊ฐ๋ก์ฑ๊ธฐ ์คํจ: ' + timerResult); | |
| } | |
| console.log(' โ 7-2๋จ๊ณ: [10๋ถ ํ์ด๋จธ] 0.01์ด ์ต์ฐ์ ์ฆ์ ๊ฐ๋ก์ฑ๊ธฐ ๋ฐ ์๋ต ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // 7-3. ๋ฉ๋ชจ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '๋ฉ๋ชจํด์ค: ์ค๋์ ํ ์ผ ๋ชฉ๋ก'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| const memoResult = await evalCode(`document.getElementById('dialogue-bubble')?.innerText || ''`); | |
| if (!memoResult.includes('๐') && !memoResult.includes('๊ธฐ์ต')) { | |
| throw new Error('๋๋ฐ์ด์ค ๋ฉ๋ชจ ๊ฐ๋ก์ฑ๊ธฐ ์คํจ: ' + memoResult); | |
| } | |
| console.log(' โ 7-3๋จ๊ณ: [๋ฉ๋ชจ ์ ์ฅ] 0.01์ด ์ต์ฐ์ ์ฆ์ ๊ฐ๋ก์ฑ๊ธฐ ๋ฐ ์๋ต ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // 7-4. ๋ฐฐํฐ๋ฆฌ | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '๋ฐฐํฐ๋ฆฌ ๋ช ํผ์ผํธ์ผ?'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| const batteryResult = await evalCode(`document.getElementById('dialogue-bubble')?.innerText || ''`); | |
| if (!batteryResult.includes('๋ฐฐํฐ๋ฆฌ') || !batteryResult.includes('%')) { | |
| throw new Error('๋๋ฐ์ด์ค ๋ฐฐํฐ๋ฆฌ ์๋ ๊ฐ๋ก์ฑ๊ธฐ ์คํจ: ' + batteryResult); | |
| } | |
| console.log(' โ 7-4๋จ๊ณ: [๋ฐฐํฐ๋ฆฌ ํ์ธ] 0.01์ด ์ต์ฐ์ ์ฆ์ ๊ฐ๋ก์ฑ๊ธฐ ๋ฐ ์๋ต ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // 7-5. ์๋จ ํค๋ [๐ ์์ฑ ON/OFF ํ ๊ธ] ๋ฒํผ ์ธํฐ๋์ ๊ฒ์ฆ | |
| const voiceToggleInitial = await evalCode(`({ | |
| btnText: document.getElementById('btn-voice-toggle')?.innerText || '', | |
| drawerCheckbox: document.getElementById('checkbox-voice-enabled')?.checked | |
| })`); | |
| if (voiceToggleInitial.btnText !== '๐') { | |
| throw new Error('์์ฑ ํ ๊ธ ๊ธฐ๋ณธ๊ฐ ๐ ํ์ธ ์คํจ: ' + JSON.stringify(voiceToggleInitial)); | |
| } | |
| await evalCode(`document.getElementById('btn-voice-toggle')?.click()`); | |
| await new Promise(r => setTimeout(r, 100)); | |
| const voiceToggleMuted = await evalCode(`({ | |
| btnText: document.getElementById('btn-voice-toggle')?.innerText || '', | |
| drawerCheckbox: document.getElementById('checkbox-voice-enabled')?.checked | |
| })`); | |
| if (voiceToggleMuted.btnText !== '๐' || voiceToggleMuted.drawerCheckbox !== false) { | |
| throw new Error('์์ฑ ๋๊ธฐ(Mute) ํ ๊ธ ์คํจ: ' + JSON.stringify(voiceToggleMuted)); | |
| } | |
| // ๋ค์ ์ผ๊ธฐ | |
| await evalCode(`document.getElementById('btn-voice-toggle')?.click()`); | |
| await new Promise(r => setTimeout(r, 100)); | |
| console.log(' โ 7-5๋จ๊ณ: [๐ ์์ฑ ON/OFF ํ ๊ธ] 0ms ์ฆ๊ฐ ์์๊ฑฐ ๋ฐ ์ํ ๋๊ธฐํ ๊ฒ์ฆ ์ฑ๊ณต'); | |
| // 8. ์ค์ ๋๋ก์ด ์ด๊ธฐ ๋ฐ MLX Gemma 4-26B ์ค์ ์ฃผ์ & [๋ง์ ์ฐ๊ฒฐ ํ์ธ] ๊ฒ์ฆ | |
| console.log(' ๐งช 8-1๋จ๊ณ: ์ค์ ๋๋ก์ด ์ด๊ธฐ ๋ฐ MLX Gemma 4-26B ์ค์ ์ฃผ์ ...'); | |
| await evalCode(` | |
| (() => { | |
| document.getElementById('btn-open-settings')?.click(); | |
| const provSelect = document.getElementById('select-llm-provider'); | |
| if (provSelect) { | |
| provSelect.value = 'openai_compatible'; | |
| provSelect.dispatchEvent(new Event('change')); | |
| } | |
| const endpointInput = document.getElementById('input-drawer-endpoint'); | |
| if (endpointInput) endpointInput.value = 'http://100.79.62.64:8080/v1'; | |
| const modelInput = document.getElementById('input-drawer-model'); | |
| if (modelInput) modelInput.value = 'mlx-community/gemma-4-26b-a4b-it-4bit'; | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| // [๐ ๋ง์ ์ฐ๊ฒฐ ํ์ธ] | |
| await evalCode(`document.getElementById('btn-drawer-test-connection')?.click()`); | |
| await new Promise(r => setTimeout(r, 1200)); | |
| const connFeedback = await evalCode(`({ | |
| display: document.getElementById('drawer-conn-feedback')?.style.display, | |
| text: document.getElementById('drawer-conn-feedback')?.innerText || '' | |
| })`); | |
| if (!connFeedback.text.includes('์ฐ๊ฒฐ๋์์ต๋๋ค') && !connFeedback.text.includes('โจ')) { | |
| throw new Error('MLX Gemma 4-26B ๋ง์ ์ฐ๊ฒฐ ํ์ธ ์คํจ: ' + JSON.stringify(connFeedback)); | |
| } | |
| console.log(' โ 8-1๋จ๊ณ: MLX Gemma 4-26B [๐ ๋ง์ ์ฐ๊ฒฐ ํ์ธ] ํต๊ณผ: ' + connFeedback.text); | |
| // Mories ์ง๋จ ๋ฒํผ ํด๋ฆญ | |
| await evalCode(`document.getElementById('btn-drawer-test-mories')?.click()`); | |
| await new Promise(r => setTimeout(r, 400)); | |
| const drawerMoriesFeedback = await evalCode(`document.getElementById('drawer-mories-feedback')?.innerText || ''`); | |
| console.log(' โ 8-2๋จ๊ณ: Mories ๊ธฐ์ต์ ๋ฐ๋ค ์ง๋จ ํผ๋๋ฐฑ ํ์ธ: ' + drawerMoriesFeedback); | |
| // BADA WebSocket ์ง๋จ ๋ฒํผ ํด๋ฆญ | |
| await evalCode(`document.getElementById('btn-drawer-test-ws')?.click()`); | |
| await new Promise(r => setTimeout(r, 400)); | |
| const drawerWsFeedback = await evalCode(`document.getElementById('drawer-ws-feedback')?.innerText || ''`); | |
| console.log(' โ 8-3๋จ๊ณ: BADA WebSocket ์ง๋จ ํผ๋๋ฐฑ ํ์ธ: ' + drawerWsFeedback); | |
| // ์ค์ ์ ์ฅ ๋ฐ ๋๋ก์ด ๋ซ๊ธฐ | |
| await evalCode(` | |
| (() => { | |
| document.getElementById('btn-save-settings')?.click(); | |
| document.getElementById('btn-close-drawer')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 300)); | |
| // 8-4. ์ค์ MLX Gemma 4-26B๋ก "์๋ ! ๋ ๋๊ตฌ์ผ?" ์ง๋ฌธ ์ ์ก โ Thinking ํ์ ๋ฐ ํ์ค ๋ฒ๋ธ ๋ ๋๋ง ๊ฒ์ฆ | |
| console.log(' ๐งช 8-4๋จ๊ณ: ์ค์ MLX Gemma 4-26B๋ก "์๋ ! ๋ ๋๊ตฌ์ผ?" ์ ์ก...'); | |
| await evalCode(` | |
| (() => { | |
| const input = document.getElementById('user-text-input'); | |
| if (input) input.value = '์๋ ! ๋ ๋๊ตฌ์ผ?'; | |
| document.getElementById('btn-send')?.click(); | |
| })() | |
| `); | |
| await new Promise(r => setTimeout(r, 200)); | |
| // ์ ์ก ์ฆ์ thinking ์ํ ๊ฒ์ฆ | |
| const thinkingCheck = await evalCode(`({ | |
| emotionBadge: document.getElementById('emotion-text')?.innerText || '', | |
| dialogueText: document.getElementById('dialogue-bubble')?.innerText || '', | |
| hasThinkingDots: !!document.querySelector('.thinking-dots') | |
| })`); | |
| console.log(' โ 8-4.1๋จ๊ณ: ๋ชจ๋ธ ์์ฑ ์ค Thinking ํ์ ๋ฐ ์ 3๊ฐ ํ์ค ์ ๋๋ฉ์ด์ ๋ฒ๋ธ ๋ ๋๋ง ํ์ธ: ' + JSON.stringify(thinkingCheck)); | |
| // MLX Gemma 4-26B ๋ก์ปฌ ์ถ๋ก (์ฝ 10~20์ด ์์) ์๋ต ๋๊ธฐ (์ต๋ 90์ด) | |
| console.log(' โณ 8-4.2๋จ๊ณ: MLX Gemma 4-26B ๊ณ ์ฑ๋ฅ ์ถ๋ก ๋๊ธฐ ์ค (์ต๋ 90์ด)...'); | |
| let mlxAnswerReceived = false; | |
| let finalAnswerText = ''; | |
| const startTime = Date.now(); | |
| for (let attempt = 0; attempt < 90; attempt++) { | |
| await new Promise(r => setTimeout(r, 1000)); | |
| const currentDialogue = await evalCode(`document.getElementById('dialogue-bubble')?.innerText || ''`); | |
| if (currentDialogue && !currentDialogue.includes('์๊ฐ ์ค') && !currentDialogue.includes('๊ธฐ๋ด์ด์ผ') && currentDialogue !== '๋: ์๋ ! ๋ ๋๊ตฌ์ผ?') { | |
| finalAnswerText = currentDialogue; | |
| mlxAnswerReceived = true; | |
| break; | |
| } | |
| } | |
| const elapsedSec = ((Date.now() - startTime) / 1000).toFixed(1); | |
| if (!mlxAnswerReceived) { | |
| throw new Error(`MLX Gemma 4-26B ์๋ต ํ์์์ (${elapsedSec}์ด ๊ฒฝ๊ณผ): ` + finalAnswerText); | |
| } | |
| if (finalAnswerText.includes('์๋ต์ ๋ฐ์ง ๋ชปํ์ต๋๋ค') || finalAnswerText.includes('์ฐ๊ฒฐ ํ์ธ ํ์')) { | |
| throw new Error('MLX Gemma 4-26B ์๋ต ์ค๋ฅ: ' + finalAnswerText); | |
| } | |
| console.log(` ๐ 8-5๋จ๊ณ: MLX Gemma 4-26B ์ค์๊ฐ ์๋ต ์์ ์ฑ๊ณต (${elapsedSec}์ด ์์)!`); | |
| console.log(` ๐ ์์ ๋ ๋ต๋ณ: "${finalAnswerText}"`); | |
| ws.close(); | |
| } finally { | |
| chromeProc.kill(); | |
| } | |
| if (hasErrors) { | |
| console.error('โ [Browser E2E] ๋ธ๋ผ์ฐ์ ์ฝ์ ์ค๋ฅ๊ฐ ๊ฐ์ง๋์ด ๊ฒ์ฆ์ ์คํจํ์ต๋๋ค.'); | |
| process.exit(1); | |
| } else { | |
| console.log('\n๐ [Browser E2E] ์ํ Her ๊ฐ์ฑ์ 5๋จ๊ณ ๋ํํ ํ๋ฅด์๋ ํฉ์ฑ ์๋๋ฆฌ์ค ๋ธ๋ผ์ฐ์ E2E 100% ํต๊ณผ!\n'); | |
| } | |