Add more specs for content blocks#16323
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
decidim-admin/spec/cells/decidim/admin/content_block_cell_spec.rbdecidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rbdecidim-core/spec/system/homepage_content_blocks_spec.rb
decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rb
Show resolved
Hide resolved
decidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rb
Outdated
Show resolved
Hide resolved
38e7b60 to
0b7a920
Compare
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (3)
decidim-admin/spec/cells/decidim/admin/homepage_content_block_cell_spec.rbdecidim-admin/spec/system/admin_publishes_unpublishes_content_blocks_spec.rbdecidim-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
alecslupu
left a comment
There was a problem hiding this comment.
I would do some changes. Could you have a look? Thanks
|
@andreslucena , i am assigning back to you for your visibility. |
fba37db
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
decidim-core/spec/system/homepage_spec.rbdecidim-meetings/app/cells/decidim/meetings/meeting_l/image.erb
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
decidim-meetings/app/packs/stylesheets/decidim/meetings/_item.scss
|
@alecslupu can you check this out again? I think everything is already answered |
🎩 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
Summary by CodeRabbit
Tests
Style