add hideAppNameInPdf functionality to footer in the pdf#1753
add hideAppNameInPdf functionality to footer in the pdf#1753walldenfilippa wants to merge 8 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPdfService now supports customizable PDF footer content with optional app name hiding. The service accepts new ChangesPDF Footer Customization with App Name Hiding
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ 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: 1
🧹 Nitpick comments (1)
test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs (1)
37-37: ⚡ Quick winAdd focused tests for the new footer branches.
The fixture now wires
ILayoutEvaluatorStateInitializer, but there are still no assertions arounduiSettings.hideAppNameInPdfas a literal boolean, as an expression, or when the config is malformed. Those are the new branches most likely to regress here.Also applies to: 538-539
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Altinn.App.Core/Internal/Pdf/PdfService.cs`:
- Around line 409-447: Wrap the whole hideAppNameInPdf evaluation in a try/catch
that returns false on any exception so PDF generation fails closed; when parsing
layoutSetsString call JsonDocument.Parse with an explicit JsonDocumentOptions
(set AllowTrailingCommas = true and CommentHandling = JsonCommentHandling.Skip)
instead of relying on _jsonSerializerOptions; after obtaining hideAppNameElement
ensure ValueKind is True/False or safely call
hideAppNameElement.Deserialize<Expression>(_jsonSerializerOptions) and if that
returns null return false; guard against null instance.Data before using
instance.Data.Find; and catch exceptions from
_instanceDataUnitOfWorkInitializer.Init, _layoutStateInit.Init and
ExpressionEvaluator.EvaluateExpression and return false on error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ddfdd5b6-cadf-40d7-9e23-9d1f72286dec
📒 Files selected for processing (4)
src/Altinn.App.Core/Internal/Pdf/PdfService.cstest/Altinn.App.Api.Tests/Controllers/PdfControllerTests.cstest/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cstest/Altinn.App.Core.Tests/PublicApiTests.PublicApi_ShouldNotChange_Unintentionally.verified.txt
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs (1)
37-37: ⚡ Quick winConsider adding setup for the layout state initializer mock or verifying it's not needed.
The
_layoutStateInitmock is instantiated but never configured with any behavior. While Moq allows this, it's worth confirming whether:
- The mock should be set up to support expression-based
hideAppNameInPdftests (see comment on lines 480-629), or- The current test scenarios don't require the initializer to be invoked
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs` at line 37, The _layoutStateInit mock (Mock<ILayoutEvaluatorStateInitializer>) is created but never configured; either add explicit setups for the calls used in PdfServiceTests — e.g., configure _layoutStateInit.Setup(s => s.InitializeState(It.IsAny<...>())).Returns(...) or Setup for any expression-based behavior used by the hideAppNameInPdf-related tests — or add assertions that the initializer is never invoked; update tests referencing hideAppNameInPdf to call the initializer mock or remove the unused field if it is truly unnecessary so the test intent is explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs`:
- Around line 480-629: Add a unit test that covers expression-based
hideAppNameInPdf by supplying layoutSets JSON with an expression (e.g.
{"sets":[],"uiSettings":{"hideAppNameInPdf":["equals",["dataModel","someField"],"someValue"]}})
when constructing the PdfService via SetupPdfService, and mock the
ILayoutEvaluatorStateInitializer / its evaluator to evaluate that expression to
true and false respectively so you can Verify GeneratePdf called with footer
that omits the app name when the expression evaluates true and includes it when
false; target the GenerateAndStorePdf method and reuse the existing Instance
setup and _pdfGeneratorClient.Verify pattern to assert behavior.
---
Nitpick comments:
In `@test/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs`:
- Line 37: The _layoutStateInit mock (Mock<ILayoutEvaluatorStateInitializer>) is
created but never configured; either add explicit setups for the calls used in
PdfServiceTests — e.g., configure _layoutStateInit.Setup(s =>
s.InitializeState(It.IsAny<...>())).Returns(...) or Setup for any
expression-based behavior used by the hideAppNameInPdf-related tests — or add
assertions that the initializer is never invoked; update tests referencing
hideAppNameInPdf to call the initializer mock or remove the unused field if it
is truly unnecessary so the test intent is explicit.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c681f9d8-14df-4a3f-ab85-bfe2243b5910
📒 Files selected for processing (2)
src/Altinn.App.Core/Internal/Pdf/PdfService.cstest/Altinn.App.Core.Tests/Internal/Pdf/PdfServiceTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Altinn.App.Core/Internal/Pdf/PdfService.cs
|


Description
The hideAppNameInPdf property determines whether the app name is displayed in the PDF footer.
Frontend implementation: Altinn/app-frontend-react#4173
Needs to be checked for consistency and alignment with next.
Related Issue(s)
Verification
Documentation
Summary by CodeRabbit
New Features
Public API
Tests