1// Factory for games-based app test runners (gamesapp, gamespay) 2// Provides shared CLI extensions, AI mocking, and deleteTestGames cleanup 15export type GamesTestConfig = { 21export const mkGamesTestActions = (config: GamesTestConfig) => { 22 const { allSuites, suiteConfigs, localAppCfg } = config 24 const gamesRuntestsCli = { 26 'del-test-games': { flag: true as const, desc: 'delete test games from db' }, 27 'enable-opnrtr': { flag: true as const, desc: 'use real OpenRouter API instead of mock' }, 31 return { allSuites, localAppCfg, suiteConfigs, wrapDbEnv: wrapDbEnv as RunTestsCoreConfig['wrapDbEnv'] } 34 const runtests = async () => { 43 if (!cli['enable-opnrtr']) aiDrawMockCtx.enterWith({ useMock: true }) // ctx:clear 45 const delTestGames = cli['del-test-games'] ?? false 46 const delTestGamesOnly = delTestGames && !cliHasArg('--suite') 48 const cfg = await getConfig() 50 if (delTestGamesOnly) opts.testsuites = [] 55 const { localAppCfg } = cfg 57 const appCfg = ctxAppCfg || localAppCfg 58 await wrapDbEnv({ appConfig: ctxAppCfg ? undefined : appCfg, reuseConn: false, wrappedFnc: async () => { 60 console.log(chalkGray(`Deleted ${deleted} test games`)) 64 if (!result.allPassed) process.exit(1) 67 runtests.cliSchema = gamesRuntestsCli 71 return { runtests, testdeploy, getConfig }