Skip to content

Re-anchored the work page Behat assertions on fixtures under test mode. - #304

Merged
AlexSkrypnyk merged 3 commits into
developfrom
feature/decouple-tests
Aug 11, 2026
Merged

Re-anchored the work page Behat assertions on fixtures under test mode.#304
AlexSkrypnyk merged 3 commits into
developfrom
feature/decouple-tests

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Aug 11, 2026

Copy link
Copy Markdown
Member

Checklist before requesting a review

  • Subject includes ticket number as [#123] Verb in past tense.
  • Ticket number #123 added to description
  • Added context in Changed section
  • Self-reviewed code and commented in commented complex areas.
  • Added tests for fix/feature.
  • Relevant tests run and passed locally.

Changed

CI provisions from the production database (VORTEX_FETCH_DB_ENVIRONMENT: main), so any assertion measuring live editorial content breaks the pipeline without a code change. Two such assertions in tests/behat/features/our_work_page.feature did exactly that on develop: a headline that editors have since replaced, and a promo-card count that only ever measured how many real projects happened to be published. The scenarios are kept, but re-anchored on fixtures.

  1. Dropped the editorial-copy assertions from the first scenario. The page no longer contains Work you can go and look at. - its h1 is now Projects, and what we did on them. The scenario keeps the 200 check and the structural primary-navigation assertion (the menu's first level-0 item points at /work). Its name and the feature's user story were adjusted to match what is asserted.
  2. Rebuilt the promo-card scenario for the two automated lists the page now carries. It creates six published projects tagged Custom development (the top list), six tagged Open source (the bottom list), and one draft, then asserts six promo cards in each list, a title scoped into each list so the tag filtering itself is proven, and that the draft stays invisible. The counts come entirely from the fixtures, so publishing or unpublishing a real project cannot move them.
  3. Tagged that scenario @testmode and taught testmode about the list view. @testmode alone would have filtered nothing: the module only rewrites views named in testmode.settings.views_node, which defaults to content. web/sites/default/includes/modules/settings.testmode.php now adds civictheme_automated_list, the view behind every CivicTheme list component, whose node_field_data base table is what testmode's title LIKE '[TEST%' filter targets. The override is inert until test mode is switched on, so it has no effect outside the test run.
  4. Enabled testmode during provisioning on local and ci. The module ships in require but was enabled nowhere, so the @testmode hook died with Class "Drupal\testmode\Testmode" not found. It is listed in config_exclude_modules and therefore deliberately absent from the exported configuration, which makes scripts/provision-10-enable-dev-modules.sh the right place to enable it, alongside sdc_devel.
  5. Added the new config override to the nine full-array expectations in tests/phpunit/Drupal/EnvironmentSettingsTest.php, since assertConfig() compares the whole config array rather than a subset.

Each list is addressed through the components block rather than through its heading text or its ct-automated-list-<pid> id: the headings are editorial copy and the ids are paragraph ids, so both would reintroduce the coupling this PR removes. The two outer .ct-list elements are the only children of that block, which makes > .ct-list:first-child and > .ct-list:last-child stable handles.

One related item is left unchanged: error_pages.feature still visits the live editorial page /about-us for its "not an error page" control scenario. Its assertions are purely structural and it is passing, so it is out of scope here.

Screenshots

N/A

Before / After

BEFORE: assertions measured live production content
┌──────────────────────────────────────────────────────────────────────────┐
│ Scenario: page opens primary navigation and introduces the work
│ - sees "Work you can go and look at." <- copy since replaced
│ by "Projects, and what
│ we did on them."

│ Scenario: Published projects listed as promo cards, 12 to a page
│ - creates 13 [TEST] project fixtures, untagged
│ - asserts 12 ".ct-promo-card" in the FIRST list
│ <- fixtures never enter a
│ tag-filtered list, so
│ this counted the 9 real
│ client projects
└──────────────────────────────────────────────────────────────────────────┘
an editor publishes or unpublishes -> CI red

AFTER: assertions measure the fixtures only
┌──────────────────────────────────────────────────────────────────────────┐
│ Scenario: The work section is reachable and leads the primary navigation
│ - 200 response
│ - primary-nav first level-0 item points at /work

│ Scenario (@Testmode): Each list shows only the published projects
│ tagged for it
│ - 6 published + tag "Custom development" -> top list
│ - 6 published + tag "Open source" -> bottom list
│ - 1 draft + tag "Custom development"
│ - test mode filters both lists to titles LIKE "[TEST%"
│ - asserts 6 cards per list, a known title inside each list,
│ and the draft absent
└──────────────────────────────────────────────────────────────────────────┘
real content is filtered out -> CI stays green

How the lists are addressed:

div.block-field-blocknodecivictheme-pagefield-c-n-components
|
+-- div.ct-list <- "> .ct-list:first-child" Client work
|
+-- div.ct-list <- "> .ct-list:last-child" Open Source work

Wiring needed to make @Testmode actually filter:

provision-10-enable-dev-modules.sh enables testmode on local + ci
|
v
settings.testmode.php views_node += civictheme_automated_list
|
v
testmode_views_query_alter() node_field_data.title LIKE '[TEST%'
|
v
both /work lists fixtures only, real projects excluded

@AlexSkrypnyk AlexSkrypnyk added AUTOMERGE Pull request has been approved and set to automerge and removed AUTOMERGE Pull request has been approved and set to automerge labels Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The work page feature now checks anonymous access to /work and confirms that the page is the first primary-navigation item. Assertions for dynamic project content, pagination, editorial copy, and draft exclusion were removed.

Changes

Work page coverage

Layer / File(s) Summary
Work page smoke scenario
tests/behat/features/our_work_page.feature
The scenario checks a successful /work response and the first primary-navigation link. Fixture-based project, pagination, editorial copy, and draft visibility checks were removed.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title says assertions were re-anchored on fixtures, but the changes remove production-dependent assertions and a fixture-based scenario. Rename the title to state that production-content-dependent work page assertions were removed while core navigation and response checks remain.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/decouple-tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.51%. Comparing base (72a160c) to head (600b010).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #304   +/-   ##
========================================
  Coverage    84.51%   84.51%           
========================================
  Files           26       26           
  Lines          562      562           
========================================
  Hits           475      475           
  Misses          87       87           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexSkrypnyk
AlexSkrypnyk temporarily deployed to PR-304 August 11, 2026 01:54 Inactive
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 80%)

  Classes: 48.00% (12/25)
  Methods: 73.42% (58/79)
  Lines:   87.77% (653/744)
Per-class coverage
Drupal\do_ai_alt_text\AltTextGenerator
  Methods:  85.71% ( 6/ 7)   Lines:  98.72% ( 77/ 78)
Drupal\do_ai_alt_text\Plugin\Action\RegenerateImageAltText
  Methods: 100.00% ( 8/ 8)   Lines: 100.00% ( 63/ 63)
Drupal\do_base\EventSubscriber\PreviewLinkCacheSubscriber
  Methods:  33.33% ( 1/ 3)   Lines:  11.11% (  1/  9)
Drupal\do_base\EventSubscriber\ThemeColorSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  40.00% (  4/ 10)
Drupal\do_base\Hook\AutomatedListPagerHook
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% ( 31/ 31)
Drupal\do_base\Hook\MetatagsAlterHook
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 58/ 58)
Drupal\do_base\Twig\ImageDimensionsExtension
  Methods:  40.00% ( 2/ 5)   Lines:  81.48% ( 44/ 54)
Drupal\do_content_api\EventSubscriber\JsonApiWriteGateSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  88.89% (  8/  9)
Drupal\do_content_api\Hook\EntityCreateAccessHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 12/ 12)
Drupal\do_content_api\Hook\ModerationPolicyHook
  Methods:  50.00% ( 1/ 2)   Lines:  93.75% ( 15/ 16)
Drupal\do_content_api\Routing\RouteSubscriber
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  6/  6)
Drupal\do_feed\FeedUrlBuilder
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 18/ 18)
Drupal\do_feed\Form\FeedSettingsForm
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 15/ 15)
Drupal\do_feed\Hook\EntityDeleteHook
  Methods:  50.00% ( 1/ 2)   Lines:  92.31% ( 12/ 13)
Drupal\do_feed\Hook\EntityPresaveHook
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 54/ 54)
Drupal\do_feed\Hook\PreprocessParagraphHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
Drupal\do_feed\Hook\PreprocessViewsViewRowRssHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_feed\Hook\ViewsPreViewHook
  Methods:  50.00% ( 1/ 2)   Lines:  96.43% ( 27/ 28)
Drupal\do_generated_content\Generator\CaseMatrix
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 12/ 12)
Drupal\do_generated_content\Generator\RelativeDate
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  1/  1)

@AlexSkrypnyk AlexSkrypnyk changed the title Removed production content assertions from the work page Behat test. Re-anchored the work page Behat assertions on fixtures under test mode. Aug 11, 2026
@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Aug 11, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit 898b603 into develop Aug 11, 2026
10 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/decouple-tests branch August 11, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs review Pull request needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants