Skip to content

Commit

Permalink
Merge pull request #962 from hmrc/BDOG-2315
Browse files Browse the repository at this point in the history
BDOG-2315: adds test reports description with warning icon
  • Loading branch information
Tyrpix authored Nov 19, 2024
2 parents 54ed2c8 + d953035 commit e0fd09d
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,35 @@ object Link:
~ (__ \ "cls" ).readNullable[String]
)(apply)

case class BuildData(
number : Int,
url : String,
timestamp : Instant,
result : Option[String],
description: Option[String]
case class TestJobResults(
securityAlerts : String,
accessibilityViolations: Option[String]
)
object TestJobResults:
val reads: Reads[TestJobResults] =
( (__ \ "securityAlerts" ).read[String]
~ (__ \ "accessibilityViolations").readNullable[String]
)(TestJobResults.apply _)

case class BuildData(
number : Int,
url : String,
timestamp : Instant,
result : Option[String],
description : Option[String],
testJobResults: Option[TestJobResults] = None
):
def testJobHelper(result: Option[String]): Int =
result.flatMap(_.toIntOption).getOrElse(0)

object BuildData:
val reads: Reads[BuildData] =
( (__ \ "number" ).read[Int]
~ (__ \ "url" ).read[String]
~ (__ \ "timestamp" ).read[Instant]
~ (__ \ "result" ).readNullable[String]
~ (__ \ "description").readNullable[String]
( (__ \ "number" ).read[Int]
~ (__ \ "url" ).read[String]
~ (__ \ "timestamp" ).read[Instant]
~ (__ \ "result" ).readNullable[String]
~ (__ \ "description" ).readNullable[String]
~ (__ \ "testJobResults").readNullable[TestJobResults](TestJobResults.reads)
)(apply)

given Parser[BuildJobType] = Parser.parser(BuildJobType.values)
Expand Down
26 changes: 25 additions & 1 deletion app/uk/gov/hmrc/cataloguefrontend/view/partials/build.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,31 @@
@if(ciLink.latestBuild.nonEmpty) {
@if(repo.repoType == RepoType.Test) {
<td>
@{ciLink.latestBuild.get.description}
@for(buildData <- ciLink.latestBuild) {
<ul class="list-unstyled mb-0">
@for(result <- buildData.testJobResults) {
@defining {
<div class="layered-icon" title="test-results-need-review">
<i class="bi bi-exclamation-triangle-fill text-warning"></i>
<i class="bi bi-exclamation-triangle text-dark"></i>
</div>
} { layeredIcon =>
<li>
@if(buildData.testJobHelper(result.accessibilityViolations) > 0) {
@layeredIcon
}
Accessibility violations: @result.accessibilityViolations
</li>
<li>
@if(buildData.testJobHelper(Some(result.securityAlerts)) > 0) {
@layeredIcon
}
Security alerts: @result.securityAlerts
</li>
}
}
</ul>
}
</td>
}
@defining({
Expand Down
59 changes: 57 additions & 2 deletions app/uk/gov/hmrc/cataloguefrontend/view/partials/tests.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<tr>
<th>Test Repository</th>
<th>Test Job</th>
<th>Description</th>
<th>Latest Result</th>
<th>Last Run</th>
</tr>
Expand All @@ -47,8 +48,35 @@
<td>
<a id="link-to-job-@{firstJob.name}" href="@{firstJob.jenkinsURL}" target="_blank" rel="noreferrer noopener">@{firstJob.name}<span class="glyphicon glyphicon-new-window"/></a>
</td>
<td>
@for(buildData <- firstJob.latestBuild) {
<ul class="list-unstyled mb-0">
@for(result <- buildData.testJobResults) {
@defining {
<div class="layered-icon" title="test-results-need-review">
<i class="bi bi-exclamation-triangle-fill text-warning"></i>
<i class="bi bi-exclamation-triangle text-dark"></i>
</div>
} { layeredIcon =>
<li>
@if(buildData.testJobHelper(result.accessibilityViolations) > 0) {
@layeredIcon
}
Accessibility violations: @result.accessibilityViolations
</li>
<li>
@if(buildData.testJobHelper(Some(result.securityAlerts)) > 0) {
@layeredIcon
}
Security alerts: @result.securityAlerts
</li>
}
}
</ul>
}
</td>
@defining(firstJob.latestBuild) {
case Some(BuildData(_, _, timestamp, result, _)) => {
case Some(BuildData(_, _, timestamp, result, _, _)) => {
@defining({
result match {
case Some("SUCCESS") => "text-bg-success"
Expand Down Expand Up @@ -80,8 +108,35 @@
<td>
<a id="link-to-job-@{job.name}" href="@{job.jenkinsURL}" target="_blank" rel="noreferrer noopener">@{job.name}<span class="glyphicon glyphicon-new-window"/></a>
</td>
<td>
@for(buildData <- job.latestBuild) {
<ul class="list-unstyled mb-0">
@for(result <- buildData.testJobResults) {
@defining {
<div class="layered-icon" title="test-results-need-review">
<i class="bi bi-exclamation-triangle-fill text-warning"></i>
<i class="bi bi-exclamation-triangle text-dark"></i>
</div>
} { layeredIcon =>
<li>
@if(buildData.testJobHelper(result.accessibilityViolations) > 0) {
@layeredIcon
}
Accessibility violations: @result.accessibilityViolations
</li>
<li>
@if(buildData.testJobHelper(Some(result.securityAlerts)) > 0) {
@layeredIcon
}
Security alerts: @result.securityAlerts
</li>
}
}
</ul>
}
</td>
@defining(job.latestBuild) {
case Some(BuildData(_, _, timestamp, result, _)) => {
case Some(BuildData(_, _, timestamp, result, _, _)) => {
@defining({
result match {
case Some("SUCCESS") => "text-bg-success"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

<title>MDTP Catalogue - @title</title>
<link rel="stylesheet" href="@routes.Assets.versioned("bootstrap.5.3.0.min.css")" />
<link rel="stylesheet" href="@routes.Assets.versioned("bootstrap-icons.min.css")" />
<link rel="stylesheet" href="@routes.Assets.versioned("glyphicon-bootstrap.3.4.1.css")" />
<link rel="stylesheet" href="@routes.Assets.versioned("catalogue-frontend.css")" />
<link rel="shortcut icon" href="@routes.Assets.versioned("favicon.ico")" type="image/x-icon">
Expand Down
5 changes: 5 additions & 0 deletions public/bootstrap-icons.min.css

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions public/catalogue-frontend.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/fonts/bootstrap-icons.woff
Binary file not shown.
Binary file added public/fonts/bootstrap-icons.woff2
Binary file not shown.

0 comments on commit e0fd09d

Please sign in to comment.