Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __tests__/reporter/pr-comment-body.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ describe('buildCommentBody', () => {
expect(body.startsWith(MARKER)).toBe(true);
});

it('omits the "View full report" link when reportUrl is empty', () => {
const success = buildCommentBody({ report: baseReport, reportUrl: '', suites: [], psVersion: null, sha: 'abc' });
expect(success).not.toMatch(/View full report/);
expect(success).not.toMatch(/\[View full report\]\(\)/);

const failure = buildCommentBody({
report: { ...baseReport, passed: 0, failed: 1, total: 1, failures: [{ suite: 'S', title: 'T', message: 'm', file: 'f', line: 1 }] },
reportUrl: '', suites: [], psVersion: null, sha: 'abc',
});
expect(failure).not.toMatch(/View full report/);
});

it('short form on success', () => {
const body = buildCommentBody({ report: baseReport, reportUrl: 'https://x', suites: ['BackOffice'], psVersion: '9.0.0', sha: 'abc123def' });
expect(body).toMatch(/10 tests passed/);
Expand Down
11 changes: 9 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120541,7 +120541,10 @@ function successBody(p) {
if (meta) {
lines.push(meta, ``);
}
lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``, footer(p.sha));
if (p.reportUrl) {
lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``);
}
lines.push(footer(p.sha));
return lines.join('\n');
}
function failureBody(p) {
Expand All @@ -120564,7 +120567,11 @@ function failureBody(p) {
if (meta) {
lines.push(meta, ``);
}
lines.push(`<details>`, `<summary>Failure details (${p.report.failed})</summary>`, ``, details, ``, `</details>`, ``, `πŸ“Š [View full report](${p.reportUrl})`, ``, footer(p.sha));
lines.push(`<details>`, `<summary>Failure details (${p.report.failed})</summary>`, ``, details, ``, `</details>`, ``);
if (p.reportUrl) {
lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``);
}
lines.push(footer(p.sha));
return lines.join('\n');
}
function buildCommentBody(p) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/reporter/pr-comment-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function successBody(p: BuildBodyParams): string {
``,
];
if (meta) { lines.push(meta, ``); }
lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``, footer(p.sha));
if (p.reportUrl) { lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``); }
lines.push(footer(p.sha));
return lines.join('\n');
}

Expand Down Expand Up @@ -75,10 +76,9 @@ function failureBody(p: BuildBodyParams): string {
``,
`</details>`,
``,
`πŸ“Š [View full report](${p.reportUrl})`,
``,
footer(p.sha),
);
if (p.reportUrl) { lines.push(`πŸ“Š [View full report](${p.reportUrl})`, ``); }
lines.push(footer(p.sha));
return lines.join('\n');
}

Expand Down
Loading