Problem/Motivation

The module ships no automated tests. Nothing verifies that the condition plugin is discovered, that its default configuration is what the schema describes, that the configuration form lists the paragraph types, or that the evaluation returns the right answer for a node that holds the selected paragraph type and for one that does not.

Without tests, the continuous integration pipeline added recently has nothing to run, so a merge request can only be judged by reading it. Every later change to this plugin, and there are several planned, would be a change nobody can verify.

Proposed resolution

Add a kernel test covering the plugin end to end.

The condition reads the node from the current route match, which a kernel test does not have. The test replaces the current_route_match service with a RouteMatch built around the node under test before creating the plugin instance, so the real evaluate() path is exercised rather than a shortcut.

The test creates two paragraph types, a "page" content type with an entity_reference_revisions field pointing at paragraphs, and two nodes: one holding a "search" paragraph and one holding a "text" paragraph. Note that paragraphs are referenced with entity_reference_revisions and not with the plain entity_reference field type, which the test helper makes explicit.

Coverage added: plugin discovery and provider, default configuration, the presence of the config schema, evaluation with no paragraph type selected, evaluation on a route without a node, evaluation matching and not matching, several selected types where any one is enough, the negated condition through the condition manager, the summary text in its three variants, and the configuration form options plus what submitting it stores.

Comments

trebormc created an issue. See original summary.

  • trebormc committed 396159b4 on 1.0.x
    Issue #3618984 by trebormc: Add kernel test coverage for the paragraph...
trebormc’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.