-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sc 63647/submission of json objects to string fields #170
Sc 63647/submission of json objects to string fields #170
Conversation
lib/types/date.js
Outdated
@@ -10,6 +10,7 @@ const formats = [ | |||
'ddd MMM DD YYYY', // 'Mon Jun 02 2014' | |||
'MMM DD YYYY', // 'Jun 02 2014' | |||
'M/D/YYYY', // '6/2/2014', '06/02/2014' | |||
'MM/DD/YYYY', // '06/02/2014' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mapping scenario was missing here and was causing failures in the unit tests
lib/types/date.js
Outdated
@@ -20,6 +21,7 @@ const formats = [ | |||
'ddd DD MMM YYYY', // 'Fri 18 July 2014' | |||
'DD MMM YYYY', // '18 July 2014' | |||
'D/M/YYYY', // '18/7/2014' | |||
'DD/MM/YYYY', // '18/07/2014' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mapping scenario was missing here and was causing failures in the unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. This worries me some. I don't understand why these date tests started failing, after working fine as of the previous release (here). What changed?
I do see the failures locally, too. But when I applied just this change, for example, it caused other failures, such as:
06/02/2014
should return a Date object:
AssertionError: expected '2014-02-06T00:00:00.000Z' to equal '2014-06-02T00:00:00.000Z'
+ expected - actual
-2014-02-06T00:00:00.000Z
+2014-06-02T00:00:00.000Z
Which I suppose your other changes fix. But that's a functional change, not just a test fix. Customers may be relying on LeadConduit treating 06/02/2014
as June 2nd, and not February 6th.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that something changed in moment from version 2.29.4 to 2.30.0. In our last versioning of types, version 2.29.4 was used. By enforcing it here, the tests pass without adding these two scenarios. There was likely a bug in this conversion that has been fixed.
Regarding clients sending dates like 06/02/2014 being converted to June 2nd and not Feb 6th, this might also be happening in cases with D/M/YYYY and M/D/YYYY formats already mapped previously. In such cases, the first format passed in the formats array will always be the one that moment returns.
-- new info: the change in moment was on isValid
function; before v2.30
, isValid('18/07/2014',['D/M/YYYY'])
was returning true
. Now we need to add the correct mask DD/MM/YYYY
, otherwise it will return false
. Moment conversion still working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were masking this issue in the tests for European formats because we were using a day that can't be a month (18).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this scenario, we would have to think about how to proceed, such as opting for (and accepting) a standard conversion to US format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A change in moment
, that explains it! Thank you for finding that!
I think the thing to do in this PR is lock moment
to 2.29.4
, and open another story to, just as you say, think about how to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes for first_name
look good, but the fixes to the unit tests have me worried. I'd really like to know why those tests started failing.
I also wonder if other types that are basically just strings should get this same protection. I think that would just be last_name
and city
.
lib/types/date.js
Outdated
@@ -20,6 +21,7 @@ const formats = [ | |||
'ddd DD MMM YYYY', // 'Fri 18 July 2014' | |||
'DD MMM YYYY', // '18 July 2014' | |||
'D/M/YYYY', // '18/7/2014' | |||
'DD/MM/YYYY', // '18/07/2014' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. This worries me some. I don't understand why these date tests started failing, after working fine as of the previous release (here). What changed?
I do see the failures locally, too. But when I applied just this change, for example, it caused other failures, such as:
06/02/2014
should return a Date object:
AssertionError: expected '2014-02-06T00:00:00.000Z' to equal '2014-06-02T00:00:00.000Z'
+ expected - actual
-2014-02-06T00:00:00.000Z
+2014-06-02T00:00:00.000Z
Which I suppose your other changes fix. But that's a functional change, not just a test fix. Customers may be relying on LeadConduit treating 06/02/2014
as June 2nd, and not February 6th.
…d function o newer versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, I appreciate it. You left a stray .only
in a test file but otherwise LGTM 👍
test/date.test.js
Outdated
@@ -1,7 +1,7 @@ | |||
const { assert } = require('chai'); | |||
const date = require('../lib/types/date'); | |||
|
|||
describe('Date', function () { | |||
describe.only('Date', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops 🙂
…d function o newer versions
Description of the change
Add string validation and
is valid/invalid format
operators to first_name typeType of change
Related tickets
Ticket SC-63647
Checklists
Development and Testing
Code Review
Tracking
QA