-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests on current job-summary behavior
Signed-off-by: Gabriel Feo <gabriel@gabrielfeo.com>
- Loading branch information
1 parent
ef36f81
commit a54fb6a
Showing
2 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import { BuildResult } from '../../src/build-results' | ||
import { renderSummaryTable } from '../../src/job-summary' | ||
import dedent from 'dedent' | ||
|
||
|
||
const successfulHelpBuild: BuildResult = { | ||
rootProjectName: 'root', | ||
rootProjectDir: '/', | ||
requestedTasks: 'help', | ||
gradleVersion: '8.0', | ||
gradleHomeDir: '/opt/gradle', | ||
buildFailed: false, | ||
buildScanUri: 'https://scans.gradle.com/s/abc123', | ||
buildScanFailed: false | ||
} | ||
|
||
const failedHelpBuild: BuildResult = { | ||
...successfulHelpBuild, | ||
buildFailed: true | ||
} | ||
|
||
const longArgsBuild: BuildResult = { | ||
...successfulHelpBuild, | ||
requestedTasks: 'check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal', | ||
} | ||
|
||
const scanPublishDisabledBuild: BuildResult = { | ||
...successfulHelpBuild, | ||
buildScanUri: '', | ||
buildScanFailed: false, | ||
} | ||
|
||
const scanPublishFailedBuild: BuildResult = { | ||
...successfulHelpBuild, | ||
buildScanUri: '', | ||
buildScanFailed: true, | ||
} | ||
|
||
describe('renderSummaryTable', () => { | ||
describe('renders', () => { | ||
it('successful build', () => { | ||
const table = renderSummaryTable([successfulHelpBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:white_check_mark:</td> | ||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
it('failed build', () => { | ||
const table = renderSummaryTable([failedHelpBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:x:</td> | ||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
describe('when build scan', () => { | ||
it('publishing disabled', () => { | ||
const table = renderSummaryTable([scanPublishDisabledBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:white_check_mark:</td> | ||
<td><a href="https://scans.gradle.com" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-NOT_PUBLISHED-lightgrey?logo=Gradle" alt="Build Scan NOT_PUBLISHED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
it('publishing failed', () => { | ||
const table = renderSummaryTable([scanPublishFailedBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:white_check_mark:</td> | ||
<td><a href="https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISH_FAILED-orange?logo=Gradle" alt="Build Scan PUBLISH_FAILED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
}) | ||
it('multiple builds', () => { | ||
const table = renderSummaryTable([successfulHelpBuild, failedHelpBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:white_check_mark:</td> | ||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td>help</td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:x:</td> | ||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
it('truncating long requested tasks', () => { | ||
const table = renderSummaryTable([longArgsBuild]) | ||
expect(table.trim()).toBe(dedent` | ||
<table> | ||
<tr> | ||
<th>Gradle Root Project</th> | ||
<th>Requested Tasks</th> | ||
<th>Gradle Version</th> | ||
<th>Build Outcome</th> | ||
<th>Build Scan®</th> | ||
</tr> | ||
<tr> | ||
<td>root</td> | ||
<td><div title='check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal'>check publishMyLongNamePluginPublicationToMavenCentral publ…</div></td> | ||
<td align='center'>8.0</td> | ||
<td align='center'>:white_check_mark:</td> | ||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td> | ||
</tr> | ||
</table> | ||
`); | ||
}) | ||
}) | ||
}) |