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

[CSL-3108] Trim space adjustments #183

Merged
merged 7 commits into from
Dec 20, 2023
Merged

Conversation

sblaurock
Copy link
Contributor

@sblaurock sblaurock commented Dec 19, 2023

It has been raised that autocomplete requests should not have non-breaking spaces trimmed from queries (terms). This pull request aims to do the following:

a. No longer trim non-breaking spaces from autocomplete and search requests

b. Add tests to cover the above case.

Reference ticket: https://linear.app/constructor/issue/CSL-3108/investigate-error-with-space-input-in-constructorio-node

@sblaurock sblaurock requested a review from a team December 19, 2023 00:32
const queryTrimmed = helpers.trimNonBreakingSpaces(query);

// Validate query (term) is provided and consists of more than non-breaking spaces
if (!queryTrimmed || typeof queryTrimmed !== 'string') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added to ensure we don't dispatch requests consisting of solely non-breaking spaces (ex: )

const queryTrimmed = helpers.trimNonBreakingSpaces(query);

// Validate query (term) is provided and consists of more than non-breaking spaces
if (!queryTrimmed || typeof queryTrimmed !== 'string') {
Copy link
Contributor Author

@sblaurock sblaurock Dec 19, 2023

Choose a reason for hiding this comment

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

This was added to ensure we don't dispatch requests consisting of solely non-breaking spaces (ex: )

Copy link
Contributor

@jjl014 jjl014 left a comment

Choose a reason for hiding this comment

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

This looks great to me! 🚀 Just left one minor comment that you can feel free to ignore.

Thanks for working on this! ❤️

@@ -6,6 +6,7 @@ const sinon = require('sinon');
const sinonChai = require('sinon-chai');
const ConstructorIO = require('../../../test/constructorio'); // eslint-disable-line import/extensions
const helpers = require('../../mocha.helpers');
const utilsHelpers = require('../../../src/utils/helpers');
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to ignore this, but should we just import the specific function here so we don't have helpers and utilsHelpers? Haha

i.e. const { trimNonBreakingSpaces } = require('../../../src/utils/helpers');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great callout - this is going to go away anyway. We should not be trimming on search either

Copy link
Contributor

@jjl014 jjl014 left a comment

Choose a reason for hiding this comment

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

Nice, this is looking great to me!

I noticed that we cleaned the query on autocomplete, but not for search. Don't recall why we did that, but maybe something to revisit in the future.

@sblaurock sblaurock merged commit 90d178f into master Dec 20, 2023
7 of 8 checks passed
@sblaurock sblaurock deleted the csl-3108/trim-space-adjustments branch December 20, 2023 21:28
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.

2 participants