Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDFBRA-475 - Ensure that materials ready for loan display the correct "Lån før XX-XX-XXXX" date #1729

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

kasperbirch1
Copy link
Contributor

@kasperbirch1 kasperbirch1 commented Mar 4, 2025

Link to issue

https://reload.atlassian.net/browse/DDFBRA-475

Description

This pull request ensures that E-materials that have been "reserved" and are now "ready for loan" display the correct label.

Please see the commit description for details on the problem and its solution.

Skærmbillede 2025-03-04 kl  15 35 48

Test

https://varnish.pr-2139.dpl-cms.dplplat01.dpl.reload.dk/
danskernesdigitalebibliotek/dpl-cms#2139

Note:

This state for the material is rare and difficult to reproduce, so I faked it like this inside:

src/core/utils/useReservations.tsx

  const mappedReservationsPublizon = reservationsPublizon?.reservations
    ? mapPublizonReservationToReservationType([
        ...reservationsPublizon.reservations,
        // fake a publizon ready to loan material
        ...[
          {
            // productId: "lige meget",
            // productTitle: "Kasper tester",
            identifier: "9788740092912",
            status: 2,

            createdDateUtc: new Date(
              new Date().setDate(new Date().getDate() - 5)
            ).toISOString(),

            expectedRedeemDateUtc: new Date().toISOString(),

            expireDateUtc: new Date(
              new Date().setDate(new Date().getDate() + 2)
            ).toISOString()
          }
        ]
      ])
    : [];

…XX-XXXX" date.

I am not a big fan of the `fetchDigitalMaterial` and `fetchMaterial` higher-order components. They are too difficult to read. Maybe these should be rewritten in the future. However, from what I can see, there is never an `identifier` in the props. Therefore, the `isDigital` variable is never set to true. This causes `getInfo` inside `src/apps/reservation-list/reservation-material/reservation-info.tsx` to use `pickupDeadline` instead of `expiryDate`, which is the intended behavior for digital materials.
Copy link
Contributor

@spaceo spaceo left a comment

Choose a reason for hiding this comment

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

I think we have tests for this. If there are no test for this case I think we should make one.

Adds a test to ensure that e-book reservations are properly displayed when they are "ready for pickup". Previously, no such test existed. The test was executed on the `develop` branch and failed as expected, confirming that the digital reservation element is not displayed correctly.
@kasperbirch1 kasperbirch1 requested review from spaceo and Copilot March 5, 2025 12:10

Choose a reason for hiding this comment

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

PR Overview

This pull request addresses the issue of ensuring that E-materials ready for loan display the correct "Borrow before" date by updating both the presentation and test verification for digital reservations.

  • Updated tests in the reservation list to verify the correct label for E-book reservations.
  • Refactored the reservation material component to use the external digital product identifier instead of a separate identifier prop.

Reviewed Changes

File Description
src/apps/reservation-list/list/reservation-list.test.ts Added a test verifying that the E-book reservation is labeled correctly.
src/apps/reservation-list/reservation-material/reservation-material.tsx Replaced usage of the "identifier" prop with "material?.externalProductId" to correctly determine digital reservations.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/apps/reservation-list/reservation-material/reservation-material.tsx:28

  • [nitpick] Confirm that the shift from using 'identifier' to 'material.externalProductId' is consistent across the component and its usage. Ensure that corresponding prop types and any dependent logic are updated accordingly.
const isDigital = !!material?.externalProductId;

src/apps/reservation-list/list/reservation-list.test.ts:510

  • [nitpick] Consider adding additional tests for varying date values to confirm that reservation labels dynamically display the correct 'Borrow before' date under different scenarios.
"Borrow before 27-01-2023 20:37"
Copy link
Contributor

@spaceo spaceo left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@spaceo spaceo removed their assignment Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants