Merge lp:~nigelbabu/launchpad/js-regression-849121 into lp:launchpad

Proposed by Nigel Babu
Status: Merged
Merged at revision: 13979
Proposed branch: lp:~nigelbabu/launchpad/js-regression-849121
Merge into: lp:launchpad
Diff against target: 92 lines (+56/-1)
2 files modified
lib/lp/app/javascript/lp-links.js (+3/-0)
lib/lp/app/javascript/tests/test_lp_links.js (+53/-1)
To merge this branch: bzr merge lp:~nigelbabu/launchpad/js-regression-849121
Reviewer Review Type Date Requested Status
William Grant (community) code Approve
Review via email: mp+75858@code.launchpad.net

Commit message

Fixes the lp-links edge case of having no branches or no bugs. Added more tests to catch the edge cases.

Description of the change

= Description =
Fixes the JavaScript edge case of having no branches or no bugs. Added more javascript tests to catch the edge cases.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/lp-links.js
  lib/lp/app/javascript/tests/test_lp_links.js

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Seems to work. Thanks.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/app/javascript/lp-links.js'
--- lib/lp/app/javascript/lp-links.js 2011-09-15 19:10:53 +0000
+++ lib/lp/app/javascript/lp-links.js 2011-09-17 16:09:23 +0000
@@ -28,6 +28,9 @@
28 // We have a collection of valid and invalid links containing links of28 // We have a collection of valid and invalid links containing links of
29 // type link_type, so we need to remove the existing link_class,29 // type link_type, so we need to remove the existing link_class,
30 // replace it with an invalid-link class, and set the link title.30 // replace it with an invalid-link class, and set the link title.
31 if(!Y.Lang.isValue(link_info[link_type])) {
32 return;
33 }
31 var invalid_links = link_info[link_type].invalid || {};34 var invalid_links = link_info[link_type].invalid || {};
32 var valid_links = link_info[link_type].valid || {};35 var valid_links = link_info[link_type].valid || {};
3336
3437
=== modified file 'lib/lp/app/javascript/tests/test_lp_links.js'
--- lib/lp/app/javascript/tests/test_lp_links.js 2011-09-15 15:34:13 +0000
+++ lib/lp/app/javascript/tests/test_lp_links.js 2011-09-17 16:09:23 +0000
@@ -8,7 +8,7 @@
8 var mock_io = new Y.lp.testing.mockio.MockIo();8 var mock_io = new Y.lp.testing.mockio.MockIo();
99
10 suite.add(new Y.Test.Case({10 suite.add(new Y.Test.Case({
11 name: 'test_bugs',11 name: 'test_bugs_branches',
1212
13 setUp: function() {13 setUp: function() {
14 links.check_valid_lp_links(mock_io);14 links.check_valid_lp_links(mock_io);
@@ -30,6 +30,41 @@
30 });30 });
31 },31 },
3232
33 test_bugs_branches: function () {
34 var validbug = Y.one('#valid-bug');
35 var invalidbug = Y.one('#invalid-bug');
36 var validbranch = Y.one('#valid-branch');
37 var invalidbranch = Y.one('#invalid-branch');
38 Y.Assert.isTrue(validbug.hasClass('bug-link'));
39 Y.Assert.isTrue(invalidbug.hasClass('invalid-link'));
40 Y.Assert.areSame(
41 'jokosher exposes personal details in its actions portlet',
42 validbug.get('title')
43 );
44 Y.Assert.isTrue(validbranch.hasClass('branch-short-link'));
45 Y.Assert.isTrue(invalidbranch.hasClass('invalid-link'));
46 }
47 }));
48
49 suite.add(new Y.Test.Case({
50 name: 'test_bugs',
51
52 setUp: function() {
53 links.check_valid_lp_links(mock_io);
54 var response = {
55 "bug_links": {
56 "valid": {
57 "/bugs/14": [
58 "jokosher exposes personal details ",
59 "in its actions portlet"].join('')},
60 "invalid": {
61 "/bugs/200": "Bug 200 cannot be found"}}};
62 mock_io.success({
63 responseText: Y.JSON.stringify(response),
64 responseHeaders: {'Content-type': 'application/json'}
65 });
66 },
67
33 test_bugs: function () {68 test_bugs: function () {
34 var validbug = Y.one('#valid-bug');69 var validbug = Y.one('#valid-bug');
35 var invalidbug = Y.one('#invalid-bug');70 var invalidbug = Y.one('#invalid-bug');
@@ -39,6 +74,23 @@
39 'jokosher exposes personal details in its actions portlet',74 'jokosher exposes personal details in its actions portlet',
40 validbug.get('title')75 validbug.get('title')
41 );76 );
77 }
78 }));
79
80 suite.add(new Y.Test.Case({
81 name: 'test_bugs',
82
83 setUp: function() {
84 links.check_valid_lp_links(mock_io);
85 var response = {
86 "branch_links": {
87 "invalid": {
88 "/+branch/invalid":
89 "No such product: 'invalid'."}}};
90 mock_io.success({
91 responseText: Y.JSON.stringify(response),
92 responseHeaders: {'Content-type': 'application/json'}
93 });
42 },94 },
4395
44 test_branch: function () {96 test_branch: function () {