Skip to content

Commit

Permalink
Don't show "There are too many failures to display" if maxNumberOfFai… (
Browse files Browse the repository at this point in the history
#194)

* Don't show "There are too many failures to display" if maxNumberOfFailures is set to zero

* Remove unnecessary dividers in SlackClient_generate_blocks.spec.ts
  • Loading branch information
ryanrosello-og authored Sep 28, 2024
1 parent b05eeae commit 0b017eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@slack/types": "^2.14.0",
"@playwright/test": "^1.47.0",
"@typescript-eslint/eslint-plugin": "^5.30.6",
Expand Down Expand Up @@ -36,7 +35,7 @@
"cli-debug": "yarn build && npx . -c ./cli_config.json -j ./tests/test_data/valid_test_results.json"
},
"name": "playwright-slack-report",
"version": "1.1.86",
"version": "1.1.88",
"bin": {
"playwright-slack-report": "dist/cli.js"
},
Expand Down
7 changes: 6 additions & 1 deletion src/LayoutGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const generateFailures = async (
});
}

if (summaryResults.failures.length > maxNumberOfFailures) {
if (maxNumberOfFailures > 0 && summaryResults.failures.length > maxNumberOfFailures) {
fails.push({
type: 'section',
text: {
Expand All @@ -81,6 +81,11 @@ const generateFailures = async (
},
});
}

if (fails.length === 0) {
return [];
}

return [
{
type: 'divider',
Expand Down
4 changes: 4 additions & 0 deletions src/SlackClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export default class SlackClient {
}) {
const result = [];
const blocks = await generateFailures(summaryResults, maxNumberOfFailures);
if (blocks.length === 0) {
return result;
}

const fallbackText = generateFallbackText(summaryResults);
for (const channel of channelIds) {
// under test
Expand Down
6 changes: 0 additions & 6 deletions tests/SlackClient_generate_blocks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ test.describe('SlackClient.generateBlocks()', () => {
text: '\n*BuildID* :\t9sdcv-312432-3134',
},
},
{
type: 'divider',
},
]);
});

Expand Down Expand Up @@ -224,9 +221,6 @@ test.describe('SlackClient.generateBlocks()', () => {
text: '✅ *0* | ❌ *1* | ⏩ *1*',
},
},
{
type: 'divider',
},
]);
});
});

0 comments on commit 0b017eb

Please sign in to comment.