donobu 2.30.0 → 2.30.1
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.
- package/dist/assets/generated/version +1 -1
- package/dist/cli/install-donobu-plugin.d.ts +6 -0
- package/dist/cli/install-donobu-plugin.d.ts.map +1 -0
- package/dist/cli/install-donobu-plugin.js +125 -0
- package/dist/cli/install-donobu-plugin.js.map +1 -0
- package/dist/cli/playwright-json-to-markdown.d.ts +43 -0
- package/dist/cli/playwright-json-to-markdown.d.ts.map +1 -0
- package/dist/cli/playwright-json-to-markdown.js +239 -0
- package/dist/cli/playwright-json-to-markdown.js.map +1 -0
- package/dist/cli/playwright-json-to-slack-json.d.ts +3 -0
- package/dist/cli/playwright-json-to-slack-json.d.ts.map +1 -0
- package/dist/cli/playwright-json-to-slack-json.js +207 -0
- package/dist/cli/playwright-json-to-slack-json.js.map +1 -0
- package/dist/esm/assets/generated/version +1 -1
- package/dist/esm/cli/install-donobu-plugin.d.ts +6 -0
- package/dist/esm/cli/install-donobu-plugin.d.ts.map +1 -0
- package/dist/esm/cli/install-donobu-plugin.js +125 -0
- package/dist/esm/cli/install-donobu-plugin.js.map +1 -0
- package/dist/esm/cli/playwright-json-to-markdown.d.ts +43 -0
- package/dist/esm/cli/playwright-json-to-markdown.d.ts.map +1 -0
- package/dist/esm/cli/playwright-json-to-markdown.js +239 -0
- package/dist/esm/cli/playwright-json-to-markdown.js.map +1 -0
- package/dist/esm/cli/playwright-json-to-slack-json.d.ts +3 -0
- package/dist/esm/cli/playwright-json-to-slack-json.d.ts.map +1 -0
- package/dist/esm/cli/playwright-json-to-slack-json.js +207 -0
- package/dist/esm/cli/playwright-json-to-slack-json.js.map +1 -0
- package/package.json +4 -4
- package/dist/assets/install-donobu-plugin.js +0 -96
- package/dist/assets/playwright-json-to-markdown.js +0 -257
- package/dist/assets/playwright-json-to-slack-json.js +0 -171
- package/dist/esm/assets/install-donobu-plugin.js +0 -96
- package/dist/esm/assets/playwright-json-to-markdown.js +0 -257
- package/dist/esm/assets/playwright-json-to-slack-json.js +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convert Playwright JSON test results to a simplified Slack-compatible report.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node playwright-json-to-slack-json.js input.json [--report-url <url>]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
// Read the JSON data from file or stdin
|
|
12
|
-
function readInput() {
|
|
13
|
-
const args = process.argv.slice(2);
|
|
14
|
-
|
|
15
|
-
// Parse arguments to extract report URL and input file
|
|
16
|
-
let reportUrl = null;
|
|
17
|
-
let inputFile = null;
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < args.length; i++) {
|
|
20
|
-
if (args[i] === '--report-url' && i + 1 < args.length) {
|
|
21
|
-
reportUrl = args[i + 1];
|
|
22
|
-
i++; // Skip the URL value
|
|
23
|
-
} else if (!args[i].startsWith('--')) {
|
|
24
|
-
inputFile = args[i];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let jsonData;
|
|
29
|
-
|
|
30
|
-
if (inputFile) {
|
|
31
|
-
jsonData = JSON.parse(fs.readFileSync(inputFile, 'utf8'));
|
|
32
|
-
} else {
|
|
33
|
-
jsonData = JSON.parse(fs.readFileSync(0, 'utf8')); // Read from stdin
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { jsonData, reportUrl };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Process JSON and create simplified Slack blocks
|
|
40
|
-
function generateSlackBlocks(jsonData, reportUrl) {
|
|
41
|
-
const { suites } = jsonData;
|
|
42
|
-
|
|
43
|
-
const blocks = [];
|
|
44
|
-
|
|
45
|
-
// Header block
|
|
46
|
-
blocks.push({
|
|
47
|
-
type: 'header',
|
|
48
|
-
text: {
|
|
49
|
-
type: 'plain_text',
|
|
50
|
-
text: '🎭 Playwright Test Summary',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Track totals
|
|
55
|
-
let totalPassed = 0;
|
|
56
|
-
let totalFailed = 0;
|
|
57
|
-
let totalTimedOut = 0;
|
|
58
|
-
let totalSkipped = 0;
|
|
59
|
-
let totalInterrupted = 0;
|
|
60
|
-
let totalSelfHealed = 0;
|
|
61
|
-
|
|
62
|
-
// Process each suite to get totals
|
|
63
|
-
suites.forEach((suite) => {
|
|
64
|
-
suite.specs.forEach((spec) => {
|
|
65
|
-
spec.tests.forEach((test) => {
|
|
66
|
-
const result = test.results && test.results.at(-1);
|
|
67
|
-
const isSelfHealed =
|
|
68
|
-
test.annotations &&
|
|
69
|
-
test.annotations.some((a) => a.type === 'self-healed');
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
test.status === 'skipped' ||
|
|
73
|
-
(!result && test.status === undefined)
|
|
74
|
-
) {
|
|
75
|
-
totalSkipped++;
|
|
76
|
-
} else if (result) {
|
|
77
|
-
if (isSelfHealed) {
|
|
78
|
-
totalSelfHealed++;
|
|
79
|
-
} else {
|
|
80
|
-
switch (result.status) {
|
|
81
|
-
case 'passed':
|
|
82
|
-
totalPassed++;
|
|
83
|
-
break;
|
|
84
|
-
case 'failed':
|
|
85
|
-
totalFailed++;
|
|
86
|
-
break;
|
|
87
|
-
case 'timedOut':
|
|
88
|
-
totalTimedOut++;
|
|
89
|
-
break;
|
|
90
|
-
case 'skipped':
|
|
91
|
-
totalSkipped++;
|
|
92
|
-
break;
|
|
93
|
-
case 'interrupted':
|
|
94
|
-
totalInterrupted++;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Create status summary table
|
|
104
|
-
const statusRows = [
|
|
105
|
-
{ name: 'Passed', emoji: '✅', count: totalPassed },
|
|
106
|
-
{ name: 'Self-Healed', emoji: '❤️🩹', count: totalSelfHealed },
|
|
107
|
-
{ name: 'Failed', emoji: '❌', count: totalFailed },
|
|
108
|
-
{ name: 'Timed Out', emoji: '⏰', count: totalTimedOut },
|
|
109
|
-
{ name: 'Skipped', emoji: '⏭️', count: totalSkipped },
|
|
110
|
-
{ name: 'Interrupted', emoji: '⚡', count: totalInterrupted },
|
|
111
|
-
];
|
|
112
|
-
|
|
113
|
-
// Add each status row as a section with two fields
|
|
114
|
-
statusRows.forEach((row) => {
|
|
115
|
-
blocks.push({
|
|
116
|
-
type: 'section',
|
|
117
|
-
fields: [
|
|
118
|
-
{
|
|
119
|
-
type: 'mrkdwn',
|
|
120
|
-
text: `${row.emoji} ${row.name}`,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
type: 'mrkdwn',
|
|
124
|
-
text: `${row.count}`,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Add report URL link if provided
|
|
131
|
-
if (reportUrl) {
|
|
132
|
-
blocks.push({
|
|
133
|
-
type: 'divider',
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
blocks.push({
|
|
137
|
-
type: 'section',
|
|
138
|
-
text: {
|
|
139
|
-
type: 'mrkdwn',
|
|
140
|
-
text: `📊 <${reportUrl}|View Full Report>`,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Add timestamp footer
|
|
146
|
-
blocks.push({
|
|
147
|
-
type: 'divider',
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
blocks.push({
|
|
151
|
-
type: 'context',
|
|
152
|
-
elements: [
|
|
153
|
-
{
|
|
154
|
-
type: 'mrkdwn',
|
|
155
|
-
text: `Report generated on ${new Date().toLocaleString()} by Donobu`,
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return { blocks };
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Main execution
|
|
164
|
-
try {
|
|
165
|
-
const { jsonData, reportUrl } = readInput();
|
|
166
|
-
const slackBlocks = generateSlackBlocks(jsonData, reportUrl);
|
|
167
|
-
console.log(JSON.stringify(slackBlocks, null, 2));
|
|
168
|
-
} catch (error) {
|
|
169
|
-
console.error('Error processing JSON:', error.message);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { exec } = require('child_process');
|
|
4
|
-
const { promisify } = require('util');
|
|
5
|
-
const { access, mkdir, rm, cp, readFile } = require('fs/promises');
|
|
6
|
-
const { basename, join } = require('path');
|
|
7
|
-
const { constants } = require('fs');
|
|
8
|
-
|
|
9
|
-
const execAsync = promisify(exec);
|
|
10
|
-
|
|
11
|
-
async function getPluginName() {
|
|
12
|
-
try {
|
|
13
|
-
// First, try to read the plugin name from package.json
|
|
14
|
-
const packageJsonContent = await readFile('package.json', 'utf8');
|
|
15
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
16
|
-
|
|
17
|
-
if (packageJson.name) {
|
|
18
|
-
console.log(`Using plugin name from package.json: ${packageJson.name}`);
|
|
19
|
-
return packageJson.name;
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.warn(
|
|
23
|
-
'Could not read package.json name, falling back to git/user detection',
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Fallback to a heuristic
|
|
28
|
-
try {
|
|
29
|
-
const { stdout } = await execAsync('git rev-parse --show-toplevel');
|
|
30
|
-
const repoPath = stdout.trim();
|
|
31
|
-
const gitBasedName = `${basename(repoPath).replace(/\.git$/, '')}-custom-tools`;
|
|
32
|
-
console.log(`Using git-based plugin name: ${gitBasedName}`);
|
|
33
|
-
return gitBasedName;
|
|
34
|
-
} catch {
|
|
35
|
-
const user = process.env.USER || 'unknown-user';
|
|
36
|
-
const userBasedName = `${user}-custom-tools`;
|
|
37
|
-
console.log(`Using user-based plugin name: ${userBasedName}`);
|
|
38
|
-
return userBasedName;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function buildPlugin() {
|
|
43
|
-
console.log('Building plugin...');
|
|
44
|
-
await execAsync('npm run build');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function installPlugin() {
|
|
48
|
-
const pluginName = await getPluginName();
|
|
49
|
-
const pluginsDir = join(
|
|
50
|
-
process.env.HOME,
|
|
51
|
-
'Library/Application Support/Donobu Studio/plugins',
|
|
52
|
-
);
|
|
53
|
-
const thisPluginDir = join(pluginsDir, pluginName);
|
|
54
|
-
|
|
55
|
-
console.log(`Installing plugin: ${pluginName}`);
|
|
56
|
-
|
|
57
|
-
// Create plugins directory
|
|
58
|
-
await mkdir(pluginsDir, { recursive: true });
|
|
59
|
-
|
|
60
|
-
// Remove old plugin if exists
|
|
61
|
-
try {
|
|
62
|
-
await rm(thisPluginDir, { recursive: true, force: true });
|
|
63
|
-
} catch (err) {
|
|
64
|
-
// Ignore if directory doesn't exist
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Copy built plugin
|
|
68
|
-
await cp('dist', thisPluginDir, { recursive: true });
|
|
69
|
-
|
|
70
|
-
console.log(`Plugin installed successfully to: ${thisPluginDir}`);
|
|
71
|
-
console.log('Restart Donobu to see the new tools.');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function main() {
|
|
75
|
-
try {
|
|
76
|
-
// Check if we're in a plugin directory
|
|
77
|
-
try {
|
|
78
|
-
await access('package.json', constants.F_OK);
|
|
79
|
-
await access('src', constants.F_OK);
|
|
80
|
-
} catch {
|
|
81
|
-
console.error(
|
|
82
|
-
'Error: This command must be run from a Donobu plugin directory',
|
|
83
|
-
);
|
|
84
|
-
console.error('Make sure you have package.json and src/ directory');
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
await buildPlugin();
|
|
89
|
-
await installPlugin();
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error('Installation failed:', error.message);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
main();
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convert Playwright JSON test results to a Markdown report.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node playwright-json-to-markdown.js input.json > report.md
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
function stripAnsiCodes(str) {
|
|
12
|
-
return str.replace(
|
|
13
|
-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
14
|
-
'',
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Function to format duration in a readable way
|
|
19
|
-
function formatDuration(ms) {
|
|
20
|
-
if (ms < 1000) {
|
|
21
|
-
return `${ms}ms`;
|
|
22
|
-
}
|
|
23
|
-
const seconds = Math.floor(ms / 1000);
|
|
24
|
-
if (seconds < 60) {
|
|
25
|
-
return `${seconds}s`;
|
|
26
|
-
}
|
|
27
|
-
const minutes = Math.floor(seconds / 60);
|
|
28
|
-
const remainingSeconds = seconds % 60;
|
|
29
|
-
return `${minutes}m ${remainingSeconds}s`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Read the JSON data from file or stdin
|
|
33
|
-
function readInput() {
|
|
34
|
-
const args = process.argv.slice(2);
|
|
35
|
-
if (args.length > 0) {
|
|
36
|
-
return JSON.parse(fs.readFileSync(args[0], 'utf8'));
|
|
37
|
-
} else {
|
|
38
|
-
return JSON.parse(fs.readFileSync(0, 'utf8')); // Read from stdin
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Process JSON and create markdown
|
|
43
|
-
function generateMarkdown(jsonData) {
|
|
44
|
-
const { suites } = jsonData;
|
|
45
|
-
|
|
46
|
-
// Count self-healed tests
|
|
47
|
-
let selfHealedCount = 0;
|
|
48
|
-
suites.forEach((suite) => {
|
|
49
|
-
suite.specs.forEach((spec) => {
|
|
50
|
-
spec.tests.forEach((test) => {
|
|
51
|
-
if (
|
|
52
|
-
test.annotations &&
|
|
53
|
-
test.annotations.some((a) => a.type === 'self-healed')
|
|
54
|
-
) {
|
|
55
|
-
selfHealedCount++;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Create report header
|
|
62
|
-
let markdown = `# Playwright Test Report\n\n`;
|
|
63
|
-
// Tests by file
|
|
64
|
-
markdown += `## Summary\n\n`;
|
|
65
|
-
|
|
66
|
-
// Create file summary table with status counts
|
|
67
|
-
markdown += `| File | Passed | Self-Healed | Failed | Timed Out | Skipped | Interrupted | Duration |\n`;
|
|
68
|
-
markdown += `| - | - | - | - | - | - | - | - |\n`;
|
|
69
|
-
|
|
70
|
-
// Track totals for summary row
|
|
71
|
-
let totalPassed = 0;
|
|
72
|
-
let totalFailed = 0;
|
|
73
|
-
let totalTimedOut = 0;
|
|
74
|
-
let totalSkipped = 0;
|
|
75
|
-
let totalInterrupted = 0;
|
|
76
|
-
let totalSelfHealed = 0;
|
|
77
|
-
let totalDuration = 0;
|
|
78
|
-
|
|
79
|
-
suites.forEach((suite) => {
|
|
80
|
-
// Count tests by status for this file
|
|
81
|
-
let passed = 0;
|
|
82
|
-
let failed = 0;
|
|
83
|
-
let timedOut = 0;
|
|
84
|
-
let skipped = 0;
|
|
85
|
-
let interrupted = 0;
|
|
86
|
-
let selfHealed = 0;
|
|
87
|
-
|
|
88
|
-
const fileDuration = suite.specs.reduce(
|
|
89
|
-
(total, spec) =>
|
|
90
|
-
total +
|
|
91
|
-
spec.tests.reduce((testTotal, test) => {
|
|
92
|
-
const result = test.results && test.results.at(-1);
|
|
93
|
-
const isSelfHealed =
|
|
94
|
-
test.annotations &&
|
|
95
|
-
test.annotations.some((a) => a.type === 'self-healed');
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
test.status === 'skipped' ||
|
|
99
|
-
(!result && test.status === undefined)
|
|
100
|
-
) {
|
|
101
|
-
skipped++;
|
|
102
|
-
} else if (result) {
|
|
103
|
-
if (isSelfHealed) {
|
|
104
|
-
selfHealed++;
|
|
105
|
-
} else {
|
|
106
|
-
switch (result.status) {
|
|
107
|
-
case 'passed':
|
|
108
|
-
passed++;
|
|
109
|
-
break;
|
|
110
|
-
case 'failed':
|
|
111
|
-
failed++;
|
|
112
|
-
break;
|
|
113
|
-
case 'timedOut':
|
|
114
|
-
timedOut++;
|
|
115
|
-
break;
|
|
116
|
-
case 'skipped':
|
|
117
|
-
skipped++;
|
|
118
|
-
break;
|
|
119
|
-
case 'interrupted':
|
|
120
|
-
interrupted++;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return testTotal + (result?.duration || 0);
|
|
127
|
-
}, 0),
|
|
128
|
-
0,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
// Add to totals
|
|
132
|
-
totalPassed += passed;
|
|
133
|
-
totalFailed += failed;
|
|
134
|
-
totalTimedOut += timedOut;
|
|
135
|
-
totalSkipped += skipped;
|
|
136
|
-
totalInterrupted += interrupted;
|
|
137
|
-
totalSelfHealed += selfHealed;
|
|
138
|
-
totalDuration += fileDuration;
|
|
139
|
-
|
|
140
|
-
markdown += `| ${suite.file} | ${passed ? passed + ' ✅' : ''} | ${selfHealed ? selfHealed + ' ❤️🩹' : ''} | ${failed ? failed + ' ❌' : ''} | ${timedOut ? timedOut + ' ⏰' : ''} | ${skipped ? skipped + ' ⏭️' : ''} | ${interrupted ? interrupted + ' ⚡' : ''} | ${formatDuration(fileDuration)} |\n`;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// Add totals row
|
|
144
|
-
markdown += `| **TOTAL** | **${totalPassed + ' ✅'}** | **${totalSelfHealed + ' ❤️🩹'}** | **${totalFailed + ' ❌'}** | **${totalTimedOut + ' ⏰'}** | **${totalSkipped + ' ⏭️'}** | **${totalInterrupted + ' ⚡'}** | **${formatDuration(totalDuration)}** |\n`;
|
|
145
|
-
|
|
146
|
-
markdown += `\n`;
|
|
147
|
-
|
|
148
|
-
// Generate test details sections
|
|
149
|
-
suites.forEach((suite) => {
|
|
150
|
-
const fileName = suite.file;
|
|
151
|
-
markdown += `## ${fileName}\n\n`;
|
|
152
|
-
|
|
153
|
-
suite.specs.forEach((spec) => {
|
|
154
|
-
markdown += `### ${spec.title}\n\n`;
|
|
155
|
-
|
|
156
|
-
spec.tests.forEach((test) => {
|
|
157
|
-
const result = test.results && test.results.at(-1);
|
|
158
|
-
|
|
159
|
-
if (test.status === 'skipped' || !result || test.status === undefined) {
|
|
160
|
-
markdown += `**Status**: ⏭️ Skipped \n`;
|
|
161
|
-
markdown += `**Duration**: N/A \n`;
|
|
162
|
-
// Get objective from annotations if available
|
|
163
|
-
let objective = 'No objective provided';
|
|
164
|
-
|
|
165
|
-
if (test.annotations) {
|
|
166
|
-
const objectiveAnnotation = test.annotations.find(
|
|
167
|
-
(a) => a.type === 'objective',
|
|
168
|
-
);
|
|
169
|
-
if (objectiveAnnotation) {
|
|
170
|
-
objective =
|
|
171
|
-
objectiveAnnotation.description || 'No objective provided';
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Escape any existing triple backticks in the objective
|
|
176
|
-
objective = objective.replace(/```/g, '\\`\\`\\`');
|
|
177
|
-
markdown += `**Objective**:\n\`\`\`\n${objective}\n\`\`\`\n`;
|
|
178
|
-
markdown += `---\n\n`;
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const isSelfHealed =
|
|
183
|
-
test.annotations &&
|
|
184
|
-
test.annotations.some((a) => a.type === 'self-healed');
|
|
185
|
-
|
|
186
|
-
// Determine status based on result status and self-healing annotation
|
|
187
|
-
let status;
|
|
188
|
-
if (result.status === 'passed') {
|
|
189
|
-
status = '✅ Passed';
|
|
190
|
-
} else if (isSelfHealed) {
|
|
191
|
-
status = '❌ Failed (❤️🩹 Self-Healed)';
|
|
192
|
-
} else if (result.status === 'failed') {
|
|
193
|
-
status = '❌ Failed';
|
|
194
|
-
} else if (result.status === 'timedOut') {
|
|
195
|
-
status = '⏰ Timed Out';
|
|
196
|
-
} else if (result.status === 'skipped') {
|
|
197
|
-
status = '⏭️ Skipped';
|
|
198
|
-
} else if (result.status === 'interrupted') {
|
|
199
|
-
status = '⚡ Interrupted';
|
|
200
|
-
} else {
|
|
201
|
-
status = `⚠️ ${result.status || 'Unknown'}`;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const duration = formatDuration(result.duration || 0);
|
|
205
|
-
|
|
206
|
-
// Get objective from annotations if available
|
|
207
|
-
let objective = 'No objective provided';
|
|
208
|
-
if (test.annotations) {
|
|
209
|
-
const objectiveAnnotation = test.annotations.find(
|
|
210
|
-
(a) => a.type === 'objective',
|
|
211
|
-
);
|
|
212
|
-
if (objectiveAnnotation) {
|
|
213
|
-
objective =
|
|
214
|
-
objectiveAnnotation.description || 'No objective provided';
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Escape any existing triple backticks in the objective by replacing ``` with \`\`\`
|
|
219
|
-
objective = objective.replace(/```/g, '\\`\\`\\`');
|
|
220
|
-
|
|
221
|
-
markdown += `**Status**: ${status} \n`;
|
|
222
|
-
markdown += `**Duration**: ${duration} \n`;
|
|
223
|
-
markdown += `**Objective**:\n\`\`\`\n${objective}\n\`\`\`\n`;
|
|
224
|
-
|
|
225
|
-
// Add error details if test failed
|
|
226
|
-
if (result.status === 'failed' && result.error) {
|
|
227
|
-
markdown += `\n<details>\n<summary>⚠️ Error Details</summary>\n\n`;
|
|
228
|
-
markdown += `\`\`\`\n${result.error.message || 'No error message available'}\n\`\`\`\n\n`;
|
|
229
|
-
|
|
230
|
-
// Include code snippet if available
|
|
231
|
-
if (result.error.snippet) {
|
|
232
|
-
markdown += `**Code Snippet**:\n\`\`\`\n${stripAnsiCodes(result.error.snippet)}\n\`\`\`\n\n`;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
markdown += `</details>\n\n`;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
markdown += `---\n\n`;
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// Add timestamp footer
|
|
244
|
-
markdown += `_Report generated on ${new Date().toLocaleString()} by Donobu_\n`;
|
|
245
|
-
|
|
246
|
-
return markdown;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Main execution
|
|
250
|
-
try {
|
|
251
|
-
const jsonData = readInput();
|
|
252
|
-
const markdown = generateMarkdown(jsonData);
|
|
253
|
-
console.log(markdown);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
console.error('Error processing JSON:', error.message);
|
|
256
|
-
process.exit(1);
|
|
257
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convert Playwright JSON test results to a simplified Slack-compatible report.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node playwright-json-to-slack-json.js input.json [--report-url <url>]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
// Read the JSON data from file or stdin
|
|
12
|
-
function readInput() {
|
|
13
|
-
const args = process.argv.slice(2);
|
|
14
|
-
|
|
15
|
-
// Parse arguments to extract report URL and input file
|
|
16
|
-
let reportUrl = null;
|
|
17
|
-
let inputFile = null;
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < args.length; i++) {
|
|
20
|
-
if (args[i] === '--report-url' && i + 1 < args.length) {
|
|
21
|
-
reportUrl = args[i + 1];
|
|
22
|
-
i++; // Skip the URL value
|
|
23
|
-
} else if (!args[i].startsWith('--')) {
|
|
24
|
-
inputFile = args[i];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let jsonData;
|
|
29
|
-
|
|
30
|
-
if (inputFile) {
|
|
31
|
-
jsonData = JSON.parse(fs.readFileSync(inputFile, 'utf8'));
|
|
32
|
-
} else {
|
|
33
|
-
jsonData = JSON.parse(fs.readFileSync(0, 'utf8')); // Read from stdin
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { jsonData, reportUrl };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Process JSON and create simplified Slack blocks
|
|
40
|
-
function generateSlackBlocks(jsonData, reportUrl) {
|
|
41
|
-
const { suites } = jsonData;
|
|
42
|
-
|
|
43
|
-
const blocks = [];
|
|
44
|
-
|
|
45
|
-
// Header block
|
|
46
|
-
blocks.push({
|
|
47
|
-
type: 'header',
|
|
48
|
-
text: {
|
|
49
|
-
type: 'plain_text',
|
|
50
|
-
text: '🎭 Playwright Test Summary',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Track totals
|
|
55
|
-
let totalPassed = 0;
|
|
56
|
-
let totalFailed = 0;
|
|
57
|
-
let totalTimedOut = 0;
|
|
58
|
-
let totalSkipped = 0;
|
|
59
|
-
let totalInterrupted = 0;
|
|
60
|
-
let totalSelfHealed = 0;
|
|
61
|
-
|
|
62
|
-
// Process each suite to get totals
|
|
63
|
-
suites.forEach((suite) => {
|
|
64
|
-
suite.specs.forEach((spec) => {
|
|
65
|
-
spec.tests.forEach((test) => {
|
|
66
|
-
const result = test.results && test.results.at(-1);
|
|
67
|
-
const isSelfHealed =
|
|
68
|
-
test.annotations &&
|
|
69
|
-
test.annotations.some((a) => a.type === 'self-healed');
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
test.status === 'skipped' ||
|
|
73
|
-
(!result && test.status === undefined)
|
|
74
|
-
) {
|
|
75
|
-
totalSkipped++;
|
|
76
|
-
} else if (result) {
|
|
77
|
-
if (isSelfHealed) {
|
|
78
|
-
totalSelfHealed++;
|
|
79
|
-
} else {
|
|
80
|
-
switch (result.status) {
|
|
81
|
-
case 'passed':
|
|
82
|
-
totalPassed++;
|
|
83
|
-
break;
|
|
84
|
-
case 'failed':
|
|
85
|
-
totalFailed++;
|
|
86
|
-
break;
|
|
87
|
-
case 'timedOut':
|
|
88
|
-
totalTimedOut++;
|
|
89
|
-
break;
|
|
90
|
-
case 'skipped':
|
|
91
|
-
totalSkipped++;
|
|
92
|
-
break;
|
|
93
|
-
case 'interrupted':
|
|
94
|
-
totalInterrupted++;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Create status summary table
|
|
104
|
-
const statusRows = [
|
|
105
|
-
{ name: 'Passed', emoji: '✅', count: totalPassed },
|
|
106
|
-
{ name: 'Self-Healed', emoji: '❤️🩹', count: totalSelfHealed },
|
|
107
|
-
{ name: 'Failed', emoji: '❌', count: totalFailed },
|
|
108
|
-
{ name: 'Timed Out', emoji: '⏰', count: totalTimedOut },
|
|
109
|
-
{ name: 'Skipped', emoji: '⏭️', count: totalSkipped },
|
|
110
|
-
{ name: 'Interrupted', emoji: '⚡', count: totalInterrupted },
|
|
111
|
-
];
|
|
112
|
-
|
|
113
|
-
// Add each status row as a section with two fields
|
|
114
|
-
statusRows.forEach((row) => {
|
|
115
|
-
blocks.push({
|
|
116
|
-
type: 'section',
|
|
117
|
-
fields: [
|
|
118
|
-
{
|
|
119
|
-
type: 'mrkdwn',
|
|
120
|
-
text: `${row.emoji} ${row.name}`,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
type: 'mrkdwn',
|
|
124
|
-
text: `${row.count}`,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Add report URL link if provided
|
|
131
|
-
if (reportUrl) {
|
|
132
|
-
blocks.push({
|
|
133
|
-
type: 'divider',
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
blocks.push({
|
|
137
|
-
type: 'section',
|
|
138
|
-
text: {
|
|
139
|
-
type: 'mrkdwn',
|
|
140
|
-
text: `📊 <${reportUrl}|View Full Report>`,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Add timestamp footer
|
|
146
|
-
blocks.push({
|
|
147
|
-
type: 'divider',
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
blocks.push({
|
|
151
|
-
type: 'context',
|
|
152
|
-
elements: [
|
|
153
|
-
{
|
|
154
|
-
type: 'mrkdwn',
|
|
155
|
-
text: `Report generated on ${new Date().toLocaleString()} by Donobu`,
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return { blocks };
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Main execution
|
|
164
|
-
try {
|
|
165
|
-
const { jsonData, reportUrl } = readInput();
|
|
166
|
-
const slackBlocks = generateSlackBlocks(jsonData, reportUrl);
|
|
167
|
-
console.log(JSON.stringify(slackBlocks, null, 2));
|
|
168
|
-
} catch (error) {
|
|
169
|
-
console.error('Error processing JSON:', error.message);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|