Skip to content

Patch bugs in full-text links logic - #458

Open
jazairi wants to merge 1 commit into
mainfrom
use-663
Open

Patch bugs in full-text links logic#458
jazairi wants to merge 1 commit into
mainfrom
use-663

Conversation

@jazairi

@jazairi jazairi commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Why these changes are being introduced:

There are two uncaught edge cases in the full-text link logic:

  1. Full-text options are removed when libkey links exist.
  2. I a PNX record as an empty links object (rather than omitting it altogether), then full-text
    options will not display.

Relevant ticket(s):

How this addresses that need:

This addresses the edge cases noted above.

Side effects of this change:

This change was prompted by full-text links not
appearing in staging, despite working properly in
local development environments. It's unclear
whether this change is what's required to fix
staging.

Developer

Accessibility
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
Additional context needed to review

"Sea otters" is an example of a search that will return a top result with a "full-text options" link.

Code Reviewer

Code
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

Why these changes are being introduced:

There are two uncaught edge cases in the full-text
link logic:

1. Full-text options are removed when libkey links
exist.
2. I a PNX record as an empty links object (rather
than omitting it altogether), then full-text
options will not display.

Relevant ticket(s):

- [USE-663](https://mitlibraries.atlassian.net/browse/USE-663)

How this addresses that need:

This addresses the edge cases noted above.

Side effects of this change:

This change was prompted by full-text links not
appearing in staging, despite working properly in
local development environments. It's unclear
whether this change is what's required to fix
staging.
@qltysh

qltysh Bot commented Aug 28, 2026

Copy link
Copy Markdown

❌ 4 blocking issues (4 total)

Tool Category Rule Count
rubocop Lint Assignment Branch Condition size for links is too high. [<4, 48, 16> 50.75/17] 1
rubocop Lint Cyclomatic complexity for links is too high. [17/7] 1
rubocop Lint Method has too many lines. [27/10] 1
rubocop Lint Perceived complexity for links is too high. [18/8] 1

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 33194305177

Coverage remained the same at 98.3%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 3 of 3 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1706
Covered Lines: 1677
Line Coverage: 98.3%
Coverage Strength: 81.61 hits per line

💛 - Coveralls

@mitlib
mitlib temporarily deployed to timdex-ui-pi-use-663-sd3pwpsnc August 28, 2026 17:24 Inactive
@jazairi
jazairi marked this pull request as draft August 28, 2026 17:25
@jazairi
jazairi marked this pull request as ready for review August 31, 2026 20:39
@jazairi

jazairi commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I'm not totally sure this addresses the problem in stage that's preventing these links from showing, but at the very least it's an improvement to the logic.

The feature does seem to work properly in this PR build, but that was the case with the initial implementation.

@jazairi
jazairi requested review from JPrevost and matt-bernhardt and a lite review from Copilot August 31, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The PR checklist/description states there are no view-layer changes, but the ERB partial was modified and the checklist should be corrected to avoid misleading review and a11y process steps.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts Primo full-text link handling so “Full-text options” is only added when no direct PDF/HTML links exist, and ensures it isn’t removed when LibKey results load (fixing edge cases seen with empty pnx.links objects and LibKey link injection).

Changes:

  • Update NormalizePrimoRecord#links to add “Full-text options” when Alma-E is present and no direct Primo PDF/HTML links exist (including when pnx.links is {}).
  • Preserve the “Full-text options” link in the Primo result UI even when LibKey links are present (hide/remove other Primo links only).
  • Add/adjust tests to cover the new normalization behavior.
File summaries
File Description
app/models/normalize_primo_record.rb Refines “Full-text options” link inclusion logic based on presence of direct PDF/HTML links.
app/views/search/_result_primo.html.erb Adds a preservable CSS class to keep “Full-text options” visible when LibKey results exist.
app/javascript/controllers/content_loader_controller.js Updates link-removal selector to exclude preservable Primo links.
test/models/normalize_primo_record_test.rb Updates/adds tests for the new full-text options edge cases.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/views/search/_result_primo.html.erb
@JPrevost JPrevost self-assigned this Sep 1, 2026
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.

5 participants