-
Notifications
You must be signed in to change notification settings - Fork 40
feat(assignVar): Patch for assignVar to add "drop key" feature and fixes reflecting documentation #350
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
Conversation
- Empty string ( "" ) to be accepted as entry into assignVar helper. - Null or Undefined values as input to assignVar now delete the key that was set. This has the usecase of freeing variables assigned by widgets or temporary assignments. - Tests for these usecases in assignVar-getVar.js
Reference to open issue #305 |
- Patch for 'SafeString' object to be treated as a string instead of as an Object by unwrapping before use. - Added test cases to reflect 'SafeString' patch use case.
- Patch for 'SafeString' object to be treated as a string instead of as an Object by unwrapping before use. - Added test cases to reflect 'SafeString' patch use case. - Move setup commands for constructing global storage outside of assignment logic. Prevents case where a variable does not yet exist and a value is deleted.
…a/assignVar-patch
Rename title of PR due to 100 character limit: |
Amended PR context header to reflect #139 issue. |
Hey @jairo-bc Clarification request: given the line comment in the actual code, this reads as incorrect implementation. Can you please confirm if the below code should be interpreted as "the buffer length of 1024 should contain no more than 1024", or as per the current implementation "the buffer cannot hold 1024 character, or more than 1024 characters. The limit is 1023 characters in the buffer." // Validate that string is not longer than the max length
if (utils.isString(value) && value.length >= max_length) {
throw new ValidationError(`assignVar helper value must be less than ${max_length} characters,
but a ${value.length} character value was set to ${key}`);
}
|
…ext gets too large and/or a variable within context gets too large. Bug is that the variable will be replaced with a JS `undefined` when actually being provided to template for rendering. Work around is to use a JS template string to generate the test handlebars with the text to test injected as part of inline. Added: - Testing procedure for large text.
Add comment to module exports explaining output change.
…rom helper to prevent test, helper mismatch due to magic number change.
@jairo-bc @bc-evan-johnson
|
Edit to also change from "up to limit" to "up to and inclusive of limit" when assigning a new variable in the global storage space.
Line 39 of assignVar.js seems like it does a incorrect check but actually resolves correctly to allow for a limit of 50 variables in practice.
🎉 This PR is included in version 6.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Proposal, What? Why?
Helper
assignVar
currently does not have a way to do any of the following features:""
because it is intended to be a placeholder when a value is not provided by the store admins or a customer input, say for a phone number click to call, this will currently cause the store to err.500 instead of handling what should be a valid input. The data input is inherently reasonable, so there is a patch in the validation logic to accept an empty string value instead of rejecting it.SafeString
object and treat it like a actual string for purposes of storage and retreival. Current workaround possible as per open issue assignVar helper does not work with SafeString #139Changes Overview
Create patch for assignVar to add following features:
unwrapSafeString
call before variable is process to all for storage and retrieval ofSafeString
contents.How was it tested?
Test cases provided in
assignVar-getVar.js
file.cc @bigcommerce/storefront-team