Skip to content

Add more specs for content blocks#16323

Merged
alecslupu merged 13 commits intodevelopfrom
test/content-blocks-specs
Mar 11, 2026
Merged

Add more specs for content blocks#16323
alecslupu merged 13 commits intodevelopfrom
test/content-blocks-specs

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Mar 5, 2026

🎩 What? Why?

After the redesign there were some pending specs for the content blocks. This PR adds them so we can close #10415.

📌 Related Issues

Testing

Everything should be green

♥️ Thank you!

Summary by CodeRabbit

  • Tests

    • Added system and component tests for admin publish/unpublish flows and comprehensive homepage content-block rendering, order, and admin UI actions.
    • Added cell/unit tests for content-block admin display, edit/delete links, and edge cases.
  • Style

    • Updated meeting date markup and corresponding stylesheet behavior to use inline elements and adjusted empty-state hiding.

@andreslucena andreslucena added the type: internal PRs that aren't necessary to add to the CHANGELOG for implementers label Mar 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13d9b209-5ec5-46ad-8aaa-2f3bbf073029

📥 Commits

Reviewing files that changed from the base of the PR and between be55eb0 and 2c1cf84.

📒 Files selected for processing (1)
  • decidim-meetings/app/cells/decidim/meetings/dates_and_map/show.erb

📝 Walkthrough

Walkthrough

Adds new admin system and cell tests for publishing/unpublishing content blocks, expands homepage system tests to cover many content blocks and ordering, and changes meeting date markup from

to with a corresponding stylesheet selector update.

Changes

Cohort / File(s) Summary
Admin tests
decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb, decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb
New system and cell specs: admin publishes/unpublishes content blocks; asserts presence/absence of hero block on homepage; cell tests verify labels, edit/delete links, delete method/data, draggable handle, and edge cases (non-persisted, no settings).
Core homepage tests
decidim-core/spec/system/homepage_spec.rb
Expanded homepage system spec to create and assert rendering/order of many content blocks (hero, sub_hero, statistics, highlighted banners, processes, assemblies, meetings, custom HTML), plus header-snippet stubbing adjustments and simplified stats assertions.
Meetings markup & styles
decidim-meetings/app/cells/decidim/meetings/meeting_l/image.erb, decidim-meetings/app/cells/decidim/meetings/dates_and_map/show.erb, decidim-meetings/app/packs/stylesheets/decidim/meetings/_item.scss
Changed date-related wrappers from <p> to <span> in meeting cells and updated SCSS selector to check >span emptiness; markup semantics changed from block to inline, no business logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • alecslupu
  • github-actions

Poem

🐇 I hopped through specs with tiny paws,
I nudged hero blocks and checked their laws.
Spans now whisper dates in line,
Tests march in order, tidy and fine.
A cheerful rabbit crowns the cause.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Markup consistency changes in meeting cell templates (replacing

with tags) are closely related to content block testing but not explicitly required by #10415.

Clarify whether markup consistency changes were necessary refactoring for the specs or should be in a separate PR focused solely on semantic HTML improvements.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change—adding more test specifications for content blocks—which aligns with the PR's primary objective.
Linked Issues check ✅ Passed The PR successfully implements all pending coding requirements from issue #10415: unit tests for HomepageContentBlockCell, system tests for admin publishing/unpublishing workflows, and integration tests with multiple content blocks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/content-blocks-specs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@decidim-admin/spec/cells/decidim/admin/content_block_cell_spec.rb`:
- Around line 21-35: The tests are matching destroy/edit links too loosely:
tighten the positive assertion in the "renders a link to destroy the content
block" example to look for the exact destroy anchor (e.g. href matching
/content_blocks/:id$ and data-method="delete") instead of /content_blocks/ so it
doesn't pick up edit links, and in the "when content block is not persisted"
context replace the /delete/ href check with absence of the destroy anchor (e.g.
not have_css('a[data-method="delete"]') or not have_link(href:
%r{/content_blocks/\d+$'})) while keeping the edit link assertion precise (e.g.
not have_link(href: %r{/content_blocks/\d+/edit$'})); update assertions that
reference subject and content_block accordingly.

In
`@decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb`:
- Around line 14-32: The spec currently seeds content_block state directly (let!
hero_block with published_at) instead of exercising the admin publish/unpublish
workflow; update the spec in admin_publishes_unpublishes_content_blocks_spec.rb
to perform real UI actions: sign in as an admin, navigate to the admin content
blocks UI (the page that manages ContentBlock), use the publish/unpublish
controls for the created content_block (reference the let! hero_block), then
visit decidim.root_path and assert presence/absence with have_css("[id^=hero]");
alternatively, if you intend a state-only test, rename the example/context to
reflect "state-based homepage rendering" instead of implying an admin workflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33ef3a08-688b-436d-9fc3-2af3ffb60eb3

📥 Commits

Reviewing files that changed from the base of the PR and between 3ecf67e and fdbf1ec.

📒 Files selected for processing (3)
  • decidim-admin/spec/cells/decidim/admin/content_block_cell_spec.rb
  • decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb
  • decidim-core/spec/system/homepage_content_blocks_spec.rb

github-actions[bot]
github-actions bot previously approved these changes Mar 5, 2026
github-actions[bot]
github-actions bot previously approved these changes Mar 6, 2026
github-actions[bot]
github-actions bot previously approved these changes Mar 6, 2026
github-actions[bot]
github-actions bot previously approved these changes Mar 6, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb (1)

17-19: Consider using a more specific regex pattern for consistency.

Line 33 uses the more precise pattern %r{/content_blocks/\d+/edit$}. Using the same pattern here would improve consistency and reduce the risk of false positives.

♻️ Suggested improvement
   it "renders a link to edit the content block" do
-    expect(subject).to have_link(href: /edit/)
+    expect(subject).to have_link(href: %r{/content_blocks/\d+/edit$})
   end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb`
around lines 17 - 19, The test in
decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb uses
a broad regex (/edit/) which can yield false positives; update the expectation
in the "renders a link to edit the content block" example (the line with
expect(subject).to have_link(href: /edit/)) to use the more specific pattern
%r{/content_blocks/\d+/edit$} so it matches the exact edit path for a content
block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb`:
- Around line 17-19: The test in
decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb uses
a broad regex (/edit/) which can yield false positives; update the expectation
in the "renders a link to edit the content block" example (the line with
expect(subject).to have_link(href: /edit/)) to use the more specific pattern
%r{/content_blocks/\d+/edit$} so it matches the exact edit path for a content
block.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a4ca0dd0-837c-4440-8bc2-4406d0c90c99

📥 Commits

Reviewing files that changed from the base of the PR and between fdbf1ec and 0b7a920.

📒 Files selected for processing (3)
  • decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb
  • decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb
  • decidim-core/spec/system/homepage_content_blocks_spec.rb
🚧 Files skipped from review as they are similar to previous changes (2)
  • decidim-core/spec/system/homepage_content_blocks_spec.rb
  • decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 6, 2026
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do some changes. Could you have a look? Thanks

@alecslupu alecslupu assigned andreslucena and unassigned alecslupu Mar 8, 2026
@alecslupu
Copy link
Copy Markdown
Contributor

@andreslucena , i am assigning back to you for your visibility.

github-actions[bot]
github-actions bot previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
decidim-core/spec/system/homepage_spec.rb (1)

425-445: Consider setting explicit weights for ordering test robustness.

The ordering test relies on implicit weight assignment (likely from creation order or factory defaults). While this tests real integration behavior, the test could become flaky if factory defaults change.

💡 Optional: Set explicit weights for more predictable ordering
 before do
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :hero)
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :sub_hero)
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :how_to_participate)
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :stats)
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :footer_sub_hero)
-  create(:content_block, organization:, scope_name: :homepage, manifest_name: :highlighted_content_banner, settings: highlighted_content_banner_settings)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :hero, weight: 1)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :sub_hero, weight: 2)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :how_to_participate, weight: 3)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :stats, weight: 4)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :footer_sub_hero, weight: 5)
+  create(:content_block, organization:, scope_name: :homepage, manifest_name: :highlighted_content_banner, weight: 6, settings: highlighted_content_banner_settings)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@decidim-core/spec/system/homepage_spec.rb` around lines 425 - 445, The test
relies on implicit block weights which can be flaky; update the spec to create
or update the homepage content blocks with explicit weight attributes so their
vertical order is deterministic: set weights such that hero < sub_hero <
how_to_participate < statistics < footer_sub_hero < highlighted_content_banner
(e.g., assign numeric weight values via your factories or setup code before
loading the page), then keep the existing position assertions (hero_section,
sub_hero_section, how_to_participate_section, stats_section,
footer_sub_hero_section, highlighted_content_banner) to verify the order.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@decidim-meetings/app/cells/decidim/meetings/meeting_l/image.erb`:
- Around line 3-17: The current CSS selector empty:[&>p]:hidden in
decidim-meetings/app/packs/stylesheets/decidim/meetings/_item.scss no longer
matches because the template in
decidim-meetings/app/cells/decidim/meetings/meeting_l/image.erb now uses <span>
elements; update that selector to empty:[&>span]:hidden (or a more generic
empty:[&>*]:hidden) so empty date child elements are correctly hidden, and
verify the rule still targets the same parent element/class used for the
calendar date segments.

---

Nitpick comments:
In `@decidim-core/spec/system/homepage_spec.rb`:
- Around line 425-445: The test relies on implicit block weights which can be
flaky; update the spec to create or update the homepage content blocks with
explicit weight attributes so their vertical order is deterministic: set weights
such that hero < sub_hero < how_to_participate < statistics < footer_sub_hero <
highlighted_content_banner (e.g., assign numeric weight values via your
factories or setup code before loading the page), then keep the existing
position assertions (hero_section, sub_hero_section, how_to_participate_section,
stats_section, footer_sub_hero_section, highlighted_content_banner) to verify
the order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a8a08d8-0f8c-415c-af60-1c5f49f937d3

📥 Commits

Reviewing files that changed from the base of the PR and between 0b7a920 and fba37db.

📒 Files selected for processing (2)
  • decidim-core/spec/system/homepage_spec.rb
  • decidim-meetings/app/cells/decidim/meetings/meeting_l/image.erb

github-actions[bot]
github-actions bot previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@decidim-meetings/app/packs/stylesheets/decidim/meetings/_item.scss`:
- Around line 35-39: The empty-state hide rule for the .-month, .-day, .-year
selectors was narrowed to only target direct <span> children
(empty:[&>span]:hidden) which breaks compatibility with the calendar markup that
still renders those nodes as direct <p> elements; update the selector on those
rules (the &-month, &-day, &-year block) to also target direct <p> children
(e.g. include &>p alongside &>span) so empty-state hiding continues to work, or
add an equivalent empty:[&>p]:hidden rule next to the existing one to preserve
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 114b58eb-d0f8-4d17-959a-59af8ea34d6d

📥 Commits

Reviewing files that changed from the base of the PR and between fba37db and be55eb0.

📒 Files selected for processing (1)
  • decidim-meetings/app/packs/stylesheets/decidim/meetings/_item.scss

@andreslucena
Copy link
Copy Markdown
Member Author

@alecslupu can you check this out again? I think everything is already answered

@andreslucena andreslucena dismissed alecslupu’s stale review March 11, 2026 08:33

Ready for another round

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@alecslupu alecslupu merged commit 353b5d7 into develop Mar 11, 2026
84 of 86 checks passed
@alecslupu alecslupu deleted the test/content-blocks-specs branch March 11, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: admin module: core module: meetings type: internal PRs that aren't necessary to add to the CHANGELOG for implementers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign / Content blocks follow up specs

2 participants