근본원인: code 요소의 textContent '❯ project > command'가 PowerShell 키워드 (return, function, const)를 포함할 수 있어 JUNK_CODE_RE에 잘못 걸림. v32: ❯ 마커로 시작하는 code 텍스트는 JUNK/PROMPT 전에 명령어 직접 추출. 14/14 E2E 테스트 통과.
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
const {generateApprovalObserverScript} = require('../out/observer-script');
|
|
let s = generateApprovalObserverScript(18080);
|
|
|
|
// Extract the regex strings
|
|
let junkMatch = s.match(/JUNK_CODE_RE\s*=\s*(\/[^;]+)/);
|
|
let promptMatch = s.match(/PROMPT_ONLY_RE\s*=\s*(\/[^;]+)/);
|
|
|
|
console.log('JUNK_CODE_RE:', junkMatch[1].substring(0, 100));
|
|
console.log('PROMPT_ONLY_RE:', promptMatch[1]);
|
|
|
|
// Use eval to construct the actual regexes
|
|
let JUNK = eval(junkMatch[1]);
|
|
let PROMPT = eval(promptMatch[1]);
|
|
|
|
let tests = [
|
|
['\u276f gravity_control > ', 'prompt only (no command)'],
|
|
['\u276f extension > ', 'prompt only (extension)'],
|
|
['\u276f gravity_control > $logFile = Join-Path $env:USERPROFILE', 'PS var assignment'],
|
|
['\u276f extension > npm.cmd run compile', 'npm compile'],
|
|
['\u276f gravity_control > Start-Sleep 12', 'Start-Sleep'],
|
|
['\u276f gravity_control > git add -A; git commit -m "test"', 'git commit'],
|
|
['\u276f gravity_control > node -e "const {gen}=require()"', 'node with require'],
|
|
['\u276f gravity_control > Get-Content file.txt', 'Get-Content'],
|
|
['\u276f gravity_control > npm.cmd version patch', 'npm version'],
|
|
['function test() { return 1; }', 'JS function (should be JUNK)'],
|
|
['const x = require("fs")', 'JS const (should be JUNK)'],
|
|
['import { foo } from "bar"', 'JS import (should be JUNK)'],
|
|
];
|
|
|
|
console.log('\n=== CODE ELEMENT FILTER ANALYSIS ===');
|
|
for (let [text, desc] of tests) {
|
|
let isJunk = JUNK.test(text);
|
|
let isPrompt = PROMPT.test(text.trim());
|
|
let junkPart = isJunk ? text.match(JUNK)[0] : null;
|
|
|
|
let status;
|
|
if (isPrompt) status = 'SKIP-PROMPT';
|
|
else if (isJunk) status = 'SKIP-JUNK (' + junkPart + ')';
|
|
else status = 'PASS';
|
|
|
|
let isBug = (isJunk || isPrompt) && text.indexOf('\u276f') !== -1 && text.trim().length > 25;
|
|
console.log((isBug ? 'BUG ' : ' ') + status.padEnd(40) + ' | ' + desc);
|
|
}
|