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

FIO-8885 & FIO-8886: use strict equality check for conditional component paths rather than Array.prototype.includes #141

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

brendanbond
Copy link
Contributor

@brendanbond brendanbond commented Aug 22, 2024

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-8886

Description

Previously, we compared conditional component paths to the context path using Array.prototype.includes, which would trigger a false positive when the string path of the component was "contained" within another key (e.g. a key "or" would be found in another hidden key "information"). Since we should be adding components to the conditionals scope keyed by absolute paths, this PR changes the comparison to strict equality.

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

The main concern here is ensuring that components added to the conditional scope are keyed by absolute data path, so I wrote tests trying to ensure that even deeply nested components get added to that scope using an absolute path. Additionally, formio and formio-server tests pass with this change.

Checklist:

  • I have completed the above PR template
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

@brendanbond brendanbond changed the title FIO-8886: use strict equality check for conditional component paths rather than Array.prototype.includes FIO-8885 & FIO-8886: use strict equality check for conditional component paths rather than Array.prototype.includes Aug 22, 2024
Copy link
Contributor

@mikekotikov mikekotikov left a comment

Choose a reason for hiding this comment

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

LGTM

src/process/conditions/__tests__/conditions.test.ts Outdated Show resolved Hide resolved
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