Merge lp:~rharding/launchpad/yui35_test into lp:launchpad

Proposed by Richard Harding on 2012-06-25
Status: Merged
Approved by: Richard Harding on 2012-06-27
Approved revision: no longer in the source branch.
Merged at revision: 15503
Proposed branch: lp:~rharding/launchpad/yui35_test
Merge into: lp:launchpad
Diff against target: 293 lines (+43/-30)
10 files modified
lib/lp/app/javascript/banners/tests/test_banner.js (+6/-5)
lib/lp/app/javascript/banners/tests/test_beta_notification.js (+7/-6)
lib/lp/app/javascript/banners/tests/test_privacy.js (+3/-2)
lib/lp/app/javascript/client.js (+1/-1)
lib/lp/app/javascript/indicator/indicator.js (+1/-1)
lib/lp/app/javascript/picker/person_picker.js (+2/-2)
lib/lp/app/javascript/picker/tests/test_personpicker.js (+9/-6)
lib/lp/app/javascript/testing/testrunner.js (+5/-2)
lib/lp/app/javascript/tests/test_lp_client.js (+7/-3)
lib/lp/app/javascript/tests/test_multicheckboxwidget.js (+2/-2)
To merge this branch: bzr merge lp:~rharding/launchpad/yui35_test
Reviewer Review Type Date Requested Status
j.c.sackett (community) 2012-06-25 Approve on 2012-06-27
Review via email: mp+111911@code.launchpad.net

Commit Message

Update JS to be compatible with YUI 3.5.

Description of the Change

= Summary =

This branch begins testing against YUI3.5. This branch only looks at making
tests pass in both our current YUI and 3.5 in the app/javascript directory.

== Pre Implementation ==

Talked with Deryck to start work.

== Implementation Notes ==

This leaves out two failing tests
listing_navigator
lp_names

They both have their own methods of running tests and try to setup their own
YUI configs. This causes them to blow up more than the other tests and will
require more refactoring in a follow up branch.

Most of the failures are around the test runner itself, or in selectors based
on attributes not quoting the attribute value.

This updates those cases as well as a few other misc items required to get the
tests to run and display correctly.

== Tests ==

./bin/test -x -cvv --layer=YUITestLayer

== Lint ==

Linting changed files:
  lib/lp/app/javascript/client.js
  lib/lp/app/javascript/banners/tests/test_banner.js
  lib/lp/app/javascript/banners/tests/test_beta_notification.js
  lib/lp/app/javascript/banners/tests/test_privacy.js
  lib/lp/app/javascript/indicator/indicator.js
  lib/lp/app/javascript/picker/person_picker.js
  lib/lp/app/javascript/picker/tests/test_personpicker.js
  lib/lp/app/javascript/testing/testrunner.js
  lib/lp/app/javascript/tests/test_lp_client.js
  lib/lp/app/javascript/tests/test_multicheckboxwidget.js

== LoC Qualification ==

There are two qualifications:

1. Fixing these tests reduces tech debt and eases maintenance.
2. Getting to YUI 3.5 will allow us to use the build in calendar widget and
will remove all of the YUI2 code from the code base which is aroud 12K LoC
(non-minified) and over 27K lines of total files.

To post a comment you must log in.
j.c.sackett (jcsackett) wrote :

This looks good. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/banners/tests/test_banner.js'
2--- lib/lp/app/javascript/banners/tests/test_banner.js 2012-05-22 22:08:07 +0000
3+++ lib/lp/app/javascript/banners/tests/test_banner.js 2012-06-26 17:59:21 +0000
4@@ -17,7 +17,8 @@
5 },
6
7 tearDown: function () {
8- Y.one('body').get('children').remove(true);
9+ Y.one('#maincontent').remove(true);
10+ Y.all('.yui3-banner').remove(true);
11 },
12
13 test_library_exists: function () {
14@@ -47,7 +48,7 @@
15 var banner = new Y.lp.app.banner.Banner({ skip_animation: true });
16 banner.render();
17
18- var banner_node = Y.one(".global-notification")
19+ var banner_node = Y.one(".global-notification");
20 Y.Assert.isObject(banner_node);
21 Y.Assert.isTrue(banner_node.hasClass('hidden'));
22 },
23@@ -71,7 +72,7 @@
24 test_show: function() {
25 var banner = new Y.lp.app.banner.Banner({ skip_animation: true });
26 banner.render();
27- banner.show();
28+ banner.show();
29 var banner_node = Y.one(".global-notification");
30 Y.Assert.isFalse(banner_node.hasClass('hidden'));
31 },
32@@ -87,7 +88,7 @@
33 var wait_for_anim = 20;
34 var check = function () {
35 Y.Assert.isTrue(banner_node.hasClass('hidden'));
36- }
37+ };
38 banner.hide();
39 this.wait(check, wait_for_anim);
40 },
41@@ -101,7 +102,7 @@
42 Y.Assert.areEqual(new_text, banner_node.get('text'));
43
44 banner.updateText();
45- var banner_node = Y.one(".global-notification");
46+ banner_node = Y.one(".global-notification");
47 Y.Assert.areEqual("", banner_node.get('text'));
48 }
49 }));
50
51=== modified file 'lib/lp/app/javascript/banners/tests/test_beta_notification.js'
52--- lib/lp/app/javascript/banners/tests/test_beta_notification.js 2012-05-21 13:52:53 +0000
53+++ lib/lp/app/javascript/banners/tests/test_beta_notification.js 2012-06-26 17:59:21 +0000
54@@ -24,7 +24,8 @@
55 },
56
57 tearDown: function () {
58- Y.one('body').get('children').remove(true);
59+ Y.one('#maincontent').remove(true);
60+ Y.all('.yui3-banner').remove(true);
61 },
62
63 test_library_exists: function () {
64@@ -40,7 +41,7 @@
65 url: 'http://lp.dev/LEP/one'
66 }};
67 var betabanner = new Y.lp.app.banner.beta.BetaBanner(
68- {skip_animation: true});
69+ {skip_animation: true});
70 betabanner.render();
71 betabanner.show();
72
73@@ -72,7 +73,7 @@
74 url: ''
75 }};
76 var betabanner = new Y.lp.app.banner.beta.BetaBanner(
77- {skip_animation: true});
78+ {skip_animation: true});
79 betabanner.render();
80 betabanner.show();
81
82@@ -101,7 +102,7 @@
83 title: 'Non-beta feature',
84 url: 'http://example.org'
85 }};
86- Y.lp.app.banner.beta.show_beta_if_needed();
87+ Y.lp.app.banner.beta.show_beta_if_needed();
88 Y.Assert.isNull(Y.one('.global-notification'));
89 },
90
91@@ -113,7 +114,7 @@
92 url: 'http://lp.dev/LEP/one'
93 }};
94 var betabanner = new Y.lp.app.banner.beta.BetaBanner(
95- {skip_animation: true});
96+ {skip_animation: true});
97 betabanner.render();
98 betabanner.show();
99 var body = Y.one('body');
100@@ -126,7 +127,7 @@
101 Y.Assert.isTrue(banner.hasClass('hidden'));
102 Y.Assert.isFalse(
103 body.hasClass('global-notification-visible'));
104- }
105+ };
106 close_link = Y.one('.global-notification-close');
107 close_link.simulate('click');
108 var wait_time = 20;
109
110=== modified file 'lib/lp/app/javascript/banners/tests/test_privacy.js'
111--- lib/lp/app/javascript/banners/tests/test_privacy.js 2012-05-22 22:13:06 +0000
112+++ lib/lp/app/javascript/banners/tests/test_privacy.js 2012-06-26 17:59:21 +0000
113@@ -19,7 +19,8 @@
114 },
115
116 tearDown: function () {
117- Y.one('body').get('children').remove(true);
118+ Y.one('#maincontent').remove(true);
119+ Y.all('.yui3-banner').remove(true);
120 },
121
122 test_library_exists: function () {
123@@ -43,7 +44,7 @@
124 Y.Assert.areEqual(1, Y.all('.global-notification').size());
125
126 var new_text = 'This is new text';
127- var banner = Y.lp.app.banner.privacy.getPrivacyBanner(new_text);
128+ banner = Y.lp.app.banner.privacy.getPrivacyBanner(new_text);
129 Y.Assert.areEqual(1, Y.all('.global-notification').size());
130 var banner_node = Y.one('.global-notification');
131 Y.Assert.areEqual(
132
133=== modified file 'lib/lp/app/javascript/client.js'
134--- lib/lp/app/javascript/client.js 2012-03-27 04:36:24 +0000
135+++ lib/lp/app/javascript/client.js 2012-06-26 17:59:21 +0000
136@@ -1022,7 +1022,7 @@
137 }
138 // Display the field specific errors.
139 Y.each(errors, function(message, field_name) {
140- var label = Y.one('label[for=' + field_name + ']');
141+ var label = Y.one('label[for="' + field_name + '"]');
142 if (Y.Lang.isValue(label)) {
143 label.ancestor('div').addClass('error');
144 var field = label.next('div');
145
146=== modified file 'lib/lp/app/javascript/indicator/indicator.js'
147--- lib/lp/app/javascript/indicator/indicator.js 2012-01-19 02:00:52 +0000
148+++ lib/lp/app/javascript/indicator/indicator.js 2012-06-26 17:59:21 +0000
149@@ -204,4 +204,4 @@
150 indicator.OverlayIndicator = OverlayIndicator;
151 indicator.actions = actions;
152
153-}, '0.1', {requires: ['base', 'widget']});
154+}, '0.1', {requires: ['base', 'node-screen', 'widget']});
155
156=== modified file 'lib/lp/app/javascript/picker/person_picker.js'
157--- lib/lp/app/javascript/picker/person_picker.js 2012-06-26 00:15:11 +0000
158+++ lib/lp/app/javascript/picker/person_picker.js 2012-06-26 17:59:21 +0000
159@@ -123,8 +123,8 @@
160
161 _save_new_team: function() {
162 var node = this.get('contentBox').one('.new-team-node');
163- var team_name = node.one('[id=field.name]').get('value');
164- var team_display_name = node.one('[id=field.displayname]')
165+ var team_name = node.one('[id="field.name"]').get('value');
166+ var team_display_name = node.one('[id="field.displayname"]')
167 .get('value');
168 this.hide_extra_content(node, false);
169 // TODO - make back end call to save team
170
171=== modified file 'lib/lp/app/javascript/picker/tests/test_personpicker.js'
172--- lib/lp/app/javascript/picker/tests/test_personpicker.js 2012-06-26 00:15:11 +0000
173+++ lib/lp/app/javascript/picker/tests/test_personpicker.js 2012-06-26 17:59:21 +0000
174@@ -1,4 +1,5 @@
175-/* Copyright 2011 Canonical Ltd. This software is licensed under the * GNU Affero General Public License version 3 (see the file LICENSE).
176+/* Copyright 2011 Canonical Ltd. This software is licensed under the
177+ * GNU Affero General Public License version 3 (see the file LICENSE).
178 */
179
180 YUI().use('test', 'console', 'plugin',
181@@ -366,8 +367,7 @@
182 'Enter new team details',
183 this.picker.get('headerContent').get('text'));
184 Y.Assert.isNotNull(
185- this.picker.get('contentBox')
186- .one('input[id=field.name]'));
187+ this.picker.get('contentBox').one('input[id="field.name"]'));
188 Y.Assert.areEqual('none',
189 this.picker.get('contentBox').one('.yui3-widget-bd')
190 .getStyle('display'));
191@@ -392,7 +392,7 @@
192 'Pick Someone',
193 this.picker.get('headerContent').get('text'));
194 Y.Assert.isNotNull(
195- this.picker.get('contentBox').one('input[id=field.name]')
196+ this.picker.get('contentBox').one('input[id="field.name"]')
197 .ancestor('div.hidden'));
198 Y.Assert.isNotNull(
199 this.picker.get('contentBox').one('.yui3-picker-search'));
200@@ -417,7 +417,7 @@
201 var new_team =
202 picker_content.one('.yui-picker-new-team-button');
203 new_team.simulate('click');
204- var team_name = picker_content.one('input[id=field.name]');
205+ var team_name = picker_content.one('input[id="field.name"]');
206 team_name.set('value', 'fred');
207 var form_buttons = picker_content.one('.extra-form-buttons');
208 simulate(
209@@ -546,7 +546,10 @@
210
211 // Hook for the test runner to get test results.
212 var handle_complete = function(data) {
213- window.status = '::::' + JSON.stringify(data);
214+ window.status = '::::' + JSON.stringify({
215+ results: data.results,
216+ type: data.type
217+ });
218 };
219 Y.Test.Runner.on('complete', handle_complete);
220 Y.Test.Runner.add(suite);
221
222=== modified file 'lib/lp/app/javascript/testing/testrunner.js'
223--- lib/lp/app/javascript/testing/testrunner.js 2011-07-18 11:52:51 +0000
224+++ lib/lp/app/javascript/testing/testrunner.js 2012-06-26 17:59:21 +0000
225@@ -21,8 +21,11 @@
226
227 // Lock, stock, and two smoking barrels.
228 var handle_complete = function(data) {
229- window.status = '::::' + JSON.stringify(data);
230- };
231+ window.status = '::::' + JSON.stringify({
232+ results: data.results,
233+ type: data.type
234+ });
235+ };
236 Y.Test.Runner.on('complete', handle_complete);
237 Y.Test.Runner.add(suite);
238
239
240=== modified file 'lib/lp/app/javascript/tests/test_lp_client.js'
241--- lib/lp/app/javascript/tests/test_lp_client.js 2012-03-27 04:36:24 +0000
242+++ lib/lp/app/javascript/tests/test_lp_client.js 2012-06-26 17:59:21 +0000
243@@ -74,7 +74,9 @@
244 test_append_qs: function() {
245 var qs = "";
246 qs = Y.lp.client.append_qs(qs, "Pöllä", "Perelló");
247- Assert.areEqual("P%C3%83%C2%B6ll%C3%83%C2%A4=Perell%C3%83%C2%B3", qs);
248+ Assert.areEqual(
249+ "P%C3%83%C2%B6ll%C3%83%C2%A4=Perell%C3%83%C2%B3", qs,
250+ 'This tests is known to fail in Chrome, it is browser specific.');
251 },
252
253 test_append_qs_with_array: function() {
254@@ -494,13 +496,15 @@
255 _assert_error_rendering: function() {
256 var label = Y.one('label[for="field.test"]');
257 var field_error = label.next('div').next('.message');
258- Y.Assert.isTrue(Y.one('#field_div').hasClass('error'));
259+ Y.Assert.isTrue(Y.one('#field_div').hasClass('error'),
260+ 'Field div has class error');
261 Y.Assert.areEqual('Field error', field_error.getContent());
262 Y.all('.error.message').each(function(error_node) {
263 var error_message = error_node.getContent();
264 Y.Assert.isTrue(
265 error_message === '<p>Form error</p>' ||
266- error_message === 'Some errors');
267+ error_message === 'Some errors',
268+ 'Each error message has the correct content.');
269 });
270 },
271
272
273=== modified file 'lib/lp/app/javascript/tests/test_multicheckboxwidget.js'
274--- lib/lp/app/javascript/tests/test_multicheckboxwidget.js 2011-07-08 05:12:39 +0000
275+++ lib/lp/app/javascript/tests/test_multicheckboxwidget.js 2012-06-26 17:59:21 +0000
276@@ -110,7 +110,7 @@
277 var x;
278 for (x = 0; x < 2; x++) {
279 var item = Y.one(
280- 'input[id="field.multicheckboxtest.'+x+'][type=checkbox]');
281+ 'input[id="field.multicheckboxtest.'+x+'"][type="checkbox"]');
282 Y.Assert.areEqual(item.getAttribute('value'), x);
283 Y.Assert.areEqual(item.get('checked'), x === 0);
284 }
285@@ -121,7 +121,7 @@
286 this.createWidget();
287 var x;
288 for (x = 0; x < 2; x++) {
289- var item = Y.one('label[for="field.multicheckboxtest.'+x+']');
290+ var item = Y.one('label[for="field.multicheckboxtest.'+x+'"]');
291 var txt = item.get('textContent');
292 //remove any &nbsp in the text
293 txt = txt.replace(/^[\s\xA0]+/g,'').replace(/[\s(&nbsp;)]+$/g,'');