io.github.frikit.twirlspec
Members list
Packages
Type members
Classlikes
Every rule module and the message-file matchers, in one mixin.
Every rule module and the message-file matchers, in one mixin.
trait ViewSpecBase extends AnyWordSpec with Matchers with TwirlSpec with AllChecks
Mix the modules in individually instead when a project wants some and not others — a project not using the GOV.UK Design System has no use for io.github.frikit.twirlspec.govuk.GovukChecks.
Attributes
- Source
- AllChecks.scala
- Supertypes
-
trait MessagesMatcherstrait I18nCheckstrait CoverageCheckstrait HtmlCheckstrait AriaCheckstrait QualityCheckstrait GovukCheckstrait WcagCheckstrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait GovukServiceCheckstrait HmrcServiceChecks
AllChecks for a GOV.UK transactional service: every rule, less the ones about search results, and with the platform's own head script left alone.
AllChecks for a GOV.UK transactional service: every rule, less the ones about search results, and with the platform's own head script left alone.
trait ViewSpecBase extends AnyWordSpec with Matchers with TwirlSpec with GovukServiceChecks
A service is reached from GOV.UK rather than from a search engine, often keeps its pages out of search on purpose, and titles every page in the Design System's "Page - Service - GOV.UK" pattern, so io.github.frikit.twirlspec.quality.MetadataStandards.searchRules would warn on every page it has. And scripts-are-deferred would warn on every page that carries HMRC's tracking-consent script, which the platform puts in the head on purpose, so here it leaves GovukServiceChecks.platformScripts alone and still reports the service's own. Everything else AllChecks runs, this runs.
Mix it in after any rule trait of your own: a trait mixed in later adds its rules after this one has filtered.
Attributes
- Companion
- object
- Source
- GovukServiceChecks.scala
- Supertypes
-
trait AllCheckstrait MessagesMatcherstrait I18nCheckstrait CoverageCheckstrait HtmlCheckstrait AriaCheckstrait QualityCheckstrait GovukCheckstrait WcagCheckstrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait HmrcServiceChecks
What GovukServiceChecks knows about a GOV.UK service's platform.
What GovukServiceChecks knows about a GOV.UK service's platform.
Attributes
- Companion
- trait
- Source
- GovukServiceChecks.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
GovukServiceChecks.type
What HmrcServiceChecks knows about play-frontend-hmrc's markup.
What HmrcServiceChecks knows about play-frontend-hmrc's markup.
Attributes
- Companion
- trait
- Source
- HmrcServiceChecks.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
HmrcServiceChecks.type
GovukServiceChecks for an HMRC service built on play-frontend-hmrc, with what every such service would otherwise write on its spec base:
GovukServiceChecks for an HMRC service built on play-frontend-hmrc, with what every such service would otherwise write on its spec base:
trait ViewSpecBase extends AnyWordSpec with Matchers with TwirlSpec with HmrcServiceChecks
The report-a-problem link every page inherits is left out of coverage, in whichever language it reads, and "HMRC" may read the same in every language. The link's own layout deserves a test of its own, and the rules still check it.
Attributes
- Companion
- object
- Source
- HmrcServiceChecks.scala
- Supertypes
-
trait GovukServiceCheckstrait AllCheckstrait MessagesMatcherstrait I18nCheckstrait CoverageCheckstrait HtmlCheckstrait AriaCheckstrait QualityCheckstrait GovukCheckstrait WcagCheckstrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
A page in a catalogue, and the rules it is excused from.
A page in a catalogue, and the rules it is excused from.
Value parameters
- label
-
what its tests are called
- standardsExcept
-
the standards rules it is excused from
- states
-
the ways it is rendered, at least one
- translationExcept
-
the language comparison rules it is excused from
Attributes
- Source
- PageCatalogue.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A service's pages as data, and the checks every page needs, for any test style: all at once, by checkStandards and checkTranslation, or one by one, by checksOf. PageCatalogue is the same for AnyWordSpec, with a test written for each check.
A service's pages as data, and the checks every page needs, for any test style: all at once, by checkStandards and checkTranslation, or one by one, by checksOf. PageCatalogue is the same for AnyWordSpec, with a test written for each check.
Nothing is rendered until a check runs, so each state renders in the language being checked. A check runs every state in every language, and its failure reports each that went wrong, by state and language.
Attributes
- Source
- PageCatalogue.scala
- Supertypes
-
trait I18nCheckstrait TwirlSpectrait SuiteLifecycletrait SuiteMixintrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait PageCatalogue
- Self type
-
Suite & Alerting
A table of a service's pages, with a test for each check on each page, so the report lists what was checked:
A table of a service's pages, with a test for each check on each page, so the report lists what was checked:
class EveryPageSpec extends ViewSpecBase with PageCatalogue {
catalogue(
staticPage("Info")(inject[InfoView](draftId)),
formPage("Name", nameForm)(inject[NameView](_, draftId)),
formPage("Date of birth", dobForm, "part of a date" -> Map("value.day" -> "1"))(
inject[DateOfBirthView](_, draftId)
),
staticPage("Not found")(inject[PageNotFoundView]())
.exceptTranslation("i18n-same-links")
)
}
Name
- must render blank, in en
- must render with errors, in en
- must meet one-h1 in en: a page has exactly one
=
- must render blank, in cy
- must meet one-h1 in cy: a page has exactly one
=
- must translate consistently by i18n-same-links, cy against en: every language links to the same places
It writes its tests in the AnyWordSpec style. For another style, mix in PageCases and call its checks from tests of your own.
Attributes
- Source
- PageCatalogue.scala
- Supertypes
-
trait PageCasestrait I18nCheckstrait TwirlSpectrait SuiteLifecycletrait SuiteMixintrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationstrait AnyWordSpecLiketrait Documentingtrait Alertingtrait Notifyingtrait Informingtrait CanVerbtrait MustVerbtrait ShouldVerbtrait TestRegistrationtrait TestSuitetrait Suitetrait Serializabletrait Assertionstrait TripleEqualstrait TripleEqualsSupportclass Objecttrait Matchableclass AnyShow all
One of a page's checks on its own: its name, as a test's name reads after the page's label and must, and the check.
One of a page's checks on its own: its name, as a test's name reads after the page's label and must, and the check.
Attributes
- Source
- PageCatalogue.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
One way a page can be rendered.
One way a page can be rendered.
Attributes
- Source
- PageCatalogue.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Starts each run of a suite with a clean coverage and exclusion record, and drops both once it has finished, so a spec run again in the same JVM — from an sbt shell, say — cannot pass assertEverything or unusedExclusions on what an earlier run asserted.
Starts each run of a suite with a clean coverage and exclusion record, and drops both once it has finished, so a spec run again in the same JVM — from an sbt shell, say — cannot pass assertEverything or unusedExclusions on what an earlier run asserted.
TwirlSpec mixes it in. A spec base built on TwirlSpecDsl mixes it in itself:
trait ViewSpecBase extends AnyWordSpec with Matchers with GuiceOneAppPerSuite
with TwirlSpecDsl with SuiteLifecycle
The run OneInstancePerTest (and so ParallelTestExecution) makes for each test on its own instance leaves the records alone, since the suite's other tests are still adding to them; ScalaTest marks that run with runTestInNewInstance. A BeforeAndAfterAll mixed in after this trait runs its afterAll once the records have been dropped.
Attributes
- Source
- SuiteLifecycle.scala
- Supertypes
-
trait SuiteMixinclass Objecttrait Matchableclass Any
- Known subtypes
- Self type
-
Suite
ScalaTest matchers over a rendered page.
ScalaTest matchers over a rendered page.
Attributes
- Source
- TwirlMatchers.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait TwirlSpecDsltrait AriaCheckstrait AllCheckstrait GovukServiceCheckstrait HmrcServiceCheckstrait GovukCheckstrait HtmlCheckstrait I18nCheckstrait PageCasestrait PageCataloguetrait TwirlSuitetrait CoverageCheckstrait QualityCheckstrait WcagCheckstrait TwirlSpecShow all
- Self type
The batteries-included entry point: an application, the implicits a Twirl view needs, and language switching, on top of the TwirlSpecDsl surface.
The batteries-included entry point: an application, the implicits a Twirl view needs, and language switching, on top of the TwirlSpecDsl surface.
Attributes
- Source
- TwirlSpec.scala
- Supertypes
-
trait SuiteLifecycletrait SuiteMixintrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait PageCasestrait PageCatalogue
- Self type
-
Suite & Alerting
The whole authoring surface. Declares no implicits and builds no application, so it drops into an existing spec base.
The whole authoring surface. Declares no implicits and builds no application, so it drops into an existing spec base.
Attributes
- Source
- TwirlSpecDsl.scala
- Supertypes
-
trait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait AriaCheckstrait AllCheckstrait GovukServiceCheckstrait HmrcServiceCheckstrait GovukCheckstrait HtmlCheckstrait I18nCheckstrait PageCasestrait PageCataloguetrait TwirlSuitetrait CoverageCheckstrait QualityCheckstrait WcagCheckstrait TwirlSpecShow all
How TwirlSpecReporter lays a run out.
How TwirlSpecReporter lays a run out.
Attributes
- Companion
- class
- Source
- TwirlSpecReporter.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TwirlSpecReporter.type
A report of a test run, as a page to read and as Markdown for a CI summary: how many tests passed, failed, warned and were cancelled, how long they took, and each suite's tests, with a catalogue's checks laid out as a table of rules by language and every failure's message beside it.
A report of a test run, as a page to read and as Markdown for a CI summary: how many tests passed, failed, warned and were cancelled, how long they took, and each suite's tests, with a catalogue's checks laid out as a table of rules by language and every failure's message beside it.
Add it to a run, in build.sbt:
Test / testOptions += Tests.Argument(
TestFrameworks.ScalaTest, "-C", "io.github.frikit.twirlspec.TwirlSpecReporter"
)
It writes index.html and report.md to target/twirl-spec-report, or to the directory the twirlspec.report.dir system property or the TWIRLSPEC_REPORT_DIR environment variable names, as each suite finishes and when the run does, and then says where.
Attributes
- Companion
- object
- Source
- TwirlSpecReporter.scala
- Supertypes
-
trait Reporterclass Objecttrait Matchableclass Any
twirl-spec for MUnit: what TwirlSpec gives a ScalaTest spec, for an MUnit suite. An application shared across the JVM, inject[View], languages, the expectation DSL, assertions over the same matchers, and the page catalogue as a test for each check:
twirl-spec for MUnit: what TwirlSpec gives a ScalaTest spec, for an MUnit suite. An application shared across the JVM, inject[View], languages, the expectation DSL, assertions over the same matchers, and the page catalogue as a test for each check:
class NameViewSuite extends TwirlSuite with HmrcServiceChecks {
private val view = inject[NameView]
private val form = Form(single("value" -> text))
cataloguePage(formPage("NameView", form)(view(_))) {
test("NameView asks for the name") {
assertDisplays(renderPage(view(form)), heading("name.heading"))
}
}
}
Its rules are those its rule traits give, as in a ScalaTest spec, and its failures are MUnit's, with the same messages. ScalaTest stays on the class path, as the rules and matchers are built on it, but nothing here runs it.
Attributes
- Source
- TwirlSuite.scala
- Supertypes
-
trait I18nCheckstrait TwirlSpecDsltrait TwirlMatcherstrait ContentExpectationstrait FormExpectationstrait FramingExpectationsclass FunSuitetrait BaseFunSuitetrait EventuallyTransformstrait ValueTransformstrait SuiteTransformstrait TestTransformstrait TestOptionsConversionstrait FunFixturestrait Assertionstrait CompileErrorMacroclass Suitetrait PlatformSuiteclass Objecttrait Matchableclass AnyShow all