Files
OmniRoute/fix-tests.js
diegosouzapw 6e9b23c8e2 fix(providers): support batch testing for web, search, and audio
Add dedicated batch test modes for web-cookie, search, and audio
providers in the dashboard, API route, and request validation so
category-level testing targets the correct connections.

Rename legacy qoder refresh and usage helpers from iflow to qoder
for consistency, and tighten regex handling in response cleaning,
thinking compression, and proxy matching to address edge cases and
static analysis findings.

Also update related tests, typing fixes, and README star history
embeds.
2026-04-16 11:52:53 -03:00

31 lines
1.2 KiB
JavaScript

const fs = require("fs");
function addAnyCast(filePath) {
let content = fs.readFileSync(filePath, "utf8");
// Match "const varname = await func({...});" and make it "const varname: any = await func({...});"
content = content.replace(
/(const\s+\w+)\s*=\s*(await\s+(?:usageService|usageFetcher)\.getUsageForProvider\()/g,
"$1: any = $2"
);
fs.writeFileSync(filePath, content);
}
addAnyCast("tests/unit/usage-service-hardening.test.ts");
addAnyCast("tests/unit/usage-fetcher-antigravity.test.ts");
let bailian = fs.readFileSync("tests/unit/bailian-quota-fetcher.test.ts", "utf8");
// Fix missing window properties in test typing
bailian = bailian.replace(/const quota = /g, "const quota: any = ");
fs.writeFileSync("tests/unit/bailian-quota-fetcher.test.ts", bailian);
let routeTest = fs.readFileSync("tests/unit/token-refresh-route-service.test.ts", "utf8");
// Fix provider mocks typing
routeTest = routeTest.replace(/github: \{/g, '"github": {'); // Fix github
routeTest = routeTest.replace(
/(refreshWithRetry|log\.entries).*?(toBe|equal).*?;/g,
(match) => match
); // just ignore
fs.writeFileSync("tests/unit/token-refresh-route-service.test.ts", routeTest);
console.log("Fixes applied.");