Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add meta-tests that check all components have unit / integration tests * exclude test fixtures for GovukPasswordInput (not yet implemented) and HMRC accessible-autocomplete helper * add missing integration tests for GovukHeader, HmrcFooter, HmrcReportTechnicalIssue * remove redundant assets config
- Loading branch information
Showing
107 changed files
with
588 additions
and
39 deletions.
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
25 changes: 25 additions & 0 deletions
25
...lay-30/src/test/scala/uk/gov/hmrc/govukfrontend/support/TemplateIntegrationMetaSpec.scala
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,25 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.govukfrontend.support | ||
|
||
import uk.gov.hmrc.support.TemplateIntegrationBaseMetaSpec | ||
|
||
class TemplateIntegrationMetaSpec | ||
extends TemplateIntegrationBaseMetaSpec( | ||
libraryName = "govuk-frontend", | ||
ignoredHelpers = Seq("govukTemplate", "govukLayout") | ||
) |
25 changes: 25 additions & 0 deletions
25
...rc/test/scala/uk/gov/hmrc/govukfrontend/views/components/GovukHeaderIntegrationSpec.scala
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,25 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.govukfrontend.views.components | ||
|
||
import uk.gov.hmrc.govukfrontend.support.TemplateIntegrationSpec | ||
import uk.gov.hmrc.govukfrontend.views.html.components._ | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.header.Header | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.header.Generators._ | ||
|
||
object GovukHeaderIntegrationSpec | ||
extends TemplateIntegrationSpec[Header, GovukHeader](govukComponentName = "govukHeader") |
55 changes: 55 additions & 0 deletions
55
...rc/test/scala/uk/gov/hmrc/hmrcfrontend/support/MessagesAwareTemplateIntegrationSpec.scala
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,55 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.hmrcfrontend.support | ||
|
||
import org.scalacheck.Arbitrary | ||
import play.api.i18n.Messages | ||
import play.api.libs.json.OWrites | ||
import play.twirl.api.{HtmlFormat, Template2} | ||
import uk.gov.hmrc.hmrcfrontend.views.HmrcFrontendDependency.hmrcFrontendVersion | ||
import uk.gov.hmrc.helpers.MessagesSupport | ||
import uk.gov.hmrc.support.TemplateIntegrationBaseSpec | ||
|
||
import scala.reflect.ClassTag | ||
import scala.util.Try | ||
|
||
/** | ||
* Base class for integration testing a Twirl template against the Nunjucks template rendering service, | ||
* where the template takes a viewmodel plus an implicit Messages API | ||
* | ||
* @tparam T Type representing the input parameters of the Twirl template | ||
*/ | ||
abstract class MessagesAwareTemplateIntegrationSpec[T: OWrites: Arbitrary, C <: Template2[ | ||
T, | ||
Messages, | ||
HtmlFormat.Appendable | ||
]: ClassTag]( | ||
hmrcComponentName: String, | ||
seed: Option[String] = None | ||
) extends TemplateIntegrationBaseSpec[T](hmrcComponentName, seed) | ||
with MessagesSupport { | ||
|
||
protected val libraryName: String = "hmrc" | ||
|
||
protected val libraryVersion: String = hmrcFrontendVersion | ||
|
||
private val component: C = app.injector.instanceOf[C] | ||
|
||
def render(templateParams: T): Try[HtmlFormat.Appendable] = | ||
Try(component.render(templateParams, implicitly)) | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/support/TemplateIntegrationMetaSpec.scala
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,22 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.hmrcfrontend.support | ||
|
||
import uk.gov.hmrc.support.TemplateIntegrationBaseMetaSpec | ||
|
||
|
||
class TemplateIntegrationMetaSpec extends TemplateIntegrationBaseMetaSpec("hmrc-frontend") |
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
24 changes: 24 additions & 0 deletions
24
.../src/test/scala/uk/gov/hmrc/hmrcfrontend/views/components/HmrcFooterIntegrationSpec.scala
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,24 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.hmrcfrontend.views.components | ||
|
||
import uk.gov.hmrc.hmrcfrontend.support.MessagesAwareTemplateIntegrationSpec | ||
import uk.gov.hmrc.hmrcfrontend.views.html.components._ | ||
import uk.gov.hmrc.hmrcfrontend.views.viewmodels.footer.Generators._ | ||
|
||
object HmrcFooterIntegrationSpec | ||
extends MessagesAwareTemplateIntegrationSpec[Footer, HmrcFooter](hmrcComponentName = "hmrcFooter") |
26 changes: 26 additions & 0 deletions
26
...a/uk/gov/hmrc/hmrcfrontend/views/components/HmrcReportTechnicalIssueIntegrationSpec.scala
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,26 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.hmrcfrontend.views.components | ||
|
||
import uk.gov.hmrc.hmrcfrontend.support.TemplateIntegrationSpec | ||
import uk.gov.hmrc.hmrcfrontend.views.html.components._ | ||
import uk.gov.hmrc.hmrcfrontend.views.viewmodels.reporttechnicalissue.Generators._ | ||
|
||
object HmrcReportTechnicalIssueIntegrationSpec | ||
extends TemplateIntegrationSpec[ReportTechnicalIssue, HmrcReportTechnicalIssue]( | ||
hmrcComponentName = "hmrcReportTechnicalIssue" | ||
) |
66 changes: 66 additions & 0 deletions
66
it-play-30/src/test/scala/uk/gov/hmrc/support/TemplateIntegrationBaseMetaSpec.scala
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,66 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.support | ||
|
||
import better.files.File | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
abstract class TemplateIntegrationBaseMetaSpec(val libraryName: String, val ignoredHelpers: Seq[String] = Seq.empty) | ||
extends AnyWordSpec | ||
with Matchers { | ||
|
||
private val libraryDir = libraryName.replace("-", "") | ||
private val libraryPrefix = libraryName.split('-').head | ||
|
||
private val itPath = "it-play-30" | ||
private val itRoot = File(itPath) | ||
private val testRoot = itRoot / "src" / "test" / "scala" | ||
private val componentTestDir = testRoot / "uk" / "gov" / "hmrc" / libraryDir / "views" / "components" | ||
|
||
private val mainPath = "play-frontend-hmrc-play-30" | ||
private val mainRoot = File(mainPath) | ||
private val templatesRoot = mainRoot / "src" / "main" / "twirl" | ||
private val templatesDir = templatesRoot / "uk" / "gov" / "hmrc" / libraryDir / "views" / "components" | ||
|
||
this.getClass.getCanonicalName when { | ||
|
||
val templates = templatesDir.children | ||
.filter(_.isRegularFile) | ||
.map(_.name) | ||
.map(filename => filename.split('.').head) | ||
.map(name => s"${name.head.toLower}${name.tail}") | ||
.filter(_.startsWith(libraryPrefix)) | ||
.filterNot(ignoredHelpers.contains(_)) | ||
.toList | ||
.sorted | ||
|
||
templates.foreach { template => | ||
s"component is $template" should { | ||
|
||
"be covered by an integration test" in { | ||
withClue(s"""no test found for component "$template" under $componentTestDir""") { | ||
componentTestDir.children | ||
.filter(_.isRegularFile) | ||
.exists(_.contentAsString.contains(s""""$template"""")) should be(true) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
1 change: 1 addition & 0 deletions
1
...s/fixtures/govuk-frontend/excluded-fixtures/password-input-attributes/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...rces/fixtures/govuk-frontend/excluded-fixtures/password-input-classes/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...rces/fixtures/govuk-frontend/excluded-fixtures/password-input-default/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...ources/fixtures/govuk-frontend/excluded-fixtures/password-input-value/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...ures/govuk-frontend/excluded-fixtures/password-input-with-describedBy/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...es/govuk-frontend/excluded-fixtures/password-input-with-error-message/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...xtures/govuk-frontend/excluded-fixtures/password-input-with-hint-text/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...-frontend/excluded-fixtures/password-input-with-label-as-page-heading/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...ntend/excluded-fixtures/password-input-with-new-password-autocomplete/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...res/govuk-frontend/excluded-fixtures/password-input-with-translations/README.md
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 @@ | ||
This fixture is excluded because we decided to not yet implement the Password Input component - see [ADR-0021](docs/maintainers/adr/0021-defer-inclusion-of-password-field.md) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.