Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(input): Take timezone into account when validating minimum and ma… #16390

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

m-amr
Copy link
Contributor

@m-amr m-amr commented Jan 5, 2018

…ximum date spans.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix

What is the current behavior? (You can also link to an open issue here)

All details in issue for Issue #16342

What is the new behavior (if this is a feature change)?

All details in issue for Issue #16342

Does this PR introduce a breaking change?

no

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Fix/Feature: Docs have been added/updated
  • Fix/Feature: Tests have been added; existing tests pass

Other information:

@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 0079b78 to 5fb8d31 Compare January 5, 2018 00:27
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 5fb8d31 to ccdb700 Compare January 5, 2018 00:43
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from ccdb700 to a0861ea Compare January 5, 2018 00:48
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from a0861ea to 8b9af1f Compare January 5, 2018 01:02
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 8b9af1f to 66a8a8e Compare January 5, 2018 01:15
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 66a8a8e to e5401c9 Compare January 5, 2018 01:24
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from e5401c9 to 58fd32a Compare January 5, 2018 10:11
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 58fd32a to 91418cc Compare January 5, 2018 10:25
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 91418cc to e1f150c Compare January 5, 2018 16:32
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from e1f150c to 76355f1 Compare January 5, 2018 19:18
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 76355f1 to f4decfb Compare January 5, 2018 21:37
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 5, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from f4decfb to 38cda5f Compare January 6, 2018 12:31
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 6, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 38cda5f to 483c123 Compare January 6, 2018 13:13
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 6, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 483c123 to cf071f8 Compare January 6, 2018 13:34
m-amr added a commit to m-amr/angular.js that referenced this pull request Jan 6, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from cf071f8 to 8d9f9cb Compare January 6, 2018 15:24
Copy link
Contributor

@Narretz Narretz 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 good at first glance.

The tests need some love, however.
In inputSpec, we have a min and a max suite for every type of date input (month, week, date etc), so the we need 2 tests (min +max) for each of them.
Please also note the change request on the test you've already added - this must go into each of the tests that need to be added.

@@ -840,6 +840,16 @@ describe('input', function() {

expect($rootScope.form.alias.$error.max).toBeFalsy();
});

it('should validate when timezone is provided.', function() {
inputElm = helper.compileInput('<input type="date" ng-model="value" name="alias" ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are only testing max, please remove min here

$rootScope.$digest();

expect($rootScope.form.alias.$error.max).toBeFalsy();
expect($rootScope.form.alias.$valid).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be am expectation after this that checks whether the validation also works when the input is updated. You might have to clear the model for that first.

}

function parseDateAndConvertTimeZoneToLocal(value, previousDate) {
var parsedDate = previousDate ? parseDate(value, previousDate) : parseDate(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply = parseDate(value, previousDate)? If the previousDate is undefined, it's not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are same but they only different in case you check arguments

function parse(a, b){
    console.log(arguments.length)
}

parse(1) // it will log 1
parse(1, undefined) //it will log 2

if someone in the future decide do something depend on the arguments.length it will not be the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt this will happen. Even more so as this is an internal API. Our tests should also catch any problems this might cause.

@Narretz
Copy link
Contributor

Narretz commented Jan 29, 2018

@m-amr are you still working on this?

@m-amr
Copy link
Contributor Author

m-amr commented Jan 29, 2018

@Narretz yes, i am working on it. i will add the missing tests by this week-end.

@m-amr m-amr closed this Jan 29, 2018
@m-amr m-amr reopened this Jan 30, 2018
@Narretz Narretz modified the milestones: 1.6.9, 1.6.10 Feb 2, 2018
@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 32d76dd to ee5a110 Compare February 3, 2018 21:56
m-amr added a commit to m-amr/angular.js that referenced this pull request Feb 3, 2018
@Narretz Narretz self-assigned this Feb 12, 2018
@Narretz
Copy link
Contributor

Narretz commented Feb 27, 2018

Hi @m-amr , sorry for the delay, I didn't get a notification when you updated the PR.
I noticed there's still a test for plain input type="date" missing, and that the test for input type="week" passes even without your change - that is usually a sign that the test isn't correct.

@m-amr
Copy link
Contributor Author

m-amr commented Feb 27, 2018

Hi @Narretz ,
Thanks for replying.
I will work on this PR this weekend. i will add all the missing tests.

@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from ee5a110 to 06709f9 Compare March 10, 2018 21:02
m-amr added a commit to m-amr/angular.js that referenced this pull request Mar 10, 2018
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

1 similar comment
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@m-amr
Copy link
Contributor Author

m-amr commented Mar 29, 2018

@Narretz
Thanks for updating the date-week tests. i didn't understand that this is the problem I got it now.
I have added the missing tests in the previous commit.

Can you please review the PR again and tell me if anything is missing or need to change ?
I am not sure why CLA post on this PR?
I have signed it before.

@Narretz
Copy link
Contributor

Narretz commented Apr 3, 2018

@m-amr I think I mentioned earlier that the test was not working as intended, but that's okay.
And you don't have to add the changes to your commit, I can squash the changes when I merge the PR.

@m-amr m-amr force-pushed the fix_max_attribute_ignore_timezone branch from 4c75421 to 08604c0 Compare April 3, 2018 20:59
@Narretz Narretz merged commit b7bb797 into angular:master Apr 6, 2018
@Narretz
Copy link
Contributor

Narretz commented Apr 6, 2018

Finally merged, thanks @m-amr

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants