34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
import { spawnSync } from 'node:child_process';
|
|
const mode = process.argv[2];
|
|
if (!['integration', 'browser'].includes(mode)) throw new Error('Choose integration or browser');
|
|
// This dedicated service is intentionally independent of the development database.
|
|
const env = {
|
|
...process.env,
|
|
DATABASE_URL: 'postgresql://merchantflow:merchantflow_local@localhost:55441/merchantflow_test',
|
|
API_PORT: '3002',
|
|
WEB_PORT: '5174',
|
|
APP_ORIGIN: 'http://127.0.0.1:5174',
|
|
};
|
|
function run(command, args) {
|
|
const result = spawnSync(command, args, { stdio: 'inherit', env });
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) process.exit(result.status ?? 1);
|
|
}
|
|
// Workflow tests write fixtures. Recreate only the disposable test service; never touch db.
|
|
run('docker', ['compose', '--profile', 'test', 'stop', 'db-test']);
|
|
run('docker', ['compose', '--profile', 'test', 'rm', '-f', 'db-test']);
|
|
run('docker', ['compose', '--profile', 'test', 'up', '-d', '--wait', 'db-test']);
|
|
run('pnpm', ['exec', 'turbo', 'run', 'build']);
|
|
run('pnpm', ['--filter', '@merchantflow/database', 'migrate']);
|
|
run('pnpm', ['--filter', '@merchantflow/database', 'seed']);
|
|
if (mode === 'integration')
|
|
run('node', [
|
|
'--test',
|
|
'--test-concurrency=1',
|
|
'apps/api/test/integration.test.mjs',
|
|
'apps/api/test/public-leads.test.mjs',
|
|
'apps/api/test/sales-workspace.test.mjs',
|
|
'apps/api/test/gated-onboarding.test.mjs',
|
|
]);
|
|
else run('pnpm', ['exec', 'playwright', 'test']);
|