Issue #3632767: Add test coverage for forward navigation, progress bar classes and error logging
Closes #3632767
Fixes #3632767.
Summary
Adds tests for the module's main behavior, which had little or no coverage: forward navigation through the progress bar, errors shown again when a page is revisited, the progress bar and tracker classes, prevent_next_validation, the page visit and error logging, and the webform settings changed when forward navigation is enabled. The tests record current behavior so that changes such as #3632734, #3632735 and #3632736 can be reviewed against them.
No module code changes.
Tests
ForwardNavigationTest (Functional)
| Test | Checks |
|---|---|
testForwardNavigation |
Every page link can be used from the first page. Skipping ahead does not validate, going back shows the page's logged error, and fixing it marks the page complete. Runs with the progress tracker (has-errors, is-complete, is-active) and the progress bar (--errors, --done, --current). |
testWithoutForwardNavigation |
Later pages cannot be reached without forward navigation. |
testPreventNextValidation |
Next with an empty required field moves on when prevent_next_validation is enabled, and stays on the page with the error when it is not. |
WebformNavigationHelperTest (Kernel)
| Test | Checks |
|---|---|
testPageVisits |
Saving a new submission logs a visit to the first page, a page is only logged once, and nothing is logged for a submission that is not saved. |
testGetErrors |
getErrors() returns the errors for all pages or for one page. |
testLogPageErrors |
An error on a composite's sub-element is logged under the composite's page, an error without an element under the current page, and errors for pages that were not validated are kept. Only one error log is kept per submission. |
testStashedErrors |
Errors for a new submission are stashed, logged once it is saved, and the stash is cleared. |
testLogsDeletedWithSubmission |
Deleting a submission deletes its log rows, and not those of other submissions. |
ForwardNavigationSettingsTest (Kernel)
| Test | Checks |
|---|---|
testForwardNavigationSettings |
Enabling forward navigation sets draft to all, purge_days to 365 and wizard_progress_link, and changes purge from none to draft, draft to draft, and completed to all. |
testPurgeDaysKept |
An existing purge_days value is kept. |
testSettingsUnchangedWithoutForwardNavigation |
No settings change when forward navigation is disabled. |
Checking the tests
Each of these changes makes the matching test fail: not unlocking the forward page links, not adding the error class, and logging a page visit more than once.
CI cleanup
The same changes as in !27 (merged), so whichever is merged first, the other merges cleanly:
- Add
.cspell-project-words.txtand fix the "Associatve" typo in the progress bar and progress tracker templates. - Exclude the CI-generated
gitlab_templates_version.txtfrom phpcs.
CI: test the supported Drupal versions
Webform 6.3 supports ^10.3 || ^11.0, but the pipeline only tested the current Drupal 11 release. .gitlab-ci.yml now opts in to:
| Variant | Runs automatically on |
|---|---|
| Previous major (Drupal 10) | Merge requests and pushes |
| Previous minor (Drupal 11) | Pushes |
| Next minor (Drupal 11 dev) | Pushes |
Each can also be run by hand from any pipeline. The next major is not tested, since Webform does not support it yet.
Supported versions
The requirements now match what CI tests:
webformnavigation.info.yml:core_version_requirementfrom^9 || ^10 || ^11to^10.3 || ^11.composer.json:drupal/corefrom^9.0 || ^10 || ^11to^10.3 || ^11, anddrupal/webformfrom^5.16 || ^6.0to^6.2.
Drupal 9 has been end of life since November 2023, and Webform 5.x only supports Drupal 8 and 9; neither was tested. This should be released as a new minor version, with the dropped support noted in the release notes. Composer keeps Drupal 9 sites on the last release that supports them.
Notes for review
webformnavigation_webform_presave()changes apurgesetting of "all" to "draft", because theswitchfalls through to "draft" and the condition before it is always true. That case is left out oftestForwardNavigationSettingsso the tests don't lock in the bug; it should be fixed in a separate issue.- The
additional_error_messagesetting is saved but never used, so it has no test here.