Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Update tests for AngularJS 1.2 #1342

Closed
wants to merge 6 commits into from

Conversation

chrisirhc
Copy link
Contributor

Update: Looks like if I just switch over to AngularJS 1.2 without maintaining 1.0 compatibility, there are little changes to be made and the tests pass.


This pull request is a work in progress.

I'm re-working tests so that they test for AngularJS 1.2 compatibility and differences.

Purpose of this:

  • Highlight things that need to be changed to make things work with AngularJS 1.2

This pull request:

  • Should not break any tests while running on AngularJS 1.0.8 (the current test setup) See comments below
  • Does not contain any changes to the modules, only changes to the tests

To use:

  1. Replace test-lib/angular.js and test-lib/angular-mocks.js with the 1.2 versions of those files.

The biggest change affects datepicker and timepicker tests is that ngModel is no longer using the isolate scope of the element directive, so using $parent.model breaks the tests as it's trying to access the model from the parent of the root scope. See breaking changes in the changelog and the original issue: angular/angular.js#1924 .

Another change that's breaking tests is that ngShowHide now adds/removes the ng-hide class instead of setting the display CSS property directly.

While working on this, I noticed a number of hacks around the edge cases. Some attributes had model-like behavior (two-way binding) (e.g. open), while other attributes were being picked up on the controller (before the linking and before the scope maybe ready). I think it's important to note these differences. This can be done either through documentation or via a naming convention of the attributes. I noticed an eye icon that I believe is supposed to mean something, but it's not quite clear what that means. (Shall put out another issue for this)

@pkozlowski-opensource
Copy link
Member

@chrisirhc nice work, AngularJS 1.2 support is next on out TODO list after Bootstrap3 support is released.
I'm leaving some additional comments in individual commits.

As far as hacks go - those need to be addressed, if something can be simplified, let's do it!

@pkozlowski-opensource
Copy link
Member

@chrisirhc looking closer at the things I'm not sure it makes sense to try to have those tests running on both 1.2 and 1.0. We should probably create a 1.2-specific branch, but only after BS3 support is out.

@chrisirhc
Copy link
Contributor Author

@pkozlowski-opensource You're right, it might make more sense to write tests for their expected behavior in 1.2 .
That way, I can remove the $parent and model part of the ngModels. That makes things cleaner.

@chrisirhc
Copy link
Contributor Author

Looks like if I can trust what the unit tests are telling me, ui-bootstrap is currently AngularJS 1.2 compatible. 😄
Only small changes had to be made, and only to the tests, to account for the change pertaining to isolate scopes.

Ref: angular/angular.js@909cabd , angular/angular.js@27e9340

@pkozlowski-opensource
Copy link
Member

@chrisirhc this is totally awesome!!!! It is great to see such good contributions, since those are rare!
I'm going to merge it as soon as BS3 support is out (before Xmas, this is for sure).

Once again, thnx for such hard, good quality work.

@matthughes
Copy link

FWIW, I'm trying to upgrade to BS 3 and NG 1.2 at the same time. I've forked the main bs3 branch here and tried to incorporate many of chrisirhc's fixes.

https://github.com/matthughes/bootstrap/tree/bs3ajs12

I would think most users upgrading to BS 3 would also want NG 1.2 at the same time. All tests pass short of date/time pickers; they are disabled until I can spend more time looking at them.

@chrisirhc
Copy link
Contributor Author

@pkozlowski-opensource Thank you for your kind words. 😄
I'm committed to making this a quality project. Cheers 🍺

@matthughes those tests should pass with the fixes here.

@matthughes
Copy link

@chrisirhc I believe your test fixes were assuming Bootstrap 2.3, no? That's what is on your branch. I'm trying to get both 3.0 BS and 1.2.3 NG working together.

@chrisirhc
Copy link
Contributor Author

@matthughes They should work on the Bootstrap 3.0 branch as the changes are only on the tests.

chrisirhc added a commit to chrisirhc/angular-ui-bootstrap that referenced this pull request Dec 21, 2013
- Ignore other tests for now as they require angular-ui#1342 to be merged
chrisirhc added a commit to chrisirhc/angular-ui-bootstrap that referenced this pull request Dec 21, 2013
- Ignore other tests for now as they require angular-ui#1342 to be merged
@chrisirhc
Copy link
Contributor Author

Rebased to master, looks good.

@bekos
Copy link
Contributor

bekos commented Jan 7, 2014

@chrisirhc There is already a test helper file at misc/test-lib/helpers.js. I suppose you can append the toBeHidden matcher there. Also, I would prefer to go with the latest 1.2.7 release files for angular & mock atm.

Let's merge this 👍

@pkozlowski-opensource
Copy link
Member

Definitively, let's merge it in! I think we should do the next release with the AngularJS1.2.x support. @bekos @chrisirhc could you guys merge this one?

@bekos
Copy link
Contributor

bekos commented Jan 7, 2014

@pkozlowski-opensource I can do. No problem. Should we squash the commits or it is better to see the analytic history?

@bekos
Copy link
Contributor

bekos commented Jan 7, 2014

@chrisirhc Can you rebase to current master, and consider the changes mentioned above?

@bekos
Copy link
Contributor

bekos commented Jan 7, 2014

I was just thinking, that since angularjs has a new release very often now, instead of updating manually the lib & mock files, it is better to use bower for this. WDYT?

@chrisirhc
Copy link
Contributor Author

I really like the idea of using bower!

My only concern is that we forget to check support for previous minor versions. However, this should be okay if we provide a AngularJS version option through grunt that way to allow quickly running tests on an older version.

@pkozlowski-opensource
Copy link
Member

Bower sounds like a good option - if it works :-) Saw some problems with it in the past, wasn't very reliable so I've abandoned it. It was few moths back so I might be spreading FUD here. Let's try to see what it gives. Any takers?

@chrisirhc
Copy link
Contributor Author

I can work on it as I rework the changes on this PR. 👍 Should be able to do it by tonight.

@ghost ghost assigned chrisirhc Jan 7, 2014
@bekos
Copy link
Contributor

bekos commented Jan 7, 2014

@chrisirhc That would be awesome 👍

@pkozlowski-opensource
Copy link
Member

OK, looked at the bower PR and I think it needs a bit more thinking. At the same time I would be keen to move on on this one and not have it blocked by the build-related discussion.

Could we make this one the old-school and focus on bower in #1542?

@chrisirhc I can take a stab at merging this one if you are busy

@pkozlowski-opensource
Copy link
Member

Just checked it quickly, there is only one merge conflict in the datepicker.spec.js

@chrisirhc
Copy link
Contributor Author

I should be able to do it pretty quickly. Got stuck last night due to mucking around with Bower.

@pkozlowski-opensource
Copy link
Member

@chrisirhc cool, so I'm not looking into this one in this case. As mentioned there seems to be conflict only in one file.

chrisirhc and others added 3 commits January 8, 2014 12:37
- Use unminified version for easier debugging
- Since Angular 1.2 is now using the ng-hide class to hide the element,
  it needs to be added into the DOM for styles to be computed.
AngularJS 1.2 introduces separate isolate scopes for directives that
require isolate scopes.

See angular/angular.js@909cabd
and angular/angular.js@27e9340
- Use ngBindHtml with $sce as ngBindHtmlUnsafe has been removed

See angular/angular.js@dae6947
@chrisirhc
Copy link
Contributor Author

@pkozlowski-opensource , done. There were some other changes needed for the tooltip spec due to new tests added.

@pkozlowski-opensource
Copy link
Member

@chrisirhc awesome. Just working on merging it with few minor changes (moving testing helpers to one place etc.).

@pkozlowski-opensource
Copy link
Member

@chrisirhc It is in master now. The only thing I've changed is this one:
85cf5b4

A W E S O M E work, we've got doors open to including 1.2-specificities ($animate and other improvements!).

@chrisirhc chrisirhc deleted the chore/tests-for-ng1.2 branch January 8, 2014 21:26
@chrisirhc
Copy link
Contributor Author

Ah, yes sorry about that. I meant to do that merge but I forgot!

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.

4 participants