Skip to content

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Sep 22, 2025

Description

This adds a default layout for a service-task, that will be displayed if the service task fails:

20251016_12h34m21s_grim

It also makes it possible for easy configuration on backend that triggers PDF generation with ?pdf=1&task=Task_1&task=Task_2 which makes it possible to auto-generate a PDF for multiple previous tasks.

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

Release Notes

  • New Features

    • Service Task feature allowing users to retry failed tasks or return to form using a back action.
    • PDF generation now supports service tasks and multi-task scenarios with improved layout control.
    • Page break support for better print layout when generating multi-page documents.
  • Tests

    • Added comprehensive end-to-end tests for service task workflows.
  • Documentation

    • Updated test application references with new test scenarios.

@olemartinorg
Copy link
Contributor Author

/publish

Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

📝 Walkthrough

Walkthrough

This pull request implements a default layout and PDF generation system for service tasks. It introduces a new ServiceTask component, refactors PDF generation to support single-layout and multi-task modes, reorganizes file structure from processEnd to process, adds task-type-based routing, and includes comprehensive E2E testing and multi-language support.

Changes

Cohort / File(s) Summary
Component Rename: PDFWrapper → PdfWrapper
src/App.tsx, src/features/pdf/PDFWrapper.test.tsx, src/features/pdf/PdfWrapper.tsx, src/layout/Subform/SubformWrapper.tsx
Renamed exported component from PDFWrapper to PdfWrapper, including import paths and JSX usage throughout.
Import Path Fixes (PDFWrapper → PdfWrapper)
src/layout/FileUpload/AttachmentSummaryComponent2.tsx, src/layout/FileUpload/FileUploadTable/AttachmentFileName.tsx, src/layout/FileUpload/FileUploadTable/FileTable.tsx, src/layout/FileUpload/FileUploadTable/FileTableRow.tsx, src/layout/Grid/GridSummary.tsx, src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx, src/layout/Subform/Summary/SubformSummaryTable.tsx, src/layout/Summary2/CommonSummaryComponents/EditButton.tsx
Updated import paths for usePdfModeActive hook from PDFWrapper to PdfWrapper (casing correction).
File Structure Reorganization: processEnd → process
src/features/process/confirm/containers/Confirm.tsx, src/features/process/confirm/containers/Confirm.test.tsx, src/features/process/confirm/containers/ConfirmPage.tsx, src/features/process/confirm/containers/ConfirmPage.test.tsx, src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts, src/features/receipt/ReceiptContainer.tsx
Updated import paths for Confirm and ConfirmPage modules from processEnd to process directory.
Routing & Task Type Extensions
src/core/routing/types.ts, src/types/index.ts
Added PdfForTask = 'task' to SearchParams enum; added Service = 'service' to ProcessTaskType enum.
Task Type Detection
src/features/instance/useProcessQuery.ts
Added early return branch in useGetTaskTypeById to detect ServiceTask elementType and return ProcessTaskType.Service before evaluating altinnTaskType.
PDF Generation Refactoring
src/features/pdf/PdfFromLayout.tsx
Major refactor replacing PDFView2 with PdfFromLayout; added PdfForServiceTask for task-based PDF generation; introduced AutoGeneratePdfFromLayout, AutoGeneratePdfFromTasks, and AllPages helpers; supports single-layout, auto-layout, and multi-task PDF flows.
Dynamic PDF Component Routing
src/features/pdf/PdfWrapper.tsx
Renamed PDFWrapper to PdfWrapper; added task-type-based dynamic rendering via useGetTaskTypeById and useNavigationParam to route between PdfForServiceTask and PdfFromLayout.
Service Task UI Component
src/features/process/service/ServiceTask.tsx, src/features/process/service/ServiceTask.module.css
New ServiceTask component with localized title, body, help text, retry button (with write authorization), and back button (with reject authorization); added .buttons CSS class for horizontal button layout.
Presentation Wrapper Update
src/components/presentation/Presentation.tsx
Wrapped DummyPresentation children with RenderStart element inside PresentationProvider.
ProcessWrapper Service Task Handling
src/components/wrappers/ProcessWrapper.tsx
Added conditional rendering for ProcessTaskType.Service before Data task handling; imports ServiceTask, PdfWrapper, and updated Confirm/Feedback import paths.
PDF Styling
src/features/pdf/PDFView.module.css
Added pageBreak CSS class with invisible default state (height: 0; width: 0) and page-break-before: always within @media print.
Type Definitions Refactoring
src/types/shared.ts
Introduced IProcessTask interface with altinnTaskType, elementId, and optional elementType; refactored IProcess.processTasks to use IProcessTask[]; converted ITask from type alias to interface extending IProcessTask.
Multilingual Support
src/language/texts/en.ts, src/language/texts/nb.ts, src/language/texts/nn.ts
Added service\_task translation keys (title, body, help\_text, retry\_button, back\_button) in English, Norwegian Bokmål, and Norwegian Nynorsk.
E2E Testing
test/e2e/integration/service-task/service-task.ts
New Cypress test file for service task flow; includes tests for default layout validation, missing layout-set handling, multi-task PDF generation with custom query parameters, and helper utilities for form filling and navigation.
Test Infrastructure Updates
test/e2e/pageobjects/app-frontend.ts, test/README.md
Reorganized AppFrontend.apps mapping to add serviceTask, signeringBrukerstyrt, and subformTest; reordered test app references in README documentation.
Test Support Utilities
test/e2e/support/custom.ts, test/e2e/support/global.ts
Updated PDF hash restoration logic to preserve URL fragments instead of full navigation; narrowed authenticationLevel type in StartAppInstanceOptions from string to constrained union ('0' | '1' | '2').

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

This change involves substantial refactoring across multiple concerns: comprehensive PDF generation logic overhaul (PdfFromLayout.tsx), critical type system changes affecting public API surface (shared.ts refactoring of ITask/IProcess), dynamic component routing (PdfWrapper.tsx), new feature implementation (ServiceTask), file reorganization, and extensive test coverage. While many homogeneous import path fixes are present, the heterogeneous nature of logic changes, type definitions, and feature complexity demands separate reasoning for multiple areas. The interconnected nature of routing, task detection, PDF generation, and UI rendering increases interdependency concerns.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Default layout and PDF support in service tasks" clearly and concisely summarizes the two main objectives of this PR: implementing a default layout for service tasks and enabling PDF generation for multiple tasks. The title directly corresponds to the primary changes evident in the raw summary, including the new ServiceTask component, PdfFromLayout refactoring, and support for automatic PDF generation via query parameters. The phrasing is specific and meaningful without being overly verbose or vague.
Linked Issues Check ✅ Passed The code changes comprehensively address the objectives from all three linked issues. Issue #3649 is satisfied by the new ServiceTask component providing a default layout and the refactored PdfFromLayout supporting custom layouts. Issue #3650 is addressed through the new SearchParams.PdfForTask enum member and the AutoGeneratePdfFromTasks function enabling multi-task PDF generation via query parameters. Issue #3722 is fully implemented with the ServiceTask component providing retry and back buttons, the dynamic PDF component selection in PdfWrapper, proper authorization checks, localization support, and the ability to auto-generate PDFs for multiple previous tasks. Supporting infrastructure changes (type system updates for ProcessTaskType.Service and IProcessTask, route parameter handling, and test coverage) enable all these features to function correctly.
Out of Scope Changes Check ✅ Passed The vast majority of changes are directly aligned with the linked issues' objectives. The ServiceTask component, PDF generation infrastructure, type system enhancements, and test additions are clearly in scope. Minor refactoring such as the PDFWrapper to PdfWrapper rename and the reorganization of Confirm/Feedback imports from processEnd to process paths appear to be supporting infrastructure necessary to implement the service task feature coherently. The test infrastructure updates and E2E tests are directly necessary for validating the new functionality. No substantive changes were identified that are unrelated to the service task feature or the three linked issues.
Description Check ✅ Passed The PR description is well-structured and adheres to the template requirements. It includes a clear description section with visual context (screenshot), properly lists all three related issues (#3649, #3650, #3722), and comprehensively fills out the Verification/QA section with appropriate checkboxes marked (manual testing performed, unit tests added, accessibility review marked as not necessary for DOM changes, documentation marked as not needed, sprint board items addressed, and labels applied). All required sections of the template are present and sufficiently detailed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/service-task2

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
Contributor

github-actions bot commented Sep 22, 2025

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2401.service-task2.5af29f0d/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2401.service-task2.5af29f0d/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@olemartinorg olemartinorg added kind/product-feature Pull requests containing new features backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Sep 22, 2025
@olemartinorg olemartinorg changed the base branch from main to refactor/task-store September 22, 2025 14:15
Base automatically changed from refactor/task-store to main September 23, 2025 11:40
@olemartinorg
Copy link
Contributor Author

/publish

Copy link
Contributor

github-actions bot commented Sep 23, 2025

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2438.service-task2.54837bab/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2438.service-task2.54837bab/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@olemartinorg
Copy link
Contributor Author

/publish

Copy link
Contributor

github-actions bot commented Oct 8, 2025

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2666.service-task2.af49a2fc/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.22.0-pr.2666.service-task2.af49a2fc/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@olemartinorg olemartinorg changed the base branch from main to bug/pdf-flaky October 10, 2025 12:31
Base automatically changed from bug/pdf-flaky to main October 13, 2025 15:10
@olemartinorg
Copy link
Contributor Author

/publish

Copy link
Contributor

github-actions bot commented Oct 15, 2025

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.23.0-pr.2775.service-task2.38f3d778/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.23.0-pr.2775.service-task2.38f3d778/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
29.9% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

@olemartinorg olemartinorg changed the title WIP: Default layout and PDF support in service tasks Default layout and PDF support in service tasks Oct 16, 2025
@olemartinorg olemartinorg moved this to 🔎 In review in Team Altinn Studio Oct 16, 2025
@olemartinorg olemartinorg marked this pull request as ready for review October 16, 2025 11:15
Copy link
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

🧹 Nitpick comments (10)
src/features/pdf/PDFView.module.css (2)

32-35: Hide screen placeholder; rely on print-only visibility

Zero-sized block works, but it’s cleaner to hide this element on screen and only show it in print. Either combine with .onlyInPrint in markup or add a screen rule.

Apply within this range:

 .pageBreak {
-  height: 0;
-  width: 0;
 }

And outside this range, add to the screen media block:

@media screen {
  .pageBreak { display: none; }
}

Alternatively, use both classes in JSX: className={cn(styles.onlyInPrint, styles.pageBreak)}. As per coding guidelines.


42-44: Add modern break-before with legacy fallback; verify placement to avoid blank first page

Include break-before: page alongside page-break-before for spec-compliant behavior across engines. Ensure this element is not the very first printable child to avoid an initial blank page.

Apply within this range:

 .pageBreak {
+  break-before: page;       /* modern */
   page-break-before: always; /* legacy */
 }

Please verify usages that .pageBreak isn’t inserted as the first node under the printable container.

src/features/receipt/ReceiptContainer.tsx (3)

68-71: Defensive: avoid out-of-bounds when deriving ref number from GUID.

Accessing index 4 assumes a UUID with five hyphen-separated parts. Use the last segment with a fallback.

Apply:

-  obj[langTools.langAsString('receipt.ref_num')] = {
-    value: instanceGuid.split('-')[4],
+  obj[langTools.langAsString('receipt.ref_num')] = {
+    value: (() => {
+      const parts = instanceGuid.split('-');
+      return parts[parts.length - 1] || instanceGuid;
+    })(),

…and keep the rest unchanged.


130-143: Minor: guard memo on instanceOwnerParty to avoid calling helper with undefined.

You later require instanceOwnerParty before rendering, so also include it in the precondition here.

Apply:

-  const instanceMetaObject = useMemo(() => {
-    if (instanceOrg && instanceOwner && instanceGuid && lastChangedDateTime) {
+  const instanceMetaObject = useMemo(() => {
+    if (instanceOrg && instanceOwner && instanceOwnerParty && instanceGuid && lastChangedDateTime) {
       const sender = getInstanceSender(instanceOwnerParty ?? undefined);
       return getSummaryDataObject({
         langTools,
         sender,
         instanceGuid,
         lastChangedDateTime,
         receiver,
       });
     }

Dependencies already include instanceOwnerParty.


161-169: Improve loader reason to avoid '-undefined' and aid observability.

When requirementMissing is undefined but pdfDisplayAttachments is missing, reason becomes receipt-missing-undefined. Make the reason explicit.

Apply:

-  const requirementMissing = getMissingRequirement();
+  const requirementMissing = getMissingRequirement();
+  const missingReason = requirementMissing ?? (!pdfDisplayAttachments ? 'pdfDisplayAttachments' : 'unknown');
...
-      <AltinnContentLoader
+      <AltinnContentLoader
         width={705}
         height={561}
-        reason={`receipt-missing-${requirementMissing}`}
+        reason={`receipt-missing-${missingReason}`}
       >

Also applies to: 163-173

src/features/pdf/PdfWrapper.tsx (1)

51-54: Guard devtools PDF preview when tasks param is missing

If previewPDF is enabled on a Service task without ?tasks=..., <PdfForServiceTask /> throws. Consider a fallback (e.g., render <PdfFromLayout /> or a clear error) to avoid unhandled errors in devtools preview.

src/features/pdf/PdfFromLayout.tsx (4)

53-58: Throwing in render path: consider graceful handling

Throwing inside render will rely on an ErrorBoundary. Consider logging and ignoring the param in auto‑mode to avoid white‑screening:

  • Log once and proceed with auto‑layout PDF.
  • Or render a small message block in the PDF.

99-127: Multi‑task generation: de‑dup and validate taskIds; skip unknown tasks

If the query includes duplicates or taskIds not present in any layout set, users may see repeated or empty sections. De‑dup is handled if you adopt getTaskIdsFromParams, but unknown taskIds should be skipped with a log.

Apply this diff:

 function AutoGeneratePdfFromTasks({ taskIds }: { taskIds: string[] }) {
+  // Optional: Skip unknown taskIds to avoid empty/incorrect sections
+  // If you prefer, move this into TaskSummaryWrapper or a small hook that checks layoutSets.
+  // window.logInfoOnce is assumed; use your logging util.
+  // const layoutSets = useLayoutSets();
+  // const validTaskIds = taskIds.filter((id) => layoutSets.some((set) => set.tasks?.includes(id)));
+  // const toRender = validTaskIds.length ? validTaskIds : taskIds;
   return (
     <DummyPresentation>
       <PdfWrapping>
         <div className={classes.instanceInfo}>
           <InstanceInformation
             elements={{
               dateSent: true,
               sender: true,
               receiver: true,
               referenceNumber: true,
             }}
           />
         </div>
-        {taskIds.map((taskId, idx) => (
+        {taskIds.map((taskId, idx) => (
           <TaskSummaryWrapper
             key={taskId}
             taskId={taskId}
           >
             {idx > 0 && <div className={classes.pageBreak} />}
             {/* Settings intentionally omitted, as this is new functionality
             and PDF settings are deprecated at this point. */}
             <AllPages pdfSettings={undefined} />
             <AllSubformSummaryComponent2 />
           </TaskSummaryWrapper>
         ))}
       </PdfWrapping>
     </DummyPresentation>
   );
 }

If you want me to wire the validation using useLayoutSets(), I can provide the exact code.


193-209: Guard against malformed pdfSettings.excludedPages

If the backend returns a partial shape, calling includes on undefined will crash. Default to an empty array.

Apply this diff:

 function AllPages({ pdfSettings }: { pdfSettings: IPdfFormat | undefined }) {
-  const order = usePageOrder();
+  const order = usePageOrder();
+  const excludedPages = pdfSettings?.excludedPages ?? [];
 
   return (
     <>
-      {order
-        .filter((pageKey) => !pdfSettings?.excludedPages.includes(pageKey))
+      {order
+        .filter((pageKey) => !excludedPages.includes(pageKey))
         .map((pageKey) => (
           <PdfForPage
             key={pageKey}
             pageKey={pageKey}
             pdfSettings={pdfSettings}
           />
         ))}
     </>
   );
 }

211-224: Guard against malformed pdfSettings.excludedComponents and stabilize deps

Same robustness concern here; also simplifies the memo deps.

Apply this diff:

 function PdfForPage({ pageKey, pdfSettings }: { pageKey: string; pdfSettings: IPdfFormat | undefined }) {
   const lookups = useLayoutLookups();
-  const children = useMemo(() => {
+  const excludedComponents = pdfSettings?.excludedComponents ?? [];
+  const children = useMemo(() => {
     const topLevel = lookups.topLevelComponents[pageKey] ?? [];
     return topLevel.filter((baseId) => {
       const component = lookups.getComponent(baseId);
       const def = getComponentDef(component.type);
       return (
         component.type !== 'Subform' &&
-        !pdfSettings?.excludedComponents.includes(baseId) &&
+        !excludedComponents.includes(baseId) &&
         def.shouldRenderInAutomaticPDF(component as never)
       );
     });
-  }, [lookups, pageKey, pdfSettings?.excludedComponents]);
+  }, [lookups, pageKey, excludedComponents]);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5af590e and 49a843c.

📒 Files selected for processing (36)
  • src/App.tsx (2 hunks)
  • src/components/presentation/Presentation.tsx (1 hunks)
  • src/components/wrappers/ProcessWrapper.tsx (2 hunks)
  • src/core/routing/types.ts (1 hunks)
  • src/features/instance/useProcessQuery.ts (1 hunks)
  • src/features/pdf/PDFView.module.css (1 hunks)
  • src/features/pdf/PDFWrapper.test.tsx (2 hunks)
  • src/features/pdf/PdfFromLayout.tsx (5 hunks)
  • src/features/pdf/PdfWrapper.tsx (3 hunks)
  • src/features/process/confirm/containers/Confirm.test.tsx (1 hunks)
  • src/features/process/confirm/containers/Confirm.tsx (1 hunks)
  • src/features/process/confirm/containers/ConfirmPage.test.tsx (1 hunks)
  • src/features/process/confirm/containers/ConfirmPage.tsx (1 hunks)
  • src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts (1 hunks)
  • src/features/process/service/ServiceTask.module.css (1 hunks)
  • src/features/process/service/ServiceTask.tsx (1 hunks)
  • src/features/receipt/ReceiptContainer.tsx (1 hunks)
  • src/language/texts/en.ts (1 hunks)
  • src/language/texts/nb.ts (1 hunks)
  • src/language/texts/nn.ts (1 hunks)
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx (1 hunks)
  • src/layout/FileUpload/FileUploadTable/AttachmentFileName.tsx (1 hunks)
  • src/layout/FileUpload/FileUploadTable/FileTable.tsx (1 hunks)
  • src/layout/FileUpload/FileUploadTable/FileTableRow.tsx (1 hunks)
  • src/layout/Grid/GridSummary.tsx (1 hunks)
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx (1 hunks)
  • src/layout/Subform/SubformWrapper.tsx (2 hunks)
  • src/layout/Subform/Summary/SubformSummaryTable.tsx (1 hunks)
  • src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (1 hunks)
  • src/types/index.ts (1 hunks)
  • src/types/shared.ts (2 hunks)
  • test/README.md (1 hunks)
  • test/e2e/integration/service-task/service-task.ts (1 hunks)
  • test/e2e/pageobjects/app-frontend.ts (1 hunks)
  • test/e2e/support/custom.ts (2 hunks)
  • test/e2e/support/global.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/core/routing/types.ts
  • src/types/index.ts
  • src/language/texts/nb.ts
  • src/layout/FileUpload/FileUploadTable/AttachmentFileName.tsx
  • src/features/instance/useProcessQuery.ts
  • src/language/texts/en.ts
  • src/layout/Subform/Summary/SubformSummaryTable.tsx
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx
  • src/components/presentation/Presentation.tsx
  • test/e2e/support/global.ts
  • src/layout/Summary2/CommonSummaryComponents/EditButton.tsx
  • src/language/texts/nn.ts
  • src/features/process/confirm/containers/ConfirmPage.test.tsx
  • test/e2e/integration/service-task/service-task.ts
  • src/features/receipt/ReceiptContainer.tsx
  • test/e2e/support/custom.ts
  • src/features/process/service/ServiceTask.tsx
  • src/components/wrappers/ProcessWrapper.tsx
  • src/layout/FileUpload/FileUploadTable/FileTableRow.tsx
  • src/features/pdf/PDFWrapper.test.tsx
  • src/layout/FileUpload/FileUploadTable/FileTable.tsx
  • src/types/shared.ts
  • src/features/process/confirm/containers/Confirm.tsx
  • test/e2e/pageobjects/app-frontend.ts
  • src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts
  • src/features/pdf/PdfWrapper.tsx
  • src/layout/Subform/SubformWrapper.tsx
  • src/features/pdf/PdfFromLayout.tsx
  • src/features/process/confirm/containers/Confirm.test.tsx
  • src/features/process/confirm/containers/ConfirmPage.tsx
  • src/App.tsx
  • src/layout/Grid/GridSummary.tsx
**/*.module.css

📄 CodeRabbit inference engine (CLAUDE.md)

Use CSS Modules for component styling and follow existing patterns in *.module.css files

Files:

  • src/features/pdf/PDFView.module.css
  • src/features/process/service/ServiceTask.module.css
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

In tests, use renderWithProviders from src/test/renderWithProviders.tsx to supply required form layout context

Files:

  • src/features/process/confirm/containers/ConfirmPage.test.tsx
  • src/features/pdf/PDFWrapper.test.tsx
  • src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts
  • src/features/process/confirm/containers/Confirm.test.tsx
🧬 Code graph analysis (9)
src/components/presentation/Presentation.tsx (1)
src/core/ui/RenderStart.tsx (1)
  • RenderStart (22-31)
test/e2e/integration/service-task/service-task.ts (1)
test/e2e/pageobjects/app-frontend.ts (1)
  • AppFrontend (3-376)
src/features/process/service/ServiceTask.tsx (6)
src/features/language/useLanguage.ts (1)
  • useLanguage (90-93)
src/utils/getPageTitle.ts (1)
  • getPageTitle (1-10)
src/features/language/Lang.tsx (1)
  • Lang (15-23)
src/components/ReadyForPrint.tsx (1)
  • ReadyForPrint (21-52)
src/features/instance/useProcessQuery.ts (1)
  • useIsAuthorized (28-35)
src/features/instance/useProcessNext.tsx (1)
  • useProcessNext (38-136)
src/components/wrappers/ProcessWrapper.tsx (3)
src/features/pdf/PdfWrapper.tsx (1)
  • PdfWrapper (20-58)
src/components/presentation/Presentation.tsx (1)
  • PresentationComponent (32-93)
src/features/process/service/ServiceTask.tsx (1)
  • ServiceTask (15-55)
src/features/pdf/PDFWrapper.test.tsx (1)
src/features/pdf/PdfWrapper.tsx (1)
  • PdfWrapper (20-58)
src/features/pdf/PdfWrapper.tsx (5)
src/features/devtools/data/DevToolsStore.ts (1)
  • useDevToolsStore (57-57)
src/hooks/useIsPdf.ts (1)
  • useIsPdf (7-9)
src/hooks/navigation.ts (1)
  • useNavigationParam (51-55)
src/features/instance/useProcessQuery.ts (1)
  • useGetTaskTypeById (61-93)
src/features/pdf/PdfFromLayout.tsx (2)
  • PdfForServiceTask (87-97)
  • PdfFromLayout (36-47)
src/layout/Subform/SubformWrapper.tsx (3)
src/features/pdf/PdfWrapper.tsx (1)
  • PdfWrapper (20-58)
src/components/presentation/Presentation.tsx (1)
  • PresentationComponent (32-93)
src/components/form/Form.tsx (1)
  • Form (39-43)
src/features/pdf/PdfFromLayout.tsx (8)
src/features/form/layoutSettings/LayoutSettingsContext.tsx (1)
  • usePdfLayoutName (113-113)
src/features/pdf/usePdfFormatQuery.ts (1)
  • usePdfFormatQuery (34-46)
src/components/ReadyForPrint.tsx (1)
  • BlockPrint (105-112)
src/components/presentation/Presentation.tsx (1)
  • DummyPresentation (123-129)
src/layout/Subform/Summary/SubformSummaryComponent2.tsx (1)
  • AllSubformSummaryComponent2 (146-163)
src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx (1)
  • TaskSummaryWrapper (14-28)
src/features/pdf/types.ts (1)
  • IPdfFormat (1-4)
src/hooks/useNavigatePage.ts (1)
  • usePageOrder (65-69)
src/App.tsx (1)
src/features/pdf/PdfWrapper.tsx (1)
  • PdfWrapper (20-58)
🪛 LanguageTool
test/README.md

[grammar] ~41-~41: There might be a mistake here.
Context: ...y.git) - ttd/expression-validation-test - [ttd/frontend-test](https://dev.altinn.st...

(QB_NEW_EN)


[grammar] ~42-~42: There might be a mistake here.
Context: ...on-validation-test) - ttd/frontend-test - [ttd/multiple-datamodels-test](https://de...

(QB_NEW_EN)


[grammar] ~43-~43: There might be a mistake here.
Context: ...nd-test) - ttd/multiple-datamodels-test - [ttd/navigation-test-subform](https://dev...

(QB_NEW_EN)


[grammar] ~44-~44: There might be a mistake here.
Context: ...els-test) - ttd/navigation-test-subform - [ttd/payment-test](https://dev.altinn.stu...

(QB_NEW_EN)


[grammar] ~45-~45: There might be a mistake here.
Context: ...gation-test-subform) - ttd/payment-test - [ttd/service-task](https://altinn.studio/...

(QB_NEW_EN)


[grammar] ~46-~46: There might be a mistake here.
Context: ...os/ttd/payment-test) - ttd/service-task - [ttd/signering-brukerstyrt](https://altin...

(QB_NEW_EN)


[grammar] ~47-~47: There might be a mistake here.
Context: ...rvice-task) - ttd/signering-brukerstyrt - [ttd/signing-test](https://dev.altinn.stu...

(QB_NEW_EN)


[grammar] ~48-~48: There might be a mistake here.
Context: ...gnering-brukerstyrt) - ttd/signing-test - [ttd/stateless-app](https://dev.altinn.st...

(QB_NEW_EN)


[grammar] ~49-~49: There might be a mistake here.
Context: ...s/ttd/signing-test) - ttd/stateless-app - [ttd/subform-test](https://dev.altinn.stu...

(QB_NEW_EN)

🔇 Additional comments (41)
test/e2e/support/global.ts (1)

23-23: Approve constrained string union for authenticationLevel
All existing usages pass valid literals ('0' | '1' | '2'); no further changes required.

src/features/receipt/ReceiptContainer.tsx (1)

18-18: Import path update verified and safe.

All checks passed:

  • ✅ No remaining imports from old processEnd/confirm/... path
  • ✅ New import path src/features/process/confirm/helpers/returnConfirmSummaryObject exists and is used consistently across the codebase (ReceiptContainer, ConfirmPage, tests)
  • getInstanceSender signature unchanged: export function getInstanceSender(instanceOwnerParty?: IParty): string

The refactoring is complete and introduces no broken references.

src/components/presentation/Presentation.tsx (1)

124-128: LGTM!

The addition of RenderStart wrapper in DummyPresentation ensures consistent initialization of language data sources, navigation effects, and dev tools across both the main presentation flow and the dummy/loader path.

src/language/texts/nb.ts (1)

509-514: LGTM!

The new service task translation keys provide complete Norwegian Bokmål text for the service task error UI, including title, body text with placeholders, help text, and button labels.

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

656-656: Capture hash for restoration.

Good addition to capture the hash before PDF generation, enabling restoration of the exact navigation state after PDF rendering completes.


737-741: Efficient hash-based restoration instead of full page visit.

The change from visiting a modified URL to directly setting window.location.hash is more efficient and avoids unnecessary page reloads. This hash-based restoration preserves the navigation state while staying within the React app context.

test/README.md (1)

41-50: LGTM!

The documentation update adds new test app repositories (service-task, subformTest, signeringBrukerstyrt) and reorganizes the list for better clarity. The static analysis warnings about grammar are false positives for Markdown link syntax.

src/language/texts/nn.ts (1)

506-511: LGTM!

Norwegian Nynorsk translations added for service task UI, maintaining consistency with the Norwegian Bokmål (nb.ts) and English (en.ts) translation files.

test/e2e/pageobjects/app-frontend.ts (1)

8-39: LGTM!

The apps mapping now includes the new serviceTask entry and reorganizes existing entries with updated repository links. This enables E2E testing of the new service task functionality.

test/e2e/integration/service-task/service-task.ts (3)

11-36: Comprehensive test coverage for service task with custom layout.

The test properly validates:

  • Custom error layout rendering
  • Notification handling
  • PDF generation with custom layout
  • Retry flow to success

The use of { retries: 0 } is appropriate for PDF tests to catch bugs rather than hide flaky behavior.


38-81: Thorough validation of default service task layout.

This test effectively covers the fallback scenario when no custom layout-set exists:

  • Layout-set interception to simulate missing layout
  • Default error UI rendering
  • Multi-task PDF generation with query parameters
  • Page break verification

The PDF URL construction using SearchParams is clean and maintainable.


84-143: Well-structured helper functions.

The three helper functions provide good separation of concerns:

  • startAppAndFillToFailure: Handles form filling and navigation to failure state
  • assertAndDismissNotification: Validates notification display and dismissal
  • goBackAndAchieveSuccess: Covers the retry-to-success path

This structure promotes test readability and maintainability.

src/types/index.ts (1)

27-27: LGTM!

The addition of ProcessTaskType.Service enables the new service task functionality. This enum value is properly integrated with the existing process task type system and is used throughout the PR for routing and component rendering decisions.

src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx (1)

12-12: LGTM! Import path updated to match renamed module.

The import path correction from PDFWrapper to PdfWrapper aligns with the project-wide renaming effort. No behavior changes.

src/layout/Subform/SubformWrapper.tsx (1)

10-10: LGTM! Component rename applied consistently.

The import and JSX usage correctly reflect the PDFWrapperPdfWrapper rename. Behavior remains unchanged.

Also applies to: 25-29

src/layout/Subform/Summary/SubformSummaryTable.tsx (1)

14-14: LGTM! Import path updated to match renamed module.

The import path correction aligns with the PdfWrapper rename across the codebase.

src/layout/FileUpload/FileUploadTable/AttachmentFileName.tsx (1)

9-9: LGTM! Import path updated to match renamed module.

The import path correction aligns with the project-wide PdfWrapper rename.

src/core/routing/types.ts (1)

7-7: LGTM! New search parameter supports task-based PDF generation.

The PdfForTask = 'task' enum member enables the backend-configurable PDF generation feature for multiple tasks via query parameters (e.g., ?pdf=1&task=Task_1&task=Task_2), as described in the PR objectives.

src/features/process/confirm/containers/Confirm.tsx (1)

9-9: LGTM! Import path updated for module reorganization.

The import path change from processEnd/confirm to process/confirm reflects a module consolidation. The imported entity remains the same.

src/features/process/confirm/containers/ConfirmPage.test.tsx (1)

11-11: LGTM! Test import aligned with module reorganization.

The test import correctly references the new process/confirm module path, maintaining consistency with the production code.

src/layout/Grid/GridSummary.tsx (1)

12-12: LGTM! Import path updated to match renamed module.

The import path correction aligns with the PdfWrapper rename across the codebase.

src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (1)

10-10: LGTM! Import path casing standardized.

The import path has been correctly updated from PDFWrapper to PdfWrapper, aligning with the project-wide naming standardization for PDF-related components.

src/layout/FileUpload/FileUploadTable/FileTable.tsx (1)

5-5: LGTM! Import path casing standardized.

The import path has been correctly updated from PDFWrapper to PdfWrapper, consistent with the project-wide refactoring.

src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts (1)

2-2: LGTM! Module path reorganization.

The import path has been correctly updated from processEnd/confirm to process/confirm, aligning with the broader module reorganization for process-related features.

src/features/process/confirm/containers/Confirm.test.tsx (1)

7-7: LGTM! Module path reorganization.

The import path has been correctly updated from processEnd/confirm to process/confirm, consistent with the broader module reorganization.

src/features/process/confirm/containers/ConfirmPage.tsx (1)

11-11: LGTM! Module path reorganization.

The import path has been correctly updated from processEnd/confirm to process/confirm, aligning with the module reorganization for process-related features.

src/features/process/service/ServiceTask.module.css (1)

1-5: LGTM! CSS follows project conventions.

The .buttons class provides clean flexbox layout for the ServiceTask action buttons, using:

  • CSS custom property var(--button-margin-top) for consistent spacing
  • Modern gap property for button spacing
  • CSS Modules for scoped styling

This aligns with the coding guidelines for component styling.

src/layout/FileUpload/FileUploadTable/FileTableRow.tsx (1)

11-11: LGTM! Import path casing standardized.

The import path has been correctly updated from PDFWrapper to PdfWrapper, consistent with the project-wide naming standardization.

src/layout/FileUpload/AttachmentSummaryComponent2.tsx (1)

8-8: LGTM! Import path casing standardized.

The import path has been correctly updated from PDFWrapper to PdfWrapper, completing the consistent naming across FileUpload components.

src/features/instance/useProcessQuery.ts (1)

82-84: ServiceTask precedence looks correct; confirm backend elementType coverage

Returning Service on elementType before altinnTaskType matches the "custom layout-set overrides default" intent. Please verify that elementType='ServiceTask' is reliably present across supported backend versions; otherwise fallback may misclassify.

src/features/pdf/PDFWrapper.test.tsx (1)

14-15: API rename to PdfWrapper is consistent

Import and JSX updated; test intent unchanged. LGTM.

Also applies to: 55-60

src/language/texts/en.ts (1)

508-514: New service_task translations added correctly

Keys and placeholders match component usage. LGTM.

src/components/wrappers/ProcessWrapper.tsx (2)

20-24: Imports updated for ServiceTask and PdfWrapper

Import adjustments align with new flow. LGTM.


148-156: Correct render path for Service tasks

Wrapping ServiceTask in PdfWrapper inside PresentationComponent matches the PDF/preview and UI patterns. LGTM.

src/App.tsx (1)

12-13: PdfWrapper rename and usage are consistent

Import and wrapper around Presentation+Form look good. LGTM.

Also applies to: 86-91

src/features/pdf/PdfWrapper.tsx (1)

25-27: Dynamic PDF component selection by task type is correct

Selecting PdfForServiceTask for Service tasks and PdfFromLayout otherwise matches the new flow. LGTM.

Also applies to: 41-45

src/types/shared.ts (2)

200-201: processTasks now typed as IProcessTask[]

Good consolidation; enables access to elementType where available. LGTM.


240-247: Introduce IProcessTask with optional elementType

This supports ServiceTask detection and future backend versions. LGTM.

Please confirm that elementType is present in all environments you target; if not, keep altinnTaskType fallback paths exercised in tests.

src/features/pdf/PdfFromLayout.tsx (3)

36-47: PdfFromLayout: clear split between explicit layout vs auto-generation

The control flow and wrapping look good. Explicit pdfLayoutName takes precedence; otherwise falls back to auto-generation.


113-124: Page breaks between tasks: Verification complete

Confirmed:

  • classes.pageBreak exists in the imported CSS module (src/features/pdf/PDFView.module.css)
  • CSS correctly defines page-break-before: always; within @media print block, ensuring hard page breaks in print media
  • Placement logic (break before each task after the first) is correct

The code is correct as written.


49-60: The original review comment is based on an incorrect assumption about the parameter names.

The codebase definitively shows:

  • SearchParams.PdfForTask is a single enum value mapped to 'task' (not multiple variants)
  • The current code correctly uses params.getAll(SearchParams.PdfForTask) to retrieve multiple task values via the standard ?task=...&task=... URL pattern
  • No 'tasks' parameter exists anywhere in the codebase
  • The e2e test confirms tasks are passed as multiple task parameters, not as a separate tasks key

The suggested helper function getTaskIdsFromParams() and its aliases are unnecessary; the current implementation is already correct and follows standard URLSearchParams conventions.

Likely an incorrect or invalid review comment.

@@ -0,0 +1,143 @@
import 'cypress-iframe';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify cypress-iframe import usage.

The cypress-iframe import is present but no iframe-related commands are used in the test. Consider removing this import if it's not needed, or document why it's required for test setup.


🏁 Script executed:

#!/bin/bash
# Check if cypress-iframe commands are used in this test file
rg -n "\.frameLoaded\(|\.iframeLoaded\(|\.enter\(|\.iframe\(" test/e2e/integration/service-task/service-task.ts

Length of output: 0



🏁 Script executed:

#!/bin/bash
# 1. Check if file exists and show the imports section
if [ -f "test/e2e/integration/service-task/service-task.ts" ]; then
  echo "=== File exists. First 30 lines (imports section): ==="
  head -30 test/e2e/integration/service-task/service-task.ts
  echo ""
  echo "=== Searching for any iframe-related patterns (case-insensitive, broader search): ==="
  rg -in "iframe|frameloaded|iframeloaded|enter" test/e2e/integration/service-task/service-task.ts
else
  echo "File not found at test/e2e/integration/service-task/service-task.ts"
fi

Length of output: 1393



🏁 Script executed:

#!/bin/bash
# Check if AppFrontend or its dependencies use cypress-iframe
echo "=== Checking AppFrontend file for cypress-iframe usage: ==="
rg -in "cypress-iframe|frameloaded|iframeloaded" test/e2e/pageobjects/app-frontend.ts test/e2e/pageobjects/app-frontend.tsx 2>/dev/null || echo "AppFrontend file not found or no matches"

echo ""
echo "=== Searching all files in test/e2e/pageobjects for cypress-iframe: ==="
rg -in "cypress-iframe" test/e2e/pageobjects/ 2>/dev/null | head -20 || echo "No cypress-iframe usage in pageobjects"

echo ""
echo "=== Full line count of service-task.ts to understand file size: ==="
wc -l test/e2e/integration/service-task/service-task.ts

Length of output: 296


Remove unused cypress-iframe import.

The import on line 1 is not used anywhere in this test file, in the AppFrontend page object, or in any pageobjects. Remove the import to keep dependencies clean.

🤖 Prompt for AI Agents
In test/e2e/integration/service-task/service-task.ts around line 1, there is an
unused import "import 'cypress-iframe';" which is not referenced anywhere in
this file or related page objects; remove that import statement on line 1, save
the file, run the e2e tests to confirm nothing breaks, and if no other files use
cypress-iframe consider removing the package from package.json/devDependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/product-feature Pull requests containing new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service task: Default layout + custom layout support Mulighet for auto PDF for et sett med tasks i bpmn config Default layout-set for service task

1 participant