@flowspec-qa/runner 0.2.4 β†’ 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,134 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { execa } from 'execa';
4
- import { config } from '@flowspec-qa/runner-core';
5
- import { apiClient } from '@flowspec-qa/runner-core';
6
-
7
- interface Check {
8
- label: string;
9
- ok: boolean;
10
- detail: string;
11
- }
12
-
13
- export function doctorCommand(): Command {
14
- return new Command('doctor')
15
- .description('Check that your environment is ready to run tests')
16
- .action(async () => {
17
- console.log(chalk.bold('\n🩺 FlowSpecQA Runner β€” Diagnostics\n'));
18
- const checks: Check[] = [];
19
-
20
- // 1. Node version
21
- try {
22
- const { stdout } = await execa('node', ['--version']);
23
- const major = parseInt(stdout.replace('v', '').split('.')[0], 10);
24
- const ok = major >= 18;
25
- checks.push({
26
- label: 'Node.js',
27
- ok,
28
- detail: ok ? `${stdout.trim()} βœ“` : `${stdout.trim()} β€” se requiere v18 o superior`,
29
- });
30
- } catch {
31
- checks.push({ label: 'Node.js', ok: false, detail: 'No encontrado β€” instΓ‘lalo desde nodejs.org' });
32
- }
33
-
34
- // 2. npm
35
- try {
36
- const { stdout } = await execa('npm', ['--version']);
37
- checks.push({ label: 'npm', ok: true, detail: `v${stdout.trim()} βœ“` });
38
- } catch {
39
- checks.push({ label: 'npm', ok: false, detail: 'No encontrado' });
40
- }
41
-
42
- // 3. Playwright chromium browser
43
- try {
44
- const { stdout } = await execa('npx', ['playwright', '--version'], { reject: false });
45
- const hasCr = stdout.includes('Version') || stdout.includes('playwright');
46
- checks.push({
47
- label: 'Playwright',
48
- ok: hasCr,
49
- detail: hasCr ? stdout.trim().split('\n')[0] + ' βœ“' : 'No instalado β€” ejecuta: npx playwright install chromium',
50
- });
51
- } catch {
52
- checks.push({
53
- label: 'Playwright',
54
- ok: false,
55
- detail: 'No encontrado β€” ejecuta: npx playwright install chromium',
56
- });
57
- }
58
-
59
- // 4. API Key configured
60
- const apiKey = config.get('apiKey') as string | undefined;
61
- const hasKey = !!apiKey && apiKey.startsWith('sk-smrt-');
62
- checks.push({
63
- label: 'API Key',
64
- ok: hasKey,
65
- detail: hasKey
66
- ? `${apiKey!.slice(0, 12)}**** βœ“`
67
- : 'No configurada β€” ejecuta: flowspecqa auth login --url <URL> --key <TU_API_KEY>',
68
- });
69
-
70
- // 5. Base URL configured
71
- const baseUrl = config.get('baseUrl') as string | undefined;
72
- const hasUrl = !!baseUrl;
73
- checks.push({
74
- label: 'URL del servidor',
75
- ok: hasUrl,
76
- detail: hasUrl ? `${baseUrl} βœ“` : 'No configurada',
77
- });
78
-
79
- // 6. Connectivity to FlowSpecQA SaaS
80
- if (hasKey && hasUrl) {
81
- try {
82
- await apiClient.get('/api/config/projects');
83
- checks.push({ label: 'Conectividad al servidor', ok: true, detail: `${baseUrl} responde βœ“` });
84
- } catch (err: any) {
85
- checks.push({
86
- label: 'Conectividad al servidor',
87
- ok: false,
88
- detail: `No se puede conectar a ${baseUrl} β€” ${err.message}`,
89
- });
90
- }
91
- } else {
92
- checks.push({ label: 'Conectividad al servidor', ok: false, detail: 'Requiere API Key configurada' });
93
- }
94
-
95
- // 7. Suite cache dir writable
96
- const cacheDir = config.get('suiteCacheDir') as string;
97
- try {
98
- const fs = await import('fs');
99
- fs.mkdirSync(cacheDir, { recursive: true });
100
- checks.push({ label: 'Carpeta de cachΓ©', ok: true, detail: `${cacheDir} βœ“` });
101
- } catch {
102
- checks.push({ label: 'Carpeta de cachΓ©', ok: false, detail: `No se puede escribir en ${cacheDir}` });
103
- }
104
-
105
- // 8. Maestro CLI (optional but needed for mobile)
106
- try {
107
- const { stdout } = await execa('maestro', ['--version']);
108
- checks.push({ label: 'Maestro CLI', ok: true, detail: `v${stdout.trim()} βœ“` });
109
- } catch {
110
- checks.push({
111
- label: 'Maestro CLI',
112
- ok: false,
113
- detail: 'No encontrado β€” opcional, instalar para tests mΓ³viles: curl -Ls "https://get.maestro.mobile.dev" | bash',
114
- });
115
- }
116
-
117
- // Print results
118
- for (const c of checks) {
119
- const icon = c.ok ? chalk.green('βœ”') : chalk.red('βœ–');
120
- const label = chalk.bold(c.label.padEnd(25));
121
- console.log(` ${icon} ${label} ${c.ok ? chalk.dim(c.detail) : chalk.yellow(c.detail)}`);
122
- }
123
-
124
- const failed = checks.filter((c) => !c.ok);
125
- console.log('');
126
- if (failed.length === 0) {
127
- console.log(chalk.green.bold(' βœ… Todo en orden β€” puedes ejecutar tests.'));
128
- } else {
129
- console.log(chalk.red(` ❌ ${failed.length} problema(s) encontrado(s). Revisa los items marcados arriba.`));
130
- process.exit(1);
131
- }
132
- console.log('');
133
- });
134
- }
@@ -1,53 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import path from 'path';
4
- import { BackupManager } from '@flowspec-qa/runner-core';
5
-
6
- export function healCommand(): Command {
7
- const heal = new Command('heal')
8
- .description('Manage test healing and backups')
9
- .argument('[file]', 'Test file to manage backups for')
10
- .option('--rollback', 'Rollback the specified file to its last backup')
11
- .option('--list', 'List available backups for the specified file')
12
- .action(async (file, options) => {
13
- if (options.rollback) {
14
- if (!file) {
15
- console.error(chalk.red('Error: You must specify a file path to rollback.'));
16
- process.exit(1);
17
- }
18
-
19
- const fullPath = path.resolve(process.cwd(), file);
20
- const success = await BackupManager.rollback(fullPath);
21
-
22
- if (success) {
23
- console.log(chalk.green(`βœ” Success: ${file} has been restored to its previous state.`));
24
- } else {
25
- console.error(chalk.red(`✘ Error: No backups found for ${file}.`));
26
- }
27
- return;
28
- }
29
-
30
- if (options.list) {
31
- if (!file) {
32
- console.error(chalk.red('Error: You must specify a file name to list backups.'));
33
- process.exit(1);
34
- }
35
-
36
- const fileName = path.basename(file);
37
- const backups = await BackupManager.listBackups(fileName);
38
-
39
- if (backups.length === 0) {
40
- console.log(chalk.yellow(`No backups found for ${fileName}.`));
41
- } else {
42
- console.log(chalk.blue(`Backups for ${fileName}:`));
43
- backups.forEach((b: string) => console.log(` - ${b}`));
44
- }
45
- return;
46
- }
47
-
48
- // Future: Implement the actual AI healing trigger here
49
- console.log(chalk.blue('AI Healing logic is not yet implemented. Use --rollback or --list to manage backups.'));
50
- });
51
-
52
- return heal;
53
- }
@@ -1,56 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import { FlowSpecQAApi } from '@flowspec-qa/runner-core';
5
-
6
- export function ingestCommand(): Command {
7
- return new Command('ingest')
8
- .description('Embed a discovery plan into the vector store so test cases can be generated')
9
- .requiredOption('--entity <id>', 'Entity ID to ingest (e.g. HOME-PAGE)')
10
- .requiredOption('--project <id>', 'Project ID the entity belongs to')
11
- .option('--source <label>', 'Source label for the ingested chunks', 'discovery-plan')
12
- .action(async (options) => {
13
- console.log(chalk.blue(`\nπŸ“₯ Starting ingestion for entity: ${chalk.bold(options.entity)}\n`));
14
-
15
- const spinner = ora('Step 1/3: Locating most recent discovery plan...').start();
16
-
17
- try {
18
- await new Promise(r => setTimeout(r, 500));
19
-
20
- spinner.text = 'Step 2/3: Embedding plan into vector store (Qdrant)...';
21
-
22
- const result = await FlowSpecQAApi.ingestDiscoveryPlan({
23
- project_id: options.project,
24
- entity_id: options.entity,
25
- source: options.source,
26
- });
27
-
28
- spinner.text = 'Step 3/3: Verifying ingestion...';
29
- await new Promise(r => setTimeout(r, 400));
30
-
31
- spinner.succeed(chalk.green(`Ingestion complete for ${chalk.bold(result.entity_id)}`));
32
-
33
- console.log('');
34
- console.log(chalk.bold(' Ingestion Summary'));
35
- console.log(chalk.gray(' ──────────────────────────────────────────'));
36
- console.log(` ${chalk.cyan('Plan ID ')} ${result.plan_id}`);
37
- console.log(` ${chalk.cyan('Source URL ')} ${result.plan_url}`);
38
- console.log(` ${chalk.cyan('Chunks ')} ${chalk.yellow(String(result.chunks_ingested))}`);
39
- console.log(` ${chalk.cyan('Duration ')} ${result.duration_ms}ms`);
40
- console.log(` ${chalk.cyan('Collection ')} ${result.collection}`);
41
- console.log('');
42
- console.log(
43
- chalk.gray(' βœ… Context is ready. Go to the FlowSpecQA portal and generate test cases for ') +
44
- chalk.bold(result.entity_id) + chalk.gray('.')
45
- );
46
- console.log('');
47
-
48
- } catch (err: any) {
49
- spinner.fail(chalk.red(`Ingestion failed: ${err.message}`));
50
- console.log('');
51
- console.log(chalk.gray(' Make sure you ran ') + chalk.cyan(`flowspecqa discover <url> --entity ${options.entity} --project ${options.project}`) + chalk.gray(' first.'));
52
- console.log('');
53
- process.exit(1);
54
- }
55
- });
56
- }
@@ -1,140 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
- import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
- import {
7
- FlowSpecQAApi,
8
- downloadSuite,
9
- executePlaywright,
10
- executeCypress,
11
- executeMaestro,
12
- uploadResults,
13
- } from '@flowspec-qa/runner-core';
14
- import type { TestResultItem } from '@flowspec-qa/runner-core';
15
-
16
-
17
- export function mcpServerCommand(): Command {
18
- return new Command('mcp-server')
19
- .description('Start a local MCP server exposing runner tools to AI agents (Cursor, Claude, etc.)')
20
- .action(async () => {
21
- const server = new Server(
22
- { name: 'flowspecqa-runner', version: '0.1.0' },
23
- { capabilities: { tools: {} } }
24
- );
25
-
26
- // ── Tool Definitions ─────────────────────────────────────────────────
27
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
28
- tools: [
29
- {
30
- name: 'list_suites',
31
- description: 'List test suites available in FlowSpecQA for a project or entity.',
32
- inputSchema: {
33
- type: 'object',
34
- properties: {
35
- entity_id: { type: 'string', description: 'Filter by entity ID (e.g. HU-012)' },
36
- },
37
- },
38
- },
39
- {
40
- name: 'run_suite',
41
- description: 'Download, execute locally, and upload results for a test suite. Client credentials stay local.',
42
- inputSchema: {
43
- type: 'object',
44
- required: ['entity_id'],
45
- properties: {
46
- entity_id: { type: 'string', description: 'Entity ID to run (e.g. HU-012)' },
47
- env_label: { type: 'string', description: 'Environment label (staging, qa, local)', default: 'local' },
48
- base_url: { type: 'string', description: 'Base URL of the application under test (stays local, not uploaded)' },
49
- grep: { type: 'string', description: 'Only run tests matching this pattern' },
50
- skip_upload: { type: 'boolean', description: 'Execute without uploading results', default: false },
51
- },
52
- },
53
- },
54
- {
55
- name: 'get_run_status',
56
- description: 'Get the QA triage status of a test execution from FlowSpecQA.',
57
- inputSchema: {
58
- type: 'object',
59
- required: ['entity_id'],
60
- properties: {
61
- entity_id: { type: 'string' },
62
- },
63
- },
64
- },
65
- ],
66
- }));
67
-
68
- // ── Tool Handlers ─────────────────────────────────────────────────────
69
- server.setRequestHandler(CallToolRequestSchema, async (req) => {
70
- const { name, arguments: args } = req.params;
71
-
72
- // list_suites
73
- if (name === 'list_suites') {
74
- const suites = await FlowSpecQAApi.listSuites((args as any)?.entity_id);
75
- return {
76
- content: [{
77
- type: 'text',
78
- text: JSON.stringify(suites, null, 2),
79
- }],
80
- };
81
- }
82
-
83
- // run_suite
84
- if (name === 'run_suite') {
85
- const a = args as any;
86
- const suites = await FlowSpecQAApi.listSuites(a.entity_id);
87
- if (suites.length === 0) {
88
- return { content: [{ type: 'text', text: `No suites found for entity: ${a.entity_id}` }] };
89
- }
90
- const suite = suites[0];
91
- const local = await downloadSuite(suite.suite_id!, a.entity_id, suite.framework);
92
-
93
- const envVars: Record<string, string> = {};
94
- if (a.base_url) envVars['BASE_URL'] = a.base_url;
95
-
96
- const fw = suite.framework ?? 'playwright_ts';
97
- const execution = fw === 'cypress'
98
- ? await executeCypress(local.suiteDir, { env: envVars, grepPattern: a.grep })
99
- : fw === 'maestro'
100
- ? await executeMaestro(local.suiteDir, { env: envVars, grepPattern: a.grep })
101
- : await executePlaywright(local.suiteDir, { env: envVars, grepPattern: a.grep });
102
-
103
- const summary = {
104
- total: execution.results.length,
105
- passed: execution.results.filter((r: TestResultItem) => r.status === 'pass').length,
106
- failed: execution.results.filter((r: TestResultItem) => r.status === 'fail').length,
107
- exec_id: null as string | null,
108
- };
109
-
110
-
111
- if (!a.skip_upload) {
112
- const { execId } = await uploadResults(execution, {
113
- runId: suite.suite_id!,
114
- entityId: a.entity_id,
115
- framework: suite.framework,
116
- envLabel: a.env_label ?? 'local',
117
- });
118
- summary.exec_id = execId;
119
- }
120
-
121
-
122
- return { content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }] };
123
- }
124
-
125
- // get_run_status
126
- if (name === 'get_run_status') {
127
- const a = args as any;
128
- const suites = await FlowSpecQAApi.listSuites(a.entity_id);
129
- return { content: [{ type: 'text', text: JSON.stringify(suites, null, 2) }] };
130
- }
131
-
132
- return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
133
- });
134
-
135
- // Start MCP server over stdio
136
- const transport = new StdioServerTransport();
137
- await server.connect(transport);
138
- console.error(chalk.dim('[flowspecqa-runner MCP server started on stdio]'));
139
- });
140
- }
@@ -1,31 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { table } from 'table';
4
- import { FlowSpecQAApi } from '@flowspec-qa/runner-core';
5
-
6
- export function projectsCommand(): Command {
7
- const cmd = new Command('projects').description('Manage projects');
8
-
9
- cmd
10
- .command('list')
11
- .description('List all projects accessible with your API Key')
12
- .action(async () => {
13
- try {
14
- const projects = await FlowSpecQAApi.listProjects();
15
- if (projects.length === 0) {
16
- console.log(chalk.yellow('No projects found.'));
17
- return;
18
- }
19
- const rows = [
20
- [chalk.bold('ID'), chalk.bold('Name'), chalk.bold('Entities')],
21
- ...projects.map((p: any) => [chalk.cyan(p.id), p.name, String(p.entity_count ?? 'β€”')]),
22
- ];
23
- console.log(table(rows));
24
- } catch (err: any) {
25
- console.error(chalk.red(`βœ— ${err.message}`));
26
- process.exit(1);
27
- }
28
- });
29
-
30
- return cmd;
31
- }
@@ -1,34 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { table } from 'table';
4
- import { listCachedSuites, evictSuite } from '@flowspec-qa/runner-core';
5
-
6
- export function resultsCommand(): Command {
7
- const cmd = new Command('results').description('Manage local results and cached suites');
8
-
9
- cmd
10
- .command('cache')
11
- .description('List locally cached suites')
12
- .action(() => {
13
- const cached = listCachedSuites();
14
- if (cached.length === 0) {
15
- console.log(chalk.dim('No suites cached locally.'));
16
- return;
17
- }
18
- const rows = [
19
- [chalk.bold('Entity'), chalk.bold('Run ID'), chalk.bold('Path')],
20
- ...cached.map((c: any) => [chalk.cyan(c.entityId), chalk.dim(c.runId), chalk.dim(c.suiteDir)]),
21
- ];
22
- console.log(table(rows));
23
- });
24
-
25
- cmd
26
- .command('evict <entityId> <runId>')
27
- .description('Remove a cached suite from local disk')
28
- .action((entityId: string, runId: string) => {
29
- evictSuite(entityId, runId);
30
- console.log(chalk.green(`βœ“ Evicted suite ${runId} for entity ${entityId}`));
31
- });
32
-
33
- return cmd;
34
- }
@@ -1,225 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import inquirer from 'inquirer';
5
- import {
6
- FlowSpecQAApi,
7
- downloadSuite,
8
- executePlaywright,
9
- executeCypress,
10
- executeMaestro,
11
- executeMaestroMultiDevice,
12
- uploadResults,
13
- type TestResultItem,
14
- } from '@flowspec-qa/runner-core';
15
-
16
- import fs from 'fs';
17
- import path from 'path';
18
-
19
- export function runCommand(): Command {
20
- const cmd = new Command('run')
21
- .description('Download, execute, and upload a test suite')
22
- .requiredOption('-e, --entity <entityId>', 'Entity ID (e.g. HU-012)')
23
- .option('--env <label>', 'Environment label (e.g. staging, qa)', 'local')
24
- .option('--base-url <url>', 'Base URL for the application under test')
25
- .option('--workers <n>', 'Number of parallel test workers', '4')
26
- .option('--headed', 'Run browser in headed mode', false)
27
- .option('--grep <pattern>', 'Only run tests matching this pattern')
28
- .option('--skip-upload', 'Execute locally without uploading results', false)
29
- .option('--skip-security-check', 'Skip secret-detection before upload', false)
30
- .option('--heal', 'Attempt to automatically fix failing tests using AI', false)
31
- .option('--device <serial>', 'Target a specific device by serial/UDID (use "flowspecqa devices" to list)')
32
- .option('--all-devices', 'Run on all connected USB devices in parallel (Android + iOS)', false)
33
- .option('--platform <android|ios>', 'Filter devices by platform when using --all-devices')
34
- .action(async (opts) => {
35
-
36
- // Step 1: Fetch available suites for entity
37
- let spinner = ora('Fetching suite info...').start();
38
- let suites;
39
- try {
40
- suites = await FlowSpecQAApi.listSuites(opts.entity);
41
- spinner.stop();
42
- } catch (err: any) {
43
- spinner.fail(chalk.red(`βœ— ${err.message}`));
44
- process.exit(1);
45
- }
46
-
47
- if (suites.length === 0) {
48
- console.log(chalk.yellow(`No suites found for entity: ${opts.entity}. Generate automation code in FlowSpecQA first.`));
49
- process.exit(0);
50
- }
51
-
52
- // If multiple suites, let user pick
53
- let suite = suites[0];
54
- if (suites.length > 1) {
55
- const ans = await inquirer.prompt([{
56
- type: 'list',
57
- name: 'suite',
58
- message: 'Multiple suites available β€” pick one:',
59
- choices: suites.map((s: any) => ({
60
- name: `${s.entity_id} | ${s.mode ?? 'mixed'} | ${s.status ?? 'DRAFT'} | id: ${s.suite_id}`,
61
- value: s,
62
- })),
63
- }]);
64
- suite = ans.suite;
65
- }
66
-
67
- // Step 2: Download suite ZIP (use suite_id = TestSuite.id)
68
- spinner = ora(`Downloading suite ${suite.suite_id}...`).start();
69
- let local;
70
- try {
71
- local = await downloadSuite(suite.suite_id, opts.entity, suite.framework ?? 'playwright');
72
- spinner.succeed(`Suite ready: ${chalk.dim(local.suiteDir)}`);
73
- } catch (err: any) {
74
- spinner.fail(chalk.red(`βœ— Download failed: ${err.message}`));
75
- process.exit(1);
76
- }
77
-
78
- // Step 3: Build env vars β€” client secrets stay local, never uploaded
79
- const envVars: Record<string, string> = { ...process.env } as Record<string, string>;
80
- if (opts.baseUrl) {
81
- envVars['BASE_URL'] = opts.baseUrl;
82
- envVars['PORTAL_URL'] = opts.baseUrl;
83
- }
84
- if (opts.device) {
85
- envVars['_FLOWSPECQA_DEVICE_ID'] = opts.device;
86
- }
87
-
88
- // 3.5 Maestro Env Support: Copy local .maestro.env or .env to the cached suite directory
89
- // so the Maestro CLI can natively pick up the variables.
90
- const cwdEnvMaestro = path.join(process.cwd(), '.maestro.env');
91
- const cwdEnvNormal = path.join(process.cwd(), '.env');
92
-
93
- if (fs.existsSync(cwdEnvMaestro)) {
94
- fs.copyFileSync(cwdEnvMaestro, path.join(local.suiteDir, '.maestro.env'));
95
- } else if (fs.existsSync(cwdEnvNormal)) {
96
- fs.copyFileSync(cwdEnvNormal, path.join(local.suiteDir, '.maestro.env'));
97
- }
98
-
99
- // Step 4: Execute
100
- const fw = suite.framework ?? 'playwright_ts';
101
- const execOpts = {
102
- env: envVars,
103
- workers: parseInt(opts.workers, 10),
104
- headed: opts.headed,
105
- grepPattern: opts.grep,
106
- };
107
-
108
- // ── Multi-device mode ────────────────────────────────────────────────
109
- let execution: any;
110
- if (opts.allDevices && fw === 'maestro') {
111
- const { readyDevices } = await import('@flowspec-qa/runner-core');
112
- const platform = opts.platform as 'android' | 'ios' | undefined;
113
- const devices = readyDevices(platform ?? 'all');
114
-
115
- if (devices.length === 0) {
116
- console.log(chalk.yellow('\n⚠️ No devices ready. Connect devices via USB and run "flowspecqa devices" to verify.\n'));
117
- process.exit(1);
118
- }
119
-
120
- spinner = ora(`Running on ${chalk.bold(devices.length + ' devices')} in parallel...`).start();
121
-
122
- let deviceResults: any[];
123
- try {
124
- deviceResults = await executeMaestroMultiDevice(local.suiteDir, devices, execOpts);
125
- spinner.stop();
126
- } catch (err: any) {
127
- spinner.fail(chalk.red(`βœ— Multi-device execution error: ${err.message}`));
128
- process.exit(1);
129
- }
130
-
131
- // Print per-device summary table
132
- console.log(chalk.bold('\nπŸ“Š Results by device:\n'));
133
- const header = ` ${'Device'.padEnd(28)}${'Platform'.padEnd(10)}${'Pass'.padEnd(7)}${'Fail'.padEnd(7)}Status`;
134
- console.log(chalk.dim(header));
135
- console.log(chalk.dim(' ' + '─'.repeat(header.length - 2)));
136
-
137
- for (const dr of deviceResults) {
138
- const passed = dr.execution.results.filter((r: TestResultItem) => r.status === 'pass').length;
139
- const failed = dr.execution.results.filter((r: TestResultItem) => r.status === 'fail').length;
140
- const icon = failed === 0 ? chalk.green('βœ… pass') : chalk.red('❌ fail');
141
- const platIcon = dr.device.platform === 'ios' ? '🍎' : 'πŸ€–';
142
- console.log(
143
- ` ${(dr.device.name).substring(0, 26).padEnd(28)}` +
144
- `${(platIcon + ' ' + dr.device.platform).padEnd(10)}` +
145
- `${chalk.green(String(passed)).padEnd(14)}` +
146
- `${chalk.red(String(failed)).padEnd(14)}` +
147
- icon
148
- );
149
- }
150
- console.log('');
151
-
152
- // Flatten all results for upload
153
- execution = {
154
- results: deviceResults.flatMap(dr =>
155
- dr.execution.results.map((r: TestResultItem) => ({
156
- ...r,
157
- name: `[${dr.device.name}] ${r.name}`,
158
- }))
159
- ),
160
- exitCode: deviceResults.some(dr => dr.execution.exitCode !== 0) ? 1 : 0,
161
- startedAt: deviceResults[0].execution.startedAt,
162
- finishedAt: deviceResults[deviceResults.length - 1].execution.finishedAt,
163
- stdout: deviceResults.map(dr => `[${dr.device.id}] ${dr.execution.stdout}`).join('\n'),
164
- stderr: '',
165
- };
166
-
167
- } else {
168
- // ── Single device / non-mobile mode ─────────────────────────────────
169
- spinner = ora(`Executing ${fw} tests (env: ${opts.env})...`).start();
170
- try {
171
- execution = fw === 'cypress'
172
- ? await executeCypress(local.suiteDir, execOpts)
173
- : fw === 'maestro'
174
- ? await executeMaestro(local.suiteDir, execOpts)
175
- : await executePlaywright(local.suiteDir, execOpts);
176
-
177
- const passed = execution.results.filter((r: TestResultItem) => r.status === 'pass').length;
178
- const failed = execution.results.filter((r: TestResultItem) => r.status === 'fail').length;
179
- const total = execution.results.length;
180
- spinner.succeed(`Executed: ${chalk.green(passed + ' pass')} / ${chalk.red(failed + ' fail')} / ${total} total`);
181
- } catch (err: any) {
182
- spinner.fail(chalk.red(`βœ— Execution error: ${err.message}`));
183
- process.exit(1);
184
- }
185
- }
186
-
187
- if (opts.skipUpload) {
188
- console.log(chalk.yellow('\nSkipping upload (--skip-upload). Results not sent to FlowSpecQA.'));
189
- printSummary(execution.results);
190
- return;
191
- }
192
-
193
- // Step 5: Upload sanitized results (run_id = suite_id for traceability)
194
- spinner = ora('Uploading sanitized results to FlowSpecQA...').start();
195
- try {
196
- const { execId } = await uploadResults(execution, {
197
- runId: suite.suite_id, // use suite_id as the run reference
198
- entityId: opts.entity,
199
- framework: suite.framework ?? 'playwright',
200
- envLabel: opts.env,
201
- skipSecurityCheck: opts.skipSecurityCheck,
202
- });
203
- spinner.succeed(`Results uploaded β€” exec_id: ${chalk.cyan(execId)}`);
204
- console.log(chalk.dim(`\nView results at: https://www.flowspecqa.com/results/${execId}`));
205
- } catch (err: any) {
206
- spinner.fail(chalk.red(`βœ— Upload failed: ${err.message}`));
207
- process.exit(1);
208
- }
209
-
210
- printSummary(execution.results);
211
- });
212
-
213
- return cmd;
214
- }
215
-
216
- function printSummary(results: Array<{ name: string; status: string; error?: string | null }>) {
217
- const failed = results.filter((r: any) => r.status === 'fail');
218
- if (failed.length > 0) {
219
- console.log(chalk.red(`\nβœ— ${failed.length} failing test(s):`));
220
- for (const f of failed) {
221
- console.log(` β€’ ${chalk.yellow(f.name)}`);
222
- if (f.error) console.log(` ${chalk.dim(f.error.split('\n')[0])}`);
223
- }
224
- }
225
- }