'use strict';
import _0x589480 from 'process';
import { packagesPath } from '../../../base-repo/app-constants/project-paths.js';
import { toolboxCoreEnvVars } from '../../../fd-toolbox-core/constants/environment-variables-constants.js';
import { ciLogMessages, ciJobs, environmentVariables, nodeMaxMemory, importTsx } from '../constants/ci-constants.js';
import { npmCommands, npxCommands } from '../constants/npm-commands.js';
import { execCommand, execSyncCommand } from '../tools/exec.js';
import { installLocalSaasKit } from '../setup/install-local-saaskit.js';
import { initDb } from '../setup/init-db.js';
import { cleanup } from '../setup/cleanup.js';
import { cliLogSubtitle, cliLogSuccess, cliLogInfo, cliLogError } from '../../../fd-toolbox/logging/cli-logger.js';
import { importBuildFromSubmodule } from '../setup/sync-build-artifacts.js';
import { copyPlaywrightReport } from '../setup/copy-playwright-report.js';
import { buildDbConnectionString } from './build-db-connection-string.js';
import { toolboxEnvSettingKeys } from '../../../fd-toolbox/infra/toolbox-env-setting-keys.js';
import { getStringEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';

var __defProp=Object['defineProperty'],__name=(_0xae139c,_0x1e0c26)=>__defProp(_0xae139c,'name',{'value':_0x1e0c26,'configurable':!![]});async function saasKitTestBuildAndTest(){try{cliLogSubtitle(''+ciLogMessages['settingUpEnvironmentVariablesFor']+ciJobs['saasKitTestBuildAndTest']+'...');const _0x3307de='saas-kit-test-submodule-'+getStringEnvSetting(environmentVariables['ciCommitSha']),_0x539043='postgresql.postgres-ram.svc.cluster.local',_0x463433=buildDbConnectionString(_0x3307de,_0x539043);_0x589480['env'][environmentVariables['databaseName']]=_0x3307de,_0x589480['env'][environmentVariables['ciSaasKitTestDatabaseName']]=_0x3307de,_0x589480['env'][toolboxEnvSettingKeys['databaseConnectionString']]=_0x463433,cliLogSuccess(ciLogMessages['environmentVariablesSet']),cliLogSubtitle('Executing\x20'+ciJobs['saasKitTestBuildAndTest']+'\x20sequence...'),cliLogInfo(ciLogMessages['runningSetupPackage']),await importBuildFromSubmodule(),await installLocalSaasKit();const _0x45922b=packagesPath['packagesTest'],_0xc53269={'cwd':_0x45922b};await execCommand(npmCommands['genMeta'],_0xc53269),await execCommand(npmCommands['genSchema'],_0xc53269),await initDb(_0xc53269),_0x589480['env'][toolboxCoreEnvVars['nodeOptions']]=nodeMaxMemory+'\x20'+importTsx,execSyncCommand(npxCommands['saasKitTestBuild'],_0xc53269),execSyncCommand(npxCommands['testSingular'],_0xc53269);}finally{cliLogSubtitle('Initiating\x20cleanup\x20sequence...');try{await copyPlaywrightReport(),cleanup();}catch(_0x5a5a1d){cliLogError('Cleanup\x20process\x20failed.\x20Please\x20check\x20resources\x20manually.\x0a',_0x5a5a1d);}}}__name(saasKitTestBuildAndTest,'saasKitTestBuildAndTest');

export { saasKitTestBuildAndTest };
