Related: T407815: Section collapsing applies to namespaces it should not apply to in mobile
Background
Under a very specific set of circumstances, we're ending up different treatments for articles in Parsoid and legacy parser when content is not arranged under h2 subheadings. This is due to the code not actually checking if the heading is an h2 explicitly, and looking at top level sections, which this h3 appears to erroneously be This is not supported behaviour.
In addition to this the English Wikitionary community in T376446 has requested that section collapsing does not apply to pages with only one section. This seems a reasonable request that should apply to all pages.
User story
As a reader of wikis on mobile once parsoid has rolled out, I want my reading experience to be consistent, and to understand the structure of an article based on its sections
Requirements
- Update MobileFrontend's section collapsing logic for legacy and parsoid so that it doesn't apply in the following circumstances:
- Only one heading in the page e.g. https://ru.m.wikipedia.org/wiki/%D0%97%D0%B0%D0%B1%D0%B5%D0%BB%D0%B8%D0%BD
- The first heading in the page is not an h2.
- The entire page is wrapped in a DIV
- When section collapsing does not apply to a page, no section collapse arrows should apply.
- The new treatment should be cache resistant by being an additive change - existing CSS should be preserved and new CSS using a new class on the HTML, parser or body element should be utilized. For example a class "mf-section-collapsing-disabled" should be added to the page and any CSS should target this element e.g. .mf-section-collapsing-disabled .section-heading .indicator { margin-right: 0;} to disable existing margin on indicator element for example.
Acceptance criteria
- All QA steps pass.
QA
For QA in beta cluster, for the following URLs:
Confirm section collapsing is available on the following URLS:
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=0
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=1
Confirm section collapsing is NOT available on the following URLS:
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=0
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=1
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=0
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=1
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=0
- https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=1
For QA in production:
- Confirm that for * https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=1 no section collapsing is available on the page
- Confirm that for * https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=0 no section collapsing is available on the page
BDD
Feature: Section collapsing logic updates
Scenario: Enable section collapsing when conditions are met
Given a page with multiple h2 headings not wrapped in a `<div>`
When the page is rendered
Then section collapsing should be available
Scenario: Disable section collapsing for pages with one heading
Given a page with only one heading
When the page is rendered
Then section collapsing should not be available
And the "mf-section-collapsing-disabled" class should be applied
Scenario: Disable section collapsing when the first heading is not an h2
Given a page where the first heading is not an h2
When the page is rendered
Then section collapsing should not be available
And the "mf-section-collapsing-disabled" class should be applied
Scenario: Disable section collapsing when the entire page is wrapped in a `<div>`
Given a page where all content is wrapped in a `<div>`
When the page is rendered
Then section collapsing should not be available
And the "mf-section-collapsing-disabled" class should be appliedTest Steps
Beta Cluster
Test Case 1: Verify section collapsing is available
- Visit the following URLs:
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=0
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=1
- Verify that section collapsing is available on these pages.
- AC1: Section collapsing is enabled.
Test Case 2: Verify section collapsing is not available
- Visit the following URLs:
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=0
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=1
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=0
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=1
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=0
• https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=1
- Verify that section collapsing is not available on these pages.
- AC2: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.
Production
Test Case 3: Verify section collapsing is not available in production
- Visit the following URLs:
• https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=1
• https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=0
- Verify that section collapsing is not available on these pages.
- AC3: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.
Rollback plan
Rollback - this does impact both legacy and parsoid HTML. It should be safe to roll back provided we add a new class to the page to identify pages where section collapsing is not available.









