Skip to content

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Sep 25, 2025

Description

This should fix #3745, which seemed to happen after refactoring in #3462

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • Bug Fixes

    • Fixed summary rendering to prevent unintended page breaks in repeating groups and stop outer layout settings from affecting nested components, improving PDF layout consistency and page counts.
  • Tests

    • Added two end-to-end PDF tests covering different summary layouts and page-break behaviors.
    • Updated tests to use a feature-toggle helper instead of raw cookie-setting.
  • New Features

    • Added testing utilities: a controllable PDF freeze option, a page-break assertion helper, and a feature-toggle setter for test flows.

@olemartinorg olemartinorg self-assigned this Sep 25, 2025
@olemartinorg olemartinorg added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches labels Sep 25, 2025
@olemartinorg olemartinorg removed their assignment Sep 25, 2025
Copy link

coderabbitai bot commented Sep 25, 2025

📝 Walkthrough

Walkthrough

Stops forwarding pageBreak and grid overrides from SummaryComponent into RenderSummary. Adds PDF e2e tests for group/summary layouts and extends Cypress support with page-break counting, a feature-toggle helper, and a new testPdf(freeze) option; updates tests to use the new toggle helper.

Changes

Cohort / File(s) Change summary
Summary rendering overrides
src/layout/Summary/SummaryComponent.tsx
Stop forwarding pageBreak and grid in the overrides passed to RenderSummary; still forward largeGroup, display, and excludedChildren.
E2E PDF tests (group/summary)
test/e2e/integration/frontend-test/pdf.ts
Add two PDF tests exercising group/summary layouts (Summary1, Summary2) that set pdfLayoutName: 'summary', apply pageBreak on the repeating group, interact with rows, and assert page-break behavior via snapshots.
Cypress support — PDF helpers & toggles
test/e2e/support/custom.ts, test/e2e/support/global.ts
Add freeze?: boolean to testPdf (default true); when freeze is true preserve prior freeze/timer behavior, otherwise skip. Add expectPageBreaks(expectedCount) command to assert CSS page-break counts. Add setFeatureToggle(toggleName, value) command that stores a FEATURE_<toggle> cookie. Update types in global defs accordingly.
Tests updated to use feature helper
test/e2e/integration/multiple-datamodels-test/saving.ts
Replace direct cookie set with cy.setFeatureToggle('saveOnBlur', false) in test setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning Beyond the pageBreak fix scope, the PR includes generic test harness changes such as adding an unused freeze parameter to testPdf and migrating the save-on-blur test in multiple-datamodels-test/saving.ts to use setFeatureToggle, which are unrelated to restoring correct PDF behavior for repeating groups. Please remove or move the unrelated test updates—specifically the freeze flag addition and the save-on-blur test migration—into a separate PR, or clarify how these changes support the linked issue’s objectives.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the bug fix for the pageBreak behavior in repeating groups and directly reflects the primary change made in the summary rendering logic to address that issue.
Linked Issues Check ✅ Passed The changes correctly implement the fix for issue #3745 by stopping pageBreak propagation in SummaryComponentInner so breaks occur per repeating group instance, and the new E2E tests verify the restored behavior across both PDF layouts as required by the linked issue.
Description Check ✅ Passed The pull request description follows the repository template by including a detailed change summary, related issue reference, and a fully populated Verification/QA section covering manual testing, automated tests, accessibility, documentation, support, sprint board, and labels.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/pageBreak

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

@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)
test/e2e/integration/frontend-test/pdf.ts (1)

233-269: Solid regression test for summary-based PDF with pageBreak; consider waiting for intercepted settings

Test is focused and validates the bug fix via page count. Optional: ensure the layout settings interception has applied before proceeding to reduce flakiness.

Apply this diff to wait for the intercepted settings response after navigation:

-    cy.goto('group');
+    cy.goto('group');
+    cy.wait('@settings');
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1ff693 and 291a8eb.

📒 Files selected for processing (4)
  • src/layout/Summary/SummaryComponent.tsx (1 hunks)
  • test/e2e/integration/frontend-test/pdf.ts (1 hunks)
  • test/e2e/support/custom.ts (2 hunks)
  • test/e2e/support/global.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/layout/Summary/SummaryComponent.tsx
  • test/e2e/support/custom.ts
  • test/e2e/support/global.ts
  • test/e2e/integration/frontend-test/pdf.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Install
🔇 Additional comments (2)
src/layout/Summary/SummaryComponent.tsx (1)

192-195: Stop forwarding pageBreak/grid to inner summaries: correct fix for RepeatingGroup PDF regression

LGTM. Preventing inheritance of pageBreak and grid into RenderSummary resolves the per-field page breaks while still allowing the wrapper to apply page-level breaks via pageBreakStyles.

test/e2e/support/global.ts (1)

328-332: Good addition: Chainable typing for getPrintPageCount

API typing and brief doc are clear and sufficient for consumers.

Copy link

@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: 0

🧹 Nitpick comments (3)
test/e2e/support/global.ts (2)

37-37: Document freeze semantics in TestPdfOptions

Consider adding a brief JSDoc for freeze (default true) explaining it stubs timers to “freeze” the page during PDF assertions.


330-339: New Chainable API: typings align with implementations

Signatures for expectPageBreaks and setFeatureToggle match the implementations in custom.ts. Minor: the comment says “approximate number of pages” but the assertion is strict equality; consider clarifying wording.

test/e2e/support/custom.ts (1)

690-707: Restore cy.clock() and print emulation when not returning to form

When freeze is true, cy.clock() is installed but only restored inside the returnToForm branch later. If returnToForm is false, the stubbed timers (and print emulation) can leak and affect subsequent steps/tests.

Apply cleanup when not returning to form (add near the end of testPdf, just before the if (returnToForm) block):

// After the .then() that handles PDF assertions and optional snapshot:
if (!returnToForm) {
  if (freeze) {
    cy.clock().invoke('restore');
  }
  cy.setEmulatedMedia(); // reset to default (screen)
  cy.get('body').invoke('css', 'margin', '');
}

This keeps existing behavior for returnToForm while preventing state leakage otherwise.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 291a8eb and 6688536.

📒 Files selected for processing (4)
  • test/e2e/integration/frontend-test/pdf.ts (1 hunks)
  • test/e2e/integration/multiple-datamodels-test/saving.ts (1 hunks)
  • test/e2e/support/custom.ts (4 hunks)
  • test/e2e/support/global.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/integration/frontend-test/pdf.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • test/e2e/integration/multiple-datamodels-test/saving.ts
  • test/e2e/support/global.ts
  • test/e2e/support/custom.ts
🧠 Learnings (1)
📚 Learning: 2025-09-25T14:35:11.396Z
Learnt from: olemartinorg
PR: Altinn/app-frontend-react#3746
File: test/e2e/support/custom.ts:993-1002
Timestamp: 2025-09-25T14:35:11.396Z
Learning: In Cypress custom commands defined with `Cypress.Commands.add()`, you don't need to explicitly return the Cypress chain from the command function. The last command executed in the chain automatically becomes the yielded value. For example, `cy.window().then((win) => { return someValue; })` will yield `someValue` even without a `return` statement at the command function level.

Applied to files:

  • test/e2e/support/custom.ts
🧬 Code graph analysis (2)
test/e2e/support/global.ts (1)
src/features/toggles.ts (1)
  • IFeatureToggles (29-29)
test/e2e/support/custom.ts (1)
src/features/toggles.ts (1)
  • IFeatureToggles (29-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Install
🔇 Additional comments (6)
test/e2e/integration/multiple-datamodels-test/saving.ts (1)

14-14: Good move to typed feature toggles

Switching to cy.setFeatureToggle('saveOnBlur', false) improves readability and type safety. Looks correct here.

test/e2e/support/global.ts (1)

7-7: Type-safe toggle names import — LGTM

Importing IFeatureToggles keeps the Chainable signature strict and in sync with app toggles.

test/e2e/support/custom.ts (4)

15-15: Importing IFeatureToggles — LGTM

Keeps the command strongly typed against actual toggle keys.


640-640: Default freeze=true preserves previous behavior

Signature change is clear and backward compatible for existing tests.


998-1009: Page-break counter — LGTM

Simple and effective assertion under print emulation. Note: counts both break-before and break-after set to page (as intended).


1011-1013: Feature toggle via cookie — LGTM

Cookie naming aligns with FEATURE_. Using boolean.toString() matches prior convention.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This PR should be cherry-picked onto older release branches kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Front-end version 4.21+ breaks Summary component of RepeatingGroup with pageBreak parameter in PDF
1 participant