Skip to content

[DEV-3834] Refactor case-histories API layer#2181

Open
Sebastiano-Bertolin wants to merge 9 commits intoDEV-3764-refactor-api-layer-for-product-apifrom
DEV-3834-refactor-api-layer-for-case-histories
Open

[DEV-3834] Refactor case-histories API layer#2181
Sebastiano-Bertolin wants to merge 9 commits intoDEV-3764-refactor-api-layer-for-product-apifrom
DEV-3834-refactor-api-layer-for-case-histories

Conversation

@Sebastiano-Bertolin
Copy link
Copy Markdown
Collaborator

This pull request refactors the handling of case histories and SOAP API content URLs, aiming to improve code organization, modularity, and maintainability. The most significant changes are the migration of case histories logic to a new repository pattern, the extraction of SOAP API content URL logic into a dedicated helper, and the consolidation of shared test factories. These updates modernise the codebase and streamline data access patterns.

List of Changes

Case Histories Refactor:

  • Introduced CaseHistoriesRepository in apps/nextjs-website/src/lib/caseHistories/index.ts to encapsulate fetching and mapping logic for case histories, replacing the previous scattered approach.
  • Migrated case histories fetcher and mapper to apps/nextjs-website/src/lib/caseHistories/fetcher.ts and apps/nextjs-website/src/lib/caseHistories/mapper.ts, respectively, and updated their interfaces for clarity and consistency. [1] [2] [3]
  • Added comprehensive tests for the new case histories mapper in apps/nextjs-website/src/lib/caseHistories/__tests__/mapper.tests.ts.
  • Defined new, explicit types for case histories in apps/nextjs-website/src/lib/caseHistories/types.ts.

SOAP API Content URL Handling:

  • Extracted the SOAP API content URL logic into a new helper function getApiSoapContentUrls in apps/nextjs-website/src/lib/apiDataList/helpers.ts, replacing the previous implementation and updating imports accordingly. [1] [2]
  • Updated related tests to use the new helper and shared factories for test data. [1] [2]

Shared Test Factories Consolidation:

  • Consolidated media and test data factories under apps/nextjs-website/src/lib/shared/factories/media and apps/nextjs-website/src/lib/shared/factories/apiDataList, updating imports throughout the codebase for consistency. [1] [2] [3] [4] [5]

API Usage Updates:

  • Refactored all usages of case histories fetching and mapping to use the new repository pattern, including in apps/nextjs-website/src/app/sitemap.ts and apps/nextjs-website/src/lib/api.ts. [1] [2] [3] [4] [5]
  • Removed obsolete functions and imports related to old case histories logic from apps/nextjs-website/src/lib/cmsApi.ts. [1] [2]

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Chore (nothing changes by a user perspective)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

- Updated import paths for apiDataList and apiDataListPages factories in tests to point to the new shared directory.
- Created new test file for caseHistories with appropriate mappings and tests.
- Added fetcher and mapper for caseHistories, including handling of various data scenarios.
- Introduced shared media factory for consistent media object creation across tests.
- Refactored existing tests to utilize the new shared media factory.
…ry for improved structure and maintainability
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: be790b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nextjs-website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Jira Pull Request Link

This Pull Request refers to the following Jira issue DEV-3834

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant