openpetswithchatandmcp/website/split-monster-test.ts
OpenPets Dev 65ac83849e Add 'website/' from commit '966aea480ffe1c340553aa878def30131d2af827'
git-subtree-dir: website
git-subtree-mainline: 8d3849caea
git-subtree-split: 966aea480f
2026-06-17 20:48:39 +00:00

30 lines
1.7 KiB
TypeScript
Executable file

import { Project, SyntaxKind } from 'ts-morph';
console.log('Loading project...');
const project = new Project({ tsConfigFilePath: 'C:/ScriptoriumAI/scriptoriumai-ui/tsconfig.json' });
const sf = project.getSourceFileOrThrow('C:/ScriptoriumAI/scriptoriumai-ui/src/__tests__/Runboard.telemetry-lockstep-parity.test.tsx');
console.log('Finding massive tests...');
const testCalls = sf.getDescendantsOfKind(SyntaxKind.CallExpression).filter(c => c.getExpression().getText() === 'it');
const massiveTests = testCalls.filter(c => c.getWidth() > 300000); // >300KB
console.log('Found ' + massiveTests.length + ' massive tests.');
for (let i = 0; i < massiveTests.length; i++) {
const t = massiveTests[i];
const newFileName = 'C:/ScriptoriumAI/scriptoriumai-ui/src/__tests__/Runboard.telemetry-lockstep-parity-massive-part-' + i + '.test.tsx';
// Create new file with all imports and mock setup from original
const newFile = project.createSourceFile(newFileName, sf.getText().substring(0, sf.getStatements().find(s => s.getKind() === SyntaxKind.ExpressionStatement && s.getText().startsWith('describe')).getStart()), { overwrite: true });
// Add describe wrap
newFile.addStatements('describe(\'Runboard telemetry lockstep parity (massive part ' + i + ')\', () => {\n beforeEach(() => { cleanup(); resetRunboardSurfaceHarnessMocks(scriptoriumClientMock); applyRunboardSurfaceDefaults(scriptoriumClientMock); });\n ' + t.getText() + '\n});\n');
console.log('Created ' + newFileName);
// Remove the huge test from the original file
t.getParent().asKindOrThrow(SyntaxKind.ExpressionStatement).remove();
}
console.log('Saving project...');
project.saveSync();
console.log('Done chunking the monster test.');