Skip to content

DT-3206 - Replace fuzzy study description matches with tags - #3927

Merged
ncalvanese1 merged 7 commits into
developfrom
nc-dt-3206-data-library-cleanup
Sep 15, 2026
Merged

ncalvanese1 merged 7 commits into
developfrom
nc-dt-3206-data-library-cleanup

Conversation

@ncalvanese1

@ncalvanese1 ncalvanese1 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Addresses

DT-3206 -- Replacing data library study description logic with tags.

Summary

Data library search definitions previously used search terms in the study description field, which had the potential for turning up a large number of false positives. Now that study tags have been implemented, we have gone through the data library logic and switched most data libraries to use tags instead of study descriptions, and have added tags where appropriate to ensure the libraries that shouldn't change have remained consistent.

Also, as part of this work, refactored libraryVersions.spec.ts to use constraint-based testing rather than structure-specific assertions. Tests now validate Elasticsearch best practices (e.g., .keyword suffix usage, valid query structures) instead of expecting specific library configurations. This makes tests future-proof—library query structures can change freely as long as architectural constraints are maintained, eliminating test breakage from routine refactors.


Have you read Terra's Contributing Guide lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@ncalvanese1
ncalvanese1 requested a review from a team as a code owner September 14, 2026 19:57
@ncalvanese1
ncalvanese1 requested review from fboulnois and kevinmarete and removed request for a team September 14, 2026 19:57
…ucture

- Remove tests expecting both match_phrase and terms in description-based libraries
- Update tests to validate tags-only queries now that study.description matching has been removed
- Add test for using StudyDataEsFields.TAGS_KEYWORD constant for proper field references
- Keep specific tests for broad (institution + tags) and anvil (single tag) libraries
- Import StudyDataEsFields for consistent field reference usage
…d approach

Replace brittle implementation-specific tests with flexible constraint-based tests:

- Remove tests that expected specific library query structures
- Add constraint tests that enforce Elasticsearch best practices:
  - All terms queries use .keyword suffix for case-sensitive matching
  - No conflicting field variants (e.g., study.data.tags vs study.data.tags.keyword)
  - All bool queries have valid structure with single query type per clause
- Keep library-specific test only for 'broad' (has semantic/business logic reason)
- Tests now validate "rules" rather than "shapes", allowing query structure flexibility
- Future library additions or refactors won't break tests unless constraints are violated
- Add missing trailing commas on lines 308 and 311 to fix @stylistic/comma-dangle lint errors
- Update "all queries with terms use .keyword suffix" test to accept any .keyword-suffixed field (e.g., both data.tags.keyword and study.data.tags.keyword)
  - This allows different fields to serve different purposes while maintaining the constraint
  - Uses regex pattern matching to validate .keyword suffix regardless of field path
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for DUOS Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 90.29% 12014 / 13306
🔵 Statements 89.78% 12822 / 14282
🔵 Functions 87.27% 3538 / 4054
🔵 Branches 82.63% 7475 / 9046
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/libs/libraryVersions.ts 100% 100% 100% 100%
Generated in workflow #7109 for commit f462ae5 by the Vitest Coverage Report Action

- Add parentheses around arrow function parameter on line 240 (arrow-parens)
- Add parentheses around arrow function parameters on lines 263, 287, 290, 309, and 312 for consistency
- Ensures all arrow functions with curly braces have proper parentheses per @stylistic/arrow-parens rule
@sonarqubecloud

Copy link
Copy Markdown

@kevinmarete kevinmarete 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.

Looks good 👍🏾

@fboulnois fboulnois 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.

👍

@ncalvanese1
ncalvanese1 merged commit b2a4669 into develop Sep 15, 2026
16 checks passed
@ncalvanese1
ncalvanese1 deleted the nc-dt-3206-data-library-cleanup branch September 15, 2026 13:12
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