Re-anchored the work page Behat assertions on fixtures under test mode. - #304
Merged
Conversation
📝 WalkthroughWalkthroughThe work page feature now checks anonymous access to ChangesWork page coverage
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
|
Code coverage (threshold: 80%) Per-class coverage |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
[#123] Verb in past tense.#123added to descriptionChangedsectionChanged
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 intests/behat/features/our_work_page.featuredid exactly that ondevelop: 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.Work you can go and look at.- itsh1is nowProjects, and what we did on them.The scenario keeps the200check 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.Custom development(the top list), six taggedOpen 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.@testmodeand taught testmode about the list view.@testmodealone would have filtered nothing: the module only rewrites views named intestmode.settings.views_node, which defaults tocontent.web/sites/default/includes/modules/settings.testmode.phpnow addscivictheme_automated_list, the view behind every CivicTheme list component, whosenode_field_database table is what testmode'stitle LIKE '[TEST%'filter targets. The override is inert until test mode is switched on, so it has no effect outside the test run.testmodeduring provisioning onlocalandci. The module ships inrequirebut was enabled nowhere, so the@testmodehook died withClass "Drupal\testmode\Testmode" not found. It is listed inconfig_exclude_modulesand therefore deliberately absent from the exported configuration, which makesscripts/provision-10-enable-dev-modules.shthe right place to enable it, alongsidesdc_devel.tests/phpunit/Drupal/EnvironmentSettingsTest.php, sinceassertConfig()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-listelements are the only children of that block, which makes> .ct-list:first-childand> .ct-list:last-childstable handles.One related item is left unchanged:
error_pages.featurestill visits the live editorial page/about-usfor 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