launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10928
[Merge] lp:~rharding/launchpad/yui35_test_fix into lp:launchpad
Richard Harding has proposed merging lp:~rharding/launchpad/yui35_test_fix into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1036313 in Launchpad itself: "JS test failures under YUI 3.5.1"
https://bugs.launchpad.net/launchpad/+bug/1036313
For more details, see:
https://code.launchpad.net/~rharding/launchpad/yui35_test_fix/+merge/119582
This branch corrects tests and js code so that they all pas under YUI 3.5.1. This brings things back into alignment with the work previously done to update the JS code to prepare for testing YUI 3.5.1 behind the feature flag.
Since tests currently only run under 3.3.0, it's easy for them to get out of sync with the changes required for 3.5.1.
--
https://code.launchpad.net/~rharding/launchpad/yui35_test_fix/+merge/119582
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/yui35_test_fix into lp:launchpad.
=== modified file 'lib/lp/app/javascript/choiceedit/tests/test_choiceedit.html'
--- lib/lp/app/javascript/choiceedit/tests/test_choiceedit.html 2012-03-14 04:41:36 +0000
+++ lib/lp/app/javascript/choiceedit/tests/test_choiceedit.html 2012-08-14 16:26:19 +0000
@@ -21,6 +21,8 @@
<script type="text/javascript"
src="../../../../../../build/js/lp/app/testing/testrunner.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/testing/assert.js"></script>
<link rel="stylesheet" href="../../../../app/javascript/testing/test.css" />
=== modified file 'lib/lp/app/javascript/choiceedit/tests/test_choiceedit.js'
--- lib/lp/app/javascript/choiceedit/tests/test_choiceedit.js 2012-08-08 16:55:17 +0000
+++ lib/lp/app/javascript/choiceedit/tests/test_choiceedit.js 2012-08-14 16:26:19 +0000
@@ -486,10 +486,9 @@
this.null_choice_edit.get('actionicon'),
this.null_choice_edit.get('addicon'),
'Action icon is not the add icon like expected.');
-
- Assert.areEqual(
+ Assert.startsWith(
+ 'inline',
this.null_choice_edit.get('addicon').getStyle('display'),
- 'inline',
'Add icon is not visible when it should be');
Assert.areEqual(
this.null_choice_edit.get('editicon').getStyle('display'),
@@ -499,7 +498,7 @@
simulate(this.null_choice_edit.get('boundingBox'),
'.value', 'click');
simulate(this.null_choice_edit._choice_list.get('boundingBox'),
- 'li a[href$=groucho]', 'click');
+ 'li a[href$="groucho"]', 'click');
this.null_choice_edit._uiClearWaiting();
Assert.areEqual(
@@ -510,9 +509,9 @@
this.null_choice_edit.get('addicon').getStyle('display'),
'none',
"Add icon is visible when it shouldn't be");
- Assert.areEqual(
+ Assert.startsWith(
+ 'inline',
this.null_choice_edit.get('editicon').getStyle('display'),
- 'inline',
"Edit icon is not visible when it shouldn be");
},
@@ -553,9 +552,7 @@
}
}));
-
-
}, '0.1', {
- 'requires': ['test', 'console', 'lp.choiceedit', 'node', 'event',
+ 'requires': ['test', 'console', 'lp.testing.assert', 'lp.choiceedit', 'node', 'event',
'event-simulate', 'widget-stack', 'lp.app.choice']
});
=== modified file 'lib/lp/app/javascript/testing/assert.js'
--- lib/lp/app/javascript/testing/assert.js 2011-10-18 15:36:34 +0000
+++ lib/lp/app/javascript/testing/assert.js 2012-08-14 16:26:19 +0000
@@ -14,4 +14,22 @@
namespace.assert_equal_structure = function(expected, actual){
Y.Assert.areEqual(JSON.stringify(expected), JSON.stringify(actual));
};
-}, '0.1', {'requires': []});
+
+
+ /**
+ * @method Y.Assert.startsWith
+ */
+ Y.Assert.startsWith = function (expected, actual, message) {
+ Y.Assert._increment();
+ if (expected != actual.substr(0, expected.length)) {
+ throw new Y.Test.ComparisonFailure(
+ Y.Test.Assert._formatMessage(
+ message,
+ actual + "should start with " + expected),
+ expected,
+ actual.substr(0, expected.length));
+ }
+ };
+
+
+}, '0.1', {'requires': ['testing']});
=== modified file 'lib/lp/app/javascript/testing/helpers.js'
--- lib/lp/app/javascript/testing/helpers.js 2012-08-01 14:09:19 +0000
+++ lib/lp/app/javascript/testing/helpers.js 2012-08-14 16:26:19 +0000
@@ -32,7 +32,7 @@
*
* EXAMPLE:
* var client = new ns.LPCLient();
- *
+ *
* client.get.args = [];
* client.get(function_arg1, function_arg2);
*/
@@ -57,10 +57,10 @@
}
/**
* Captures call data and simulates callbacks.
- *
+ *
* The function called and the arguments it's called with are added to the
* LPCLient's `received` attribute.
- *
+ *
* Callback behavior are governed by the args set on the callee.
* @method
*/
=== modified file 'lib/lp/bugs/javascript/bug_picker.js'
--- lib/lp/bugs/javascript/bug_picker.js 2012-08-10 04:48:36 +0000
+++ lib/lp/bugs/javascript/bug_picker.js 2012-08-14 16:26:19 +0000
@@ -203,15 +203,14 @@
},
_private_warning_template: function(message) {
- var template = [
+ return [
'{{#private_warning}}',
'<tr><td><p id="privacy-warning" ',
'class="block-sprite large-warning">',
- '{message}',
+ message,
'</p></td></tr>',
'{{/private_warning}}'
].join(' ');
- return Y.Lang.substitute(template, {message: message});
},
// Template for the bug confirmation form.
@@ -237,12 +236,12 @@
var private_warning_message
= this.get('private_warning_message');
var html = Y.lp.mustache.to_html(
- this._bug_confirmation_form_template(), bug_data,
- {
+ this._bug_confirmation_form_template(),
+ bug_data, {
bug_details: this._bug_details_template(),
private_warning:
this._private_warning_template(private_warning_message)
- });
+ });
var bug_details_node = Y.Node.create(html);
var bug_link = bug_details_node.one('.bugtitle');
bug_link.on('click', function(e) {
=== modified file 'lib/lp/bugs/javascript/tests/test_bug_picker.js'
--- lib/lp/bugs/javascript/tests/test_bug_picker.js 2012-08-08 11:59:48 +0000
+++ lib/lp/bugs/javascript/tests/test_bug_picker.js 2012-08-14 16:26:19 +0000
@@ -32,6 +32,12 @@
}
},
+ // The specified error message is displayed.
+ _assert_error_display: function(message) {
+ var error_msg = Y.one('.yui3-picker-error');
+ Y.Assert.areEqual(message, error_msg.get('text').trim());
+ },
+
// The bug entry form is visible visible or not.
_assert_form_state: function(bug_details_visible) {
var bug_info = Y.one('.yui3-picker-results ' +
@@ -140,11 +146,6 @@
Y.Assert.isTrue(save_bug_called);
},
- // The specified error message is displayed.
- _assert_error_display: function(message) {
- var error_msg = Y.one('.yui3-picker-error');
- Y.Assert.areEqual(message, error_msg.get('text').trim());
- },
// The error is displayed as expected when the initial bug search
// fails with a generic error.
=== modified file 'lib/lp/bugs/javascript/tests/test_duplicates.js'
--- lib/lp/bugs/javascript/tests/test_duplicates.js 2012-08-09 04:56:41 +0000
+++ lib/lp/bugs/javascript/tests/test_duplicates.js 2012-08-14 16:26:19 +0000
@@ -37,6 +37,7 @@
}
delete this.mockio;
delete window.LP;
+ delete this.lp_client;
},
test_library_exists: function () {
@@ -65,6 +66,25 @@
return widget;
},
+ // The expected data is submitted after searching for and selecting a
+ // bug.
+ _assert_dupe_submission: function(bug_id) {
+ this._assert_search_form_submission(bug_id);
+ this._assert_search_form_success(bug_id);
+ Y.one(
+ '.yui3-picker-footer-slot [name="field.actions.save"]')
+ .simulate('click');
+ this._assert_form_state(true);
+ Y.Assert.areEqual(
+ '/foobar/bug/1/+duplicate',
+ this.mockio.last_request.url);
+ var expected_link =
+ 'field.actions.change=Set%20Duplicate' +
+ '&field.duplicateof=3';
+ Y.Assert.areEqual(
+ expected_link, this.mockio.last_request.config.data);
+ },
+
// The widget is created when there are no bug duplicates.
test_widget_creation_no_duplicate_exists: function() {
this.widget = this._createWidget(false);
@@ -140,25 +160,6 @@
privacy_message.get('text').trim());
},
- // The expected data is submitted after searching for and selecting a
- // bug.
- _assert_dupe_submission: function(bug_id) {
- this._assert_search_form_submission(bug_id);
- this._assert_search_form_success(bug_id);
- Y.one(
- '.yui3-picker-footer-slot [name="field.actions.save"]')
- .simulate('click');
- this._assert_form_state(true);
- Y.Assert.areEqual(
- '/foobar/bug/1/+duplicate',
- this.mockio.last_request.url);
- var expected_link =
- 'field.actions.change=Set%20Duplicate' +
- '&field.duplicateof=3';
- Y.Assert.areEqual(
- expected_link, this.mockio.last_request.config.data);
- },
-
// Submitting a bug dupe works as expected.
test_picker_form_submission_success: function() {
this.widget = this._createWidget(false);
=== modified file 'lib/lp/registry/javascript/sharing/granteepicker.js'
--- lib/lp/registry/javascript/sharing/granteepicker.js 2012-07-20 03:15:04 +0000
+++ lib/lp/registry/javascript/sharing/granteepicker.js 2012-08-14 16:26:19 +0000
@@ -171,7 +171,7 @@
if (Y.Lang.isObject(data.grantee_permissions)) {
Y.each(data.grantee_permissions, function(perm, type) {
var cb = step_two_content.one(
- 'input[name=field.permission.'+type+']' +
+ 'input[name="field.permission.'+type+'"]' +
'[value="' + perm + '"]');
if (Y.Lang.isValue(cb)) {
cb.set('checked', true);
@@ -221,7 +221,7 @@
var contentBox = this.get('contentBox');
var selected_permissions = {};
Y.Array.each(this.get('information_types'), function(info_type) {
- contentBox.all('input[name=field.permission.'+info_type.value+']')
+ contentBox.all('input[name="field.permission.'+info_type.value+'"]')
.each(function(node) {
if (node.get('checked')) {
selected_permissions[info_type.value] = node.get('value');
@@ -295,7 +295,7 @@
// Disable the radio buttons 'Some' for selected info types.
var disable_some_button = function(info_type) {
var selector =
- 'input[name=field.permission.' + info_type + '][value=SOME]';
+ 'input[name="field.permission.' + info_type + '"][value="SOME"]';
policies.all(selector).each(function(permission_node) {
permission_node.set('disabled', true);
permission_node.set(
=== modified file 'lib/lp/registry/javascript/sharing/granteetable.js'
--- lib/lp/registry/javascript/sharing/granteetable.js 2012-07-26 20:29:27 +0000
+++ lib/lp/registry/javascript/sharing/granteetable.js 2012-08-14 16:26:19 +0000
@@ -234,10 +234,10 @@
});
var id = 'permission-'+grantee.name;
- var grantee_row = this.get('grantee_table').one('[id=' + id + ']');
- var permission_node = grantee_row.one('[id=td-' + id + ']');
+ var grantee_row = this.get('grantee_table').one('[id="' + id + '"]');
+ var permission_node = grantee_row.one('[id="td-' + id + '"]');
var contentBox = permission_node.one(
- '[id=' + policy + '-' + id + ']');
+ '[id="' + policy + '-' + id + '"]');
var value_location = contentBox.one('.value');
var editicon = permission_node.one('a.editicon');
=== modified file 'lib/lp/registry/javascript/sharing/tests/test_granteetable.js'
--- lib/lp/registry/javascript/sharing/tests/test_granteetable.js 2012-07-21 03:04:06 +0000
+++ lib/lp/registry/javascript/sharing/tests/test_granteetable.js 2012-08-14 16:26:19 +0000
@@ -127,8 +127,8 @@
// The given grantee is correctly rendered.
_test_grantee_rendered: function(grantee) {
// The grantee row
- var grantee_row = Y.one('#grantee-table tr[id=permission-'
- + grantee.name + ']');
+ var grantee_row = Y.one('#grantee-table tr[id="permission-'
+ + grantee.name + '"]');
Y.Assert.isNotNull(grantee_row);
// The sprite or branding icon.
if (Y.Lang.isValue(grantee.icon_url)) {
@@ -139,20 +139,20 @@
}
// The update link
Y.Assert.isNotNull(
- Y.one('#grantee-table span[id=update-'
- + grantee.name + '] a'));
+ Y.one('#grantee-table span[id="update-'
+ + grantee.name + '"] a'));
// The delete link
Y.Assert.isNotNull(
- Y.one('#grantee-table span[id=remove-'
- + grantee.name + '] a'));
+ Y.one('#grantee-table span[id="remove-'
+ + grantee.name + '"] a'));
// The sharing permissions
var self = this;
Y.each(grantee.permissions, function(permission, info_type) {
var permission_node =
- Y.one('#grantee-table td[id=td-permission-'
- + grantee.name + '] ul li '
- + 'span[id=' + info_type + '-permission-'
- + grantee.name + '] span.value');
+ Y.one('#grantee-table td[id="td-permission-'
+ + grantee.name + '"] ul li '
+ + 'span[id="' + info_type + '-permission-'
+ + grantee.name + '"] span.value');
Y.Assert.isNotNull(permission_node);
var expected_content =
self.information_types[info_type] + ': ' +
@@ -165,7 +165,7 @@
if (grantee.shared_items_exist) {
Y.Assert.isNotNull(
shared_items_cell.one(
- 'a[href=+sharing/' + grantee.name + ']'));
+ 'a[href="+sharing/' + grantee.name + '"]'));
} else {
Y.Assert.areEqual(
'No items shared through subscriptions.',
@@ -201,7 +201,7 @@
}
);
var update_link_to_click =
- Y.one('#grantee-table span[id=update-fred] a');
+ Y.one('#grantee-table span[id="update-fred"] a');
update_link_to_click.simulate('click');
Y.Assert.isTrue(event_fired);
},
@@ -252,7 +252,7 @@
}
);
var delete_link_to_click =
- Y.one('#grantee-table span[id=remove-fred] a');
+ Y.one('#grantee-table span[id="remove-fred"] a');
delete_link_to_click.simulate('click');
Y.Assert.isTrue(event_fired);
},
@@ -286,10 +286,10 @@
}
);
var permission_popup =
- Y.one('#grantee-table span[id=P1-permission-fred] a');
+ Y.one('#grantee-table span[id="P1-permission-fred"] a');
permission_popup.simulate('click');
var permission_choice = Y.one(
- '.yui3-ichoicelist-content a[href=#s2]');
+ '.yui3-ichoicelist-content a[href="#s2"]');
permission_choice.simulate('click');
Y.Assert.isTrue(event_fired);
},
@@ -378,7 +378,7 @@
// A named grantee operation error is displayed correctly.
this.grantee_table = this._create_Widget();
this.grantee_table.render();
- var row_fred = Y.one('#grantee-table tr[id=permission-fred]');
+ var row_fred = Y.one('#grantee-table tr[id="permission-fred"]');
var success = false;
Y.lp.app.errors.display_error = function(flash_node, msg) {
Y.Assert.areEqual(row_fred, flash_node);
Follow ups