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

Fix ngjq #11182

Closed
wants to merge 3 commits into from
Closed

Fix ngjq #11182

wants to merge 3 commits into from

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Feb 25, 2015

@mboudreau This is a wip for the e2e tests. You can play around with it. (use grunt test:protractor) You can als comment out the other test paths in protractor.conf.js, so only the e2e folders get run:

// 'build/docs/ptore2e/**/*.js',
// 'docs/app/e2e/**/*.scenario.js'

The problem is currently that we don't have a reliable method of detecting what is loaded, because jq is private. We might have to expose it. Currently we can only test that it doesn't break.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@petebacondarwin
Copy link
Contributor

Looks good so far. We ought to be able to work out what jquery-like library is being used from inside the fixture app. For instance, in the fixture app, call angular.element() and then look for something that only appears in JQuery or jqLite.

@gkalpak
Copy link
Member

gkalpak commented Feb 26, 2015

We can just check that angular.element !== window.jQuery (either from inside the fixture, or using executeScript).
It would also be nice to test that one can load a different version of jQuery than the rest of the app (testing against window.jQuery.fn.jquery).

@Narretz Narretz self-assigned this Feb 27, 2015
@Narretz
Copy link
Contributor Author

Narretz commented Feb 27, 2015

thx @gkalpak that works very well.

I'm not quite sure how we should test for another version of jquery without including it in the repo.

@petebacondarwin
Copy link
Contributor

Since it is just an e2e test, perhaps we could hit a CDN with well defined versions of jQuery for the test?

@Narretz
Copy link
Contributor Author

Narretz commented Mar 2, 2015

I updated the PR with expects & a test for ensuring forcing a specific jQuery version works via google cdn. The http request should be negligible as the e2e take a long time anyway.

@Narretz Narretz assigned petebacondarwin and unassigned Narretz Mar 2, 2015
it('should be able to force jqlite', function() {
loadFixture("ngJq").andWaitForAngular();
expect(browser.executeScript('return window.angular.element !== window.jQuery')).toBe(true);
});
Copy link
Member

Choose a reason for hiding this comment

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

It might be a good idea to also test that window.jQuery is defined.

E.g. imagine 'jquery.js' isn't properly loaded in the future for whatever reason (e.g. directory is moved). It would be good to catch this in the test (and fix).

@Narretz
Copy link
Contributor Author

Narretz commented Mar 2, 2015

I refactored the tests to use a directive that exposes a binding on the scope.

The test with forcing a specific version of jQuery fails when the file is on the google cdn. It works when I have the file locally. It also works with the cdn when I try it in a non-protractor environment, so I think it might be something with protractor, that it is not waiting for the file to download.

@petebacondarwin
Copy link
Contributor

I think the e2e middleware is rewriting the path to the CDN for the jquery at this point: https://github.com/angular/angular.js/blob/master/test/e2e/tools/util.js#L34

@petebacondarwin
Copy link
Contributor

In my branch here: angular:master...petebacondarwin:ngJq

then run grunt webserver

and go to http://localhost:8000/e2e/fixtures/ngJqJquery

You can see in the source that the CDN src is changed to false

@Narretz
Copy link
Contributor Author

Narretz commented Mar 5, 2015

Thanks @petebacondarwin I was so focused on protractor being the problem that I didn't consider the rewrite.

@Narretz
Copy link
Contributor Author

Narretz commented Mar 6, 2015

I updated the PR. script src starting with http are now exempt from rewrite. I also included the simplified code from @petebacondarwin

@petebacondarwin
Copy link
Contributor

And now it works, yes?

@@ -0,0 +1,6 @@
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

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

This line breaks jshint rules. It should either be made into the functional form, or perhaps easier just remove it.

@petebacondarwin
Copy link
Contributor

Merging...

@Narretz Narretz closed this in 3fd4874 Mar 6, 2015
@Narretz
Copy link
Contributor Author

Narretz commented Mar 6, 2015

Thanks @petebacondarwin !

hansmaad pushed a commit to hansmaad/angular.js that referenced this pull request Mar 10, 2015
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
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