QA: unit tests for API logic, Playwright smoke tests, pre-push check, manual QA checklist
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* بررسی قبل از پوش: بیلد shared، تایپ API و تستها، تایپ وب.
|
||||
* npm run check — بررسی کامل
|
||||
* npm run check -- --e2e — بهعلاوهٔ تستهای مرورگری (نیاز به e2e/.env)
|
||||
*/
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
const withE2e = process.argv.includes('--e2e');
|
||||
|
||||
function run(label, cmd, cwd = '.') {
|
||||
return new Promise((resolve) => {
|
||||
const started = Date.now();
|
||||
const child = spawn(cmd, { cwd, shell: true, env: process.env });
|
||||
let out = '';
|
||||
child.stdout.on('data', (d) => (out += d));
|
||||
child.stderr.on('data', (d) => (out += d));
|
||||
child.on('close', (code) => {
|
||||
const sec = ((Date.now() - started) / 1000).toFixed(0);
|
||||
if (code === 0) console.log(` ✔ ${label} (${sec}s)`);
|
||||
else console.log(` ✖ ${label} (${sec}s)\n${out.trim().split('\n').slice(-40).join('\n')}\n`);
|
||||
resolve(code === 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log('بررسی پروژه…');
|
||||
const steps = [];
|
||||
if (!(await run('بیلد @mento/shared', 'npm run build -w @mento/shared'))) process.exit(1);
|
||||
|
||||
steps.push(
|
||||
run('تایپ API', 'npx tsc --noEmit -p tsconfig.json', 'apps/api'),
|
||||
run('تایپ تستهای API', 'npx tsc --noEmit -p test/tsconfig.json', 'apps/api'),
|
||||
run('تستهای واحد API', 'npm test -w @mento/api'),
|
||||
run('تایپ وب (vue-tsc)', 'npx vue-tsc -b', 'apps/web'),
|
||||
);
|
||||
const results = await Promise.all(steps);
|
||||
|
||||
if (withE2e && results.every(Boolean)) {
|
||||
results.push(await run('تستهای مرورگری (Playwright)', 'npx playwright test'));
|
||||
}
|
||||
|
||||
if (results.every(Boolean)) {
|
||||
console.log('همهچیز سالم است.');
|
||||
} else {
|
||||
console.log('بررسی ناموفق بود؛ قبل از پوش مشکلها را رفع کنید. (اضطراری: git push --no-verify)');
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user