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

Fix/TR-3995/Max words restriction can be exceeded #145

Merged
merged 7 commits into from
Jun 17, 2022

Conversation

jsconan
Copy link
Contributor

@jsconan jsconan commented May 5, 2022

1/4

Related to: https://oat-sa.atlassian.net/browse/TR-3995

The helper util/strLimiter is aimed at limiting a text to a maximum number of units, either chars or words. Unfortunately, so far it was exclusively expecting plain text and it was producing wrong results with HTML.

This pull request proposes to support either plain text or HTML text.

How to test:

  • run the unit tests
  • create a test having extended text interactions with a constraint for the max words and for the max length (a test sample is attached to the ticket).
  • publish the test, then take it
  • type some text in the extended text interaction, then copy it and paste it until the limit is reached.
  • try to exhaust the limit by pasting again
  • remove a few words, ideally less than the number in the clipboard, then paste again

Without the fix, the limit can be overflown.
With the fix, we cannot overflow the limit.

@github-actions
Copy link

github-actions bot commented May 5, 2022

Version

Target Version 1.19.1
Last version 1.19.0

There are 0 BREAKING CHANGE, 0 feature, 3 fixes

@github-actions
Copy link

github-actions bot commented May 5, 2022

Coverage Report

Totals Coverage
Statements: 90.62% ( 2705 / 2985 )
Methods: 94.22% ( 782 / 830 )

Copy link
Contributor

@meefox meefox left a comment

Choose a reason for hiding this comment

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

Screenshot 2022-05-11 at 17 43 12

Review Checklist

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful
  • Pull request's target is not master
  • Commits are following conventional commits
  • Commits messages are meaningful
  • Commits are atomic
  • Changelog is updated according to changes (if applicable)
  • Documentation is updated according to changes (if applicable)

Copy link
Contributor

@shaveko shaveko left a comment

Choose a reason for hiding this comment

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

Code looks fine and tests run well, please check my comment on optional change

* @param {Node} fragment
*/
const limitFragment = fragment => {
[].slice.call(fragment.childNodes).forEach(node => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: may be we can rely on ES6 equivalent Array.from() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I was considering using it. But as there might be a need to backport it to an older version than needs IE support I preferred to stay safe.

@AntonNeviarouski
Copy link

QA verified

@jsconan jsconan merged commit 952b66e into develop Jun 17, 2022
@jsconan jsconan deleted the fix/TR-3995/max-words-restriction-can-be-exceeded branch June 17, 2022 14:18
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.

None yet

4 participants