Initial Playwright ERP UAT VAPT test suite v2.4.1 IMAP
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
require('dotenv').config();
|
||||
|
||||
module.exports = async () => {
|
||||
fs.mkdirSync(path.resolve('results'), { recursive: true });
|
||||
if (process.env.START_ERP !== 'true') return;
|
||||
|
||||
const cwd = process.env.ERP_WORKDIR;
|
||||
const cmd = process.env.ERP_COMMAND || 'uvicorn app.main:app --reload';
|
||||
const child = spawn(cmd, { cwd, shell: true, env: process.env });
|
||||
global.__ERP_PROCESS__ = child;
|
||||
const logFile = path.resolve('results/erp-console.log');
|
||||
fs.writeFileSync(logFile, '');
|
||||
const append = (buf) => {
|
||||
const text = buf.toString();
|
||||
fs.appendFileSync(logFile, text);
|
||||
const otp = text.match(/\[DEV OTP\].*?code=(\d{4,8})/i);
|
||||
if (otp) fs.writeFileSync(path.resolve('results/current-otp.txt'), otp[1]);
|
||||
};
|
||||
child.stdout.on('data', append);
|
||||
child.stderr.on('data', append);
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
};
|
||||
Reference in New Issue
Block a user