Merge lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor into lp:launchpad
- localpackagediffs-filter-by-package-set-bug-809786-refactor
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Gavin Panella |
Approved revision: | no longer in the source branch. |
Merged at revision: | 13461 |
Proposed branch: | lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor |
Merge into: | lp:launchpad |
Diff against target: |
518 lines (+171/-88) 6 files modified
Makefile (+11/-5) lib/lp/app/javascript/testing/testrunner.js (+29/-0) lib/lp/registry/browser/distroseries.py (+4/-0) lib/lp/registry/javascript/distroseries.initseries.js (+55/-30) lib/lp/registry/javascript/tests/test_distroseries.initseries.html (+29/-16) lib/lp/registry/javascript/tests/test_distroseries.initseries.js (+43/-37) |
To merge this branch: | bzr merge lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+68233@code.launchpad.net |
Commit message
[r=benji][bug=809786] Refactor some DistroSeries JavaScript and add a declarative approach for running YUI tests.
Description of the change
This moves a few DistroSeries related bits of JavaScript around and
fixes some lint. The only thing that really needs reviewing is the new
code in lib/lp/
/**
* Merely loading this script into a page will cause it to look for a
* list of suites in the document using the selector ul#suites>li. If
* found, the text within each node is considered to be a test module
* name. This is then loaded, and its "suite" property passed to
* Runner.run().
*
* Here's how to declare the suites to run:
*
* <ul id="suites">
* <li>lp.
* </ul>
*
*/
The test is then declared as a regular YUI module instead of
containing test run code.
Preview Diff
1 | === modified file 'Makefile' | |||
2 | --- Makefile 2011-07-15 15:55:34 +0000 | |||
3 | +++ Makefile 2011-07-18 11:54:37 +0000 | |||
4 | @@ -25,11 +25,15 @@ | |||
5 | 25 | JS_BUILD := min | 25 | JS_BUILD := min |
6 | 26 | endif | 26 | endif |
7 | 27 | 27 | ||
10 | 28 | JS_SOURCE_PATHS = -path './lib/lp/*/javascript/*' ! -path '*/tests/*' \ | 28 | define JS_LP_PATHS |
11 | 29 | ! -path '*/testing/*' ! -path './lib/lp/services/*' | 29 | lib -path 'lib/lp/*/javascript/*' \ |
12 | 30 | ! -path '*/tests/*' ! -path '*/testing/*' \ | ||
13 | 31 | ! -path 'lib/lp/services/*' | ||
14 | 32 | endef | ||
15 | 33 | |||
16 | 30 | JS_YUI := $(shell utilities/yui-deps.py $(JS_BUILD:raw=)) | 34 | JS_YUI := $(shell utilities/yui-deps.py $(JS_BUILD:raw=)) |
17 | 31 | JS_OTHER := $(wildcard lib/canonical/launchpad/javascript/*/*.js) | 35 | JS_OTHER := $(wildcard lib/canonical/launchpad/javascript/*/*.js) |
19 | 32 | JS_LP := $(shell find $(JS_SOURCE_PATHS) -name '*.js' ! -name '.*.js' ) | 36 | JS_LP := $(shell find $(JS_LP_PATHS) -name '*.js') |
20 | 33 | JS_ALL := $(JS_YUI) $(JS_OTHER) $(JS_LP) | 37 | JS_ALL := $(JS_YUI) $(JS_OTHER) $(JS_LP) |
21 | 34 | JS_OUT := $(LP_BUILT_JS_ROOT)/launchpad.js | 38 | JS_OUT := $(LP_BUILT_JS_ROOT)/launchpad.js |
22 | 35 | 39 | ||
23 | @@ -164,7 +168,7 @@ | |||
24 | 164 | 168 | ||
25 | 165 | jsbuild_widget_css: bin/jsbuild | 169 | jsbuild_widget_css: bin/jsbuild |
26 | 166 | ${SHHH} bin/jsbuild \ | 170 | ${SHHH} bin/jsbuild \ |
28 | 167 | --srcdir lib/lp/app/javascript \ | 171 | --srcdir lib/lp/app/javascript \ |
29 | 168 | --builddir $(LP_BUILT_JS_ROOT) | 172 | --builddir $(LP_BUILT_JS_ROOT) |
30 | 169 | 173 | ||
31 | 170 | $(JS_LP): jsbuild_widget_css | 174 | $(JS_LP): jsbuild_widget_css |
32 | @@ -425,7 +429,9 @@ | |||
33 | 425 | copy-apache-config: | 429 | copy-apache-config: |
34 | 426 | # We insert the absolute path to the branch-rewrite script | 430 | # We insert the absolute path to the branch-rewrite script |
35 | 427 | # into the Apache config as we copy the file into position. | 431 | # into the Apache config as we copy the file into position. |
37 | 428 | sed -e 's,%BRANCH_REWRITE%,$(shell pwd)/scripts/branch-rewrite.py,' configs/development/local-launchpad-apache > /etc/apache2/sites-available/local-launchpad | 432 | sed -e 's,%BRANCH_REWRITE%,$(shell pwd)/scripts/branch-rewrite.py,' \ |
38 | 433 | configs/development/local-launchpad-apache > \ | ||
39 | 434 | /etc/apache2/sites-available/local-launchpad | ||
40 | 429 | cp configs/development/local-vostok-apache \ | 435 | cp configs/development/local-vostok-apache \ |
41 | 430 | /etc/apache2/sites-available/local-vostok | 436 | /etc/apache2/sites-available/local-vostok |
42 | 431 | touch /var/tmp/bazaar.launchpad.dev/rewrite.log | 437 | touch /var/tmp/bazaar.launchpad.dev/rewrite.log |
43 | 432 | 438 | ||
44 | === modified file 'lib/lp/app/javascript/testing/testrunner.js' | |||
45 | --- lib/lp/app/javascript/testing/testrunner.js 2011-07-08 06:06:15 +0000 | |||
46 | +++ lib/lp/app/javascript/testing/testrunner.js 2011-07-18 11:54:37 +0000 | |||
47 | @@ -39,3 +39,32 @@ | |||
48 | 39 | }; | 39 | }; |
49 | 40 | 40 | ||
50 | 41 | }, "0.1", {"requires": ["oop", "test", "console"]}); | 41 | }, "0.1", {"requires": ["oop", "test", "console"]}); |
51 | 42 | |||
52 | 43 | |||
53 | 44 | /** | ||
54 | 45 | * Merely loading this script into a page will cause it to look for a | ||
55 | 46 | * list of suites in the document using the selector ul#suites>li. If | ||
56 | 47 | * found, the text within each node is considered to be a test module | ||
57 | 48 | * name. This is then loaded, and its "suite" property passed to | ||
58 | 49 | * Runner.run(). | ||
59 | 50 | * | ||
60 | 51 | * Here's how to declare the suites to run: | ||
61 | 52 | * | ||
62 | 53 | * <ul id="suites"> | ||
63 | 54 | * <li>lp.registry.distroseries.initseries.test</li> | ||
64 | 55 | * </ul> | ||
65 | 56 | * | ||
66 | 57 | */ | ||
67 | 58 | YUI().use("event", function(Y) { | ||
68 | 59 | Y.on("domready", function() { | ||
69 | 60 | var suites = Y.all("ul#suites > li"); | ||
70 | 61 | Y.each(suites, function(suite_node) { | ||
71 | 62 | var suite_name = suite_node.get("text"); | ||
72 | 63 | Y.use("lp.testing.runner", suite_name, function(y) { | ||
73 | 64 | var module = y, parts = suite_name.split("."); | ||
74 | 65 | while (parts.length > 0) { module = module[parts.shift()]; } | ||
75 | 66 | y.lp.testing.Runner.run(module.suite); | ||
76 | 67 | }); | ||
77 | 68 | }); | ||
78 | 69 | }); | ||
79 | 70 | }); | ||
80 | 42 | 71 | ||
81 | === modified file 'lib/lp/registry/browser/distroseries.py' | |||
82 | --- lib/lp/registry/browser/distroseries.py 2011-07-08 09:06:24 +0000 | |||
83 | +++ lib/lp/registry/browser/distroseries.py 2011-07-18 11:54:37 +0000 | |||
84 | @@ -827,6 +827,8 @@ | |||
85 | 827 | super(DistroSeriesDifferenceBaseView, self).initialize() | 827 | super(DistroSeriesDifferenceBaseView, self).initialize() |
86 | 828 | 828 | ||
87 | 829 | def initialize_sync_label(self, label): | 829 | def initialize_sync_label(self, label): |
88 | 830 | # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers | ||
89 | 831 | # are running single threaded... | ||
90 | 830 | self.__class__.actions.byname['actions.sync'].label = label | 832 | self.__class__.actions.byname['actions.sync'].label = label |
91 | 831 | 833 | ||
92 | 832 | @property | 834 | @property |
93 | @@ -861,6 +863,8 @@ | |||
94 | 861 | SimpleTerm(diff, diff.id) | 863 | SimpleTerm(diff, diff.id) |
95 | 862 | for diff in self.cached_differences.batch] | 864 | for diff in self.cached_differences.batch] |
96 | 863 | diffs_vocabulary = SimpleVocabulary(terms) | 865 | diffs_vocabulary = SimpleVocabulary(terms) |
97 | 866 | # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers | ||
98 | 867 | # are running single threaded... | ||
99 | 864 | choice = self.form_fields['selected_differences'].field.value_type | 868 | choice = self.form_fields['selected_differences'].field.value_type |
100 | 865 | choice.vocabulary = diffs_vocabulary | 869 | choice.vocabulary = diffs_vocabulary |
101 | 866 | 870 | ||
102 | 867 | 871 | ||
103 | === renamed file 'lib/lp/registry/javascript/distroseries.js' => 'lib/lp/registry/javascript/distroseries.initseries.js' | |||
104 | --- lib/lp/registry/javascript/distroseries.js 2011-06-27 17:04:27 +0000 | |||
105 | +++ lib/lp/registry/javascript/distroseries.initseries.js 2011-07-18 11:54:37 +0000 | |||
106 | @@ -22,7 +22,9 @@ | |||
107 | 22 | * | 22 | * |
108 | 23 | * @class FormRowWidget | 23 | * @class FormRowWidget |
109 | 24 | */ | 24 | */ |
111 | 25 | var FormRowWidget = function() { | 25 | var FormRowWidget; |
112 | 26 | |||
113 | 27 | FormRowWidget = function() { | ||
114 | 26 | FormRowWidget.superclass.constructor.apply(this, arguments); | 28 | FormRowWidget.superclass.constructor.apply(this, arguments); |
115 | 27 | }; | 29 | }; |
116 | 28 | 30 | ||
117 | @@ -166,7 +168,9 @@ | |||
118 | 166 | * can also be made an overlay, and a component and a pocket selected. | 168 | * can also be made an overlay, and a component and a pocket selected. |
119 | 167 | * | 169 | * |
120 | 168 | */ | 170 | */ |
122 | 169 | var ParentSeriesListWidget = function() { | 171 | var ParentSeriesListWidget; |
123 | 172 | |||
124 | 173 | ParentSeriesListWidget = function() { | ||
125 | 170 | ParentSeriesListWidget | 174 | ParentSeriesListWidget |
126 | 171 | .superclass.constructor.apply(this, arguments); | 175 | .superclass.constructor.apply(this, arguments); |
127 | 172 | }; | 176 | }; |
128 | @@ -466,7 +470,9 @@ | |||
129 | 466 | * | 470 | * |
130 | 467 | * @class ChoiceListWidget | 471 | * @class ChoiceListWidget |
131 | 468 | */ | 472 | */ |
133 | 469 | var ChoiceListWidget = function() { | 473 | var ChoiceListWidget; |
134 | 474 | |||
135 | 475 | ChoiceListWidget = function() { | ||
136 | 470 | ChoiceListWidget.superclass.constructor.apply(this, arguments); | 476 | ChoiceListWidget.superclass.constructor.apply(this, arguments); |
137 | 471 | }; | 477 | }; |
138 | 472 | 478 | ||
139 | @@ -660,7 +666,9 @@ | |||
140 | 660 | * | 666 | * |
141 | 661 | * @class ArchitecturesChoiceListWidget | 667 | * @class ArchitecturesChoiceListWidget |
142 | 662 | */ | 668 | */ |
144 | 663 | var ArchitecturesChoiceListWidget = function() { | 669 | var ArchitecturesChoiceListWidget; |
145 | 670 | |||
146 | 671 | ArchitecturesChoiceListWidget = function() { | ||
147 | 664 | ArchitecturesChoiceListWidget | 672 | ArchitecturesChoiceListWidget |
148 | 665 | .superclass.constructor.apply(this, arguments); | 673 | .superclass.constructor.apply(this, arguments); |
149 | 666 | }; | 674 | }; |
150 | @@ -726,14 +734,15 @@ | |||
151 | 726 | */ | 734 | */ |
152 | 727 | remove_distroseries: function(distroseries_id) { | 735 | remove_distroseries: function(distroseries_id) { |
153 | 728 | // Compute which das is only in the distroseries to be removed. | 736 | // Compute which das is only in the distroseries to be removed. |
155 | 729 | arch_to_remove = []; | 737 | var arch_to_remove = []; |
156 | 730 | var das = this._distroseries[distroseries_id]; | 738 | var das = this._distroseries[distroseries_id]; |
157 | 731 | var i, ds, j; | 739 | var i, ds, j; |
158 | 732 | for (i=0; i<das.entries.length; i++) { | 740 | for (i=0; i<das.entries.length; i++) { |
161 | 733 | remove_das = true; | 741 | var remove_das = true; |
162 | 734 | arch = das.entries[i].get('architecture_tag'); | 742 | var arch = das.entries[i].get('architecture_tag'); |
163 | 735 | for (ds in this._distroseries) { | 743 | for (ds in this._distroseries) { |
165 | 736 | if (ds !== distroseries_id) { | 744 | if (this._distroseries.hasOwnProperty(ds) && |
166 | 745 | ds !== distroseries_id) { | ||
167 | 737 | var other_das = this._distroseries[ds]; | 746 | var other_das = this._distroseries[ds]; |
168 | 738 | for (j=0; j<other_das.entries.length; j++) { | 747 | for (j=0; j<other_das.entries.length; j++) { |
169 | 739 | var other_arch = other_das.entries[j].get( | 748 | var other_arch = other_das.entries[j].get( |
170 | @@ -782,7 +791,9 @@ | |||
171 | 782 | * | 791 | * |
172 | 783 | * @class SelectWidget | 792 | * @class SelectWidget |
173 | 784 | */ | 793 | */ |
175 | 785 | var SelectWidget = function() { | 794 | var SelectWidget; |
176 | 795 | |||
177 | 796 | SelectWidget = function() { | ||
178 | 786 | SelectWidget.superclass.constructor.apply(this, arguments); | 797 | SelectWidget.superclass.constructor.apply(this, arguments); |
179 | 787 | }; | 798 | }; |
180 | 788 | 799 | ||
181 | @@ -949,7 +960,9 @@ | |||
182 | 949 | * | 960 | * |
183 | 950 | * @class PackagesetPickerWidget | 961 | * @class PackagesetPickerWidget |
184 | 951 | */ | 962 | */ |
186 | 952 | var PackagesetPickerWidget = function() { | 963 | var PackagesetPickerWidget; |
187 | 964 | |||
188 | 965 | PackagesetPickerWidget = function() { | ||
189 | 953 | PackagesetPickerWidget | 966 | PackagesetPickerWidget |
190 | 954 | .superclass.constructor.apply(this, arguments); | 967 | .superclass.constructor.apply(this, arguments); |
191 | 955 | }; | 968 | }; |
192 | @@ -1144,7 +1157,9 @@ | |||
193 | 1144 | * | 1157 | * |
194 | 1145 | * @class FormActionsWidget | 1158 | * @class FormActionsWidget |
195 | 1146 | */ | 1159 | */ |
197 | 1147 | var FormActionsWidget = function() { | 1160 | var FormActionsWidget; |
198 | 1161 | |||
199 | 1162 | FormActionsWidget = function() { | ||
200 | 1148 | FormActionsWidget | 1163 | FormActionsWidget |
201 | 1149 | .superclass.constructor.apply(this, arguments); | 1164 | .superclass.constructor.apply(this, arguments); |
202 | 1150 | }; | 1165 | }; |
203 | @@ -1234,7 +1249,9 @@ | |||
204 | 1234 | * | 1249 | * |
205 | 1235 | * @class DeriveDistroSeriesActionsWidget | 1250 | * @class DeriveDistroSeriesActionsWidget |
206 | 1236 | */ | 1251 | */ |
208 | 1237 | var DeriveDistroSeriesActionsWidget = function() { | 1252 | var DeriveDistroSeriesActionsWidget; |
209 | 1253 | |||
210 | 1254 | DeriveDistroSeriesActionsWidget = function() { | ||
211 | 1238 | DeriveDistroSeriesActionsWidget | 1255 | DeriveDistroSeriesActionsWidget |
212 | 1239 | .superclass.constructor.apply(this, arguments); | 1256 | .superclass.constructor.apply(this, arguments); |
213 | 1240 | }; | 1257 | }; |
214 | @@ -1333,7 +1350,8 @@ | |||
215 | 1333 | add_parent_series(result); | 1350 | add_parent_series(result); |
216 | 1334 | }; | 1351 | }; |
217 | 1335 | 1352 | ||
219 | 1336 | parent_picker = Y.lp.app.picker.create('DistroSeriesDerivation', config); | 1353 | var parent_picker = |
220 | 1354 | Y.lp.app.picker.create('DistroSeriesDerivation', config); | ||
221 | 1337 | parent_picker.show(); | 1355 | parent_picker.show(); |
222 | 1338 | }; | 1356 | }; |
223 | 1339 | 1357 | ||
224 | @@ -1354,17 +1372,21 @@ | |||
225 | 1354 | * | 1372 | * |
226 | 1355 | * @function setup | 1373 | * @function setup |
227 | 1356 | */ | 1374 | */ |
231 | 1357 | namespace.setup = function() { | 1375 | namespace.setup = function(cache) { |
232 | 1358 | var form_actions = namespace.setupWidgets(); | 1376 | var form_actions = namespace.setupWidgets(cache); |
233 | 1359 | namespace.setupInteraction(form_actions); | 1377 | namespace.setupInteraction(form_actions, cache); |
234 | 1360 | }; | 1378 | }; |
235 | 1361 | 1379 | ||
236 | 1362 | /** | 1380 | /** |
237 | 1363 | * Setup the widgets objects and return the form object. | 1381 | * Setup the widgets objects and return the form object. |
238 | 1364 | * | 1382 | * |
239 | 1365 | * @function setupWidgets | 1383 | * @function setupWidgets |
240 | 1384 | * @param {Object} cache Specify the value cache to use. If not | ||
241 | 1385 | * specified, LP.cache is used. Intended chiefly for testing. | ||
242 | 1366 | */ | 1386 | */ |
244 | 1367 | namespace.setupWidgets = function() { | 1387 | namespace.setupWidgets = function(cache) { |
245 | 1388 | if (cache === undefined) { cache = LP.cache; } | ||
246 | 1389 | |||
247 | 1368 | var form_container = Y.one("#initseries-form-container"); | 1390 | var form_container = Y.one("#initseries-form-container"); |
248 | 1369 | var form_table = form_container.one("table.form"); | 1391 | var form_table = form_container.one("table.form"); |
249 | 1370 | var form_table_body = form_table.append(Y.Node.create('<tbody />')); | 1392 | var form_table_body = form_table.append(Y.Node.create('<tbody />')); |
250 | @@ -1394,7 +1416,7 @@ | |||
251 | 1394 | "architectures).")) | 1416 | "architectures).")) |
252 | 1395 | .render(form_table_body); | 1417 | .render(form_table_body); |
253 | 1396 | var packageset_choice = null; | 1418 | var packageset_choice = null; |
255 | 1397 | if (LP.cache['is_first_derivation']) { | 1419 | if (cache.is_first_derivation) { |
256 | 1398 | packageset_choice = | 1420 | packageset_choice = |
257 | 1399 | new PackagesetPickerWidget() | 1421 | new PackagesetPickerWidget() |
258 | 1400 | .set("name", "field.packagesets") | 1422 | .set("name", "field.packagesets") |
259 | @@ -1424,7 +1446,7 @@ | |||
260 | 1424 | .render(form_table_body); | 1446 | .render(form_table_body); |
261 | 1425 | var form_actions = | 1447 | var form_actions = |
262 | 1426 | new DeriveDistroSeriesActionsWidget({ | 1448 | new DeriveDistroSeriesActionsWidget({ |
264 | 1427 | context: LP.cache.context, | 1449 | context: cache.context, |
265 | 1428 | srcNode: form_container.one("div.actions"), | 1450 | srcNode: form_container.one("div.actions"), |
266 | 1429 | deriveFromChoices: parents_selection, | 1451 | deriveFromChoices: parents_selection, |
267 | 1430 | architectureChoice: architecture_choice, | 1452 | architectureChoice: architecture_choice, |
268 | @@ -1440,10 +1462,14 @@ | |||
269 | 1440 | * Setup the interaction between the widgets. | 1462 | * Setup the interaction between the widgets. |
270 | 1441 | * | 1463 | * |
271 | 1442 | * @function setupInteraction | 1464 | * @function setupInteraction |
274 | 1443 | * @param {DeriveDistroSeriesActionsWidget} The form widget containing all | 1465 | * @param {DeriveDistroSeriesActionsWidget} The form widget containing |
275 | 1444 | * the other widgets. | 1466 | * all the other widgets. |
276 | 1467 | * @param {Object} cache Specify the value cache to use. If not | ||
277 | 1468 | * specified, LP.cache is used. Intended chiefly for testing. | ||
278 | 1445 | */ | 1469 | */ |
280 | 1446 | namespace.setupInteraction = function(form_actions) { | 1470 | namespace.setupInteraction = function(form_actions, cache) { |
281 | 1471 | if (cache === undefined) { cache = LP.cache; } | ||
282 | 1472 | |||
283 | 1447 | // Wire up the add parent series link. | 1473 | // Wire up the add parent series link. |
284 | 1448 | var link = Y.one('#add-parent-series'); | 1474 | var link = Y.one('#add-parent-series'); |
285 | 1449 | if (Y.Lang.isValue(link)) { | 1475 | if (Y.Lang.isValue(link)) { |
286 | @@ -1458,7 +1484,7 @@ | |||
287 | 1458 | } | 1484 | } |
288 | 1459 | }); | 1485 | }); |
289 | 1460 | 1486 | ||
291 | 1461 | if (LP.cache['is_first_derivation']) { | 1487 | if (cache.is_first_derivation) { |
292 | 1462 | // Wire the architecture and packageset pickers to the parent picker. | 1488 | // Wire the architecture and packageset pickers to the parent picker. |
293 | 1463 | Y.on('parent_added', function(parent) { | 1489 | Y.on('parent_added', function(parent) { |
294 | 1464 | form_actions.architectureChoice.add_distroseries(parent); | 1490 | form_actions.architectureChoice.add_distroseries(parent); |
295 | @@ -1471,7 +1497,7 @@ | |||
296 | 1471 | }); | 1497 | }); |
297 | 1472 | } | 1498 | } |
298 | 1473 | else { | 1499 | else { |
300 | 1474 | // Disable rebuilding if LP.cache['is_first_derivation'] is false. | 1500 | // Disable rebuilding if cache.is_first_derivation is false. |
301 | 1475 | form_actions.packageCopyOptions.fieldNode | 1501 | form_actions.packageCopyOptions.fieldNode |
302 | 1476 | .one('input[value="Copy Source and Rebuild"]') | 1502 | .one('input[value="Copy Source and Rebuild"]') |
303 | 1477 | .set('disabled', 'disabled'); | 1503 | .set('disabled', 'disabled'); |
304 | @@ -1485,13 +1511,12 @@ | |||
305 | 1485 | "if you want to use all the available " + | 1511 | "if you want to use all the available " + |
306 | 1486 | "architectures).")); | 1512 | "architectures).")); |
307 | 1487 | form_actions.architectureChoice.add_distroseries( | 1513 | form_actions.architectureChoice.add_distroseries( |
309 | 1488 | LP.cache['previous_series']); | 1514 | cache.previous_series); |
310 | 1489 | // Setup the pre-selected parents (parents from the previous series). | 1515 | // Setup the pre-selected parents (parents from the previous series). |
316 | 1490 | var index; | 1516 | Y.each( |
317 | 1491 | for (index in LP.cache['previous_parents']) { | 1517 | cache.previous_parents, |
318 | 1492 | form_actions.deriveFromChoices.add_parent( | 1518 | form_actions.deriveFromChoices.add_parent, |
319 | 1493 | LP.cache['previous_parents'][index]); | 1519 | form_actions.deriveFromChoices); |
315 | 1494 | } | ||
320 | 1495 | } | 1520 | } |
321 | 1496 | 1521 | ||
322 | 1497 | // Wire up the form submission. | 1522 | // Wire up the form submission. |
323 | 1498 | 1523 | ||
324 | === renamed file 'lib/lp/registry/javascript/tests/test_distroseries.html' => 'lib/lp/registry/javascript/tests/test_distroseries.initseries.html' | |||
325 | --- lib/lp/registry/javascript/tests/test_distroseries.html 2011-07-08 06:06:15 +0000 | |||
326 | +++ lib/lp/registry/javascript/tests/test_distroseries.initseries.html 2011-07-18 11:54:37 +0000 | |||
327 | @@ -6,27 +6,40 @@ | |||
328 | 6 | <title>Launchpad DistroSeries</title> | 6 | <title>Launchpad DistroSeries</title> |
329 | 7 | 7 | ||
330 | 8 | <!-- YUI and test setup --> | 8 | <!-- YUI and test setup --> |
331 | 9 | <script type="text/javascript" | ||
332 | 10 | src="../../../../canonical/launchpad/icing/yui/yui/yui.js"> | ||
333 | 11 | </script> | ||
334 | 12 | <link rel="stylesheet" href="../../../app/javascript/testing/test.css" /> | 9 | <link rel="stylesheet" href="../../../app/javascript/testing/test.css" /> |
335 | 13 | <script type="text/javascript" | 10 | <script type="text/javascript" |
336 | 11 | src="../../../../canonical/launchpad/icing/yui/yui/yui.js"></script> | ||
337 | 12 | <script type="text/javascript" | ||
338 | 14 | src="../../../app/javascript/testing/testrunner.js"></script> | 13 | src="../../../app/javascript/testing/testrunner.js"></script> |
339 | 15 | 14 | ||
353 | 16 | <!-- Required modules --> | 15 | <!-- Required modules --> |
354 | 17 | <script type="text/javascript" src="../../../app/javascript/client.js"></script> | 16 | <script type="text/javascript" |
355 | 18 | <script type="text/javascript" src="../../../app/javascript/activator/activator.js"></script> | 17 | src="../../../app/javascript/client.js"></script> |
356 | 19 | <script type="text/javascript" src="../../../app/javascript/anim/anim.js"></script> | 18 | <script type="text/javascript" |
357 | 20 | <script type="text/javascript" src="../../../app/javascript/lazr/lazr.js"></script> | 19 | src="../../../app/javascript/activator/activator.js"></script> |
358 | 21 | <script type="text/javascript" src="../../../app/javascript/overlay/overlay.js"></script> | 20 | <script type="text/javascript" |
359 | 22 | <script type="text/javascript" src="../../../app/javascript/picker/picker.js"></script> | 21 | src="../../../app/javascript/anim/anim.js"></script> |
360 | 23 | <script type="text/javascript" src="../../../app/javascript/picker/person_picker.js"></script> | 22 | <script type="text/javascript" |
361 | 24 | <script type="text/javascript" src="../../../app/javascript/picker/picker_patcher.js"></script> | 23 | src="../../../app/javascript/lazr/lazr.js"></script> |
362 | 25 | <!-- The module under test --> | 24 | <script type="text/javascript" |
363 | 26 | <script type="text/javascript" src="../distroseries.js"></script> | 25 | src="../../../app/javascript/overlay/overlay.js"></script> |
364 | 27 | <!-- The test suite --> | 26 | <script type="text/javascript" |
365 | 28 | <script type="text/javascript" src="test_distroseries.js"></script> | 27 | src="../../../app/javascript/picker/picker.js"></script> |
366 | 28 | <script type="text/javascript" | ||
367 | 29 | src="../../../app/javascript/picker/person_picker.js"></script> | ||
368 | 30 | <script type="text/javascript" | ||
369 | 31 | src="../../../app/javascript/picker/picker_patcher.js"></script> | ||
370 | 32 | |||
371 | 33 | <!-- The module under test --> | ||
372 | 34 | <script type="text/javascript" src="../distroseries.initseries.js"></script> | ||
373 | 35 | |||
374 | 36 | <!-- The test suite --> | ||
375 | 37 | <script type="text/javascript" src="test_distroseries.initseries.js"></script> | ||
376 | 38 | |||
377 | 29 | </head> | 39 | </head> |
378 | 30 | <body class="yui3-skin-sam"> | 40 | <body class="yui3-skin-sam"> |
379 | 41 | <ul id="suites"> | ||
380 | 42 | <li>lp.registry.distroseries.initseries.test</li> | ||
381 | 43 | </ul> | ||
382 | 31 | </body> | 44 | </body> |
383 | 32 | </html> | 45 | </html> |
384 | 33 | 46 | ||
385 | === renamed file 'lib/lp/registry/javascript/tests/test_distroseries.js' => 'lib/lp/registry/javascript/tests/test_distroseries.initseries.js' | |||
386 | --- lib/lp/registry/javascript/tests/test_distroseries.js 2011-07-08 05:39:39 +0000 | |||
387 | +++ lib/lp/registry/javascript/tests/test_distroseries.initseries.js 2011-07-18 11:54:37 +0000 | |||
388 | @@ -1,9 +1,16 @@ | |||
395 | 1 | /* Copyright (c) 2011, Canonical Ltd. All rights reserved. */ | 1 | /** |
396 | 2 | 2 | * Copyright 2011 Canonical Ltd. This software is licensed under the | |
397 | 3 | YUI().use( | 3 | * GNU Affero General Public License version 3 (see the file LICENSE). |
398 | 4 | 'lp.testing.runner', 'test', 'console', 'node-event-simulate', | 4 | * |
399 | 5 | 'lp.registry.distroseries.initseries', | 5 | * Tests for DistroSeries related stuff. |
400 | 6 | function(Y) { | 6 | * |
401 | 7 | * @module lp.registry.distroseries | ||
402 | 8 | * @submodule test | ||
403 | 9 | */ | ||
404 | 10 | |||
405 | 11 | YUI.add('lp.registry.distroseries.initseries.test', function(Y) { | ||
406 | 12 | |||
407 | 13 | var namespace = Y.namespace('lp.registry.distroseries.initseries.test'); | ||
408 | 7 | 14 | ||
409 | 8 | var Assert = Y.Assert; | 15 | var Assert = Y.Assert; |
410 | 9 | var ArrayAssert = Y.ArrayAssert; | 16 | var ArrayAssert = Y.ArrayAssert; |
411 | @@ -440,6 +447,7 @@ | |||
412 | 440 | }, | 447 | }, |
413 | 441 | 448 | ||
414 | 442 | testParentGetter: function() { | 449 | testParentGetter: function() { |
415 | 450 | var parent; | ||
416 | 443 | parent = {value: "4", title: "Hoary", api_uri: "ubuntu/hoary"}; | 451 | parent = {value: "4", title: "Hoary", api_uri: "ubuntu/hoary"}; |
417 | 444 | this.widget.add_parent(parent); | 452 | this.widget.add_parent(parent); |
418 | 445 | parent = {value: "3", title: "Warty", api_uri: "ubuntu/warty"}; | 453 | parent = {value: "3", title: "Warty", api_uri: "ubuntu/warty"}; |
419 | @@ -495,7 +503,7 @@ | |||
420 | 495 | Assert.isFunction(config.on.failure); | 503 | Assert.isFunction(config.on.failure); |
421 | 496 | } | 504 | } |
422 | 497 | }; | 505 | }; |
424 | 498 | distroseries = {api_uri: "ubuntu/hoary", value: 3}; | 506 | var distroseries = {api_uri: "ubuntu/hoary", value: 3}; |
425 | 499 | this.widget.add_distroseries(distroseries); | 507 | this.widget.add_distroseries(distroseries); |
426 | 500 | Assert.isTrue(io, "No IO initiated."); | 508 | Assert.isTrue(io, "No IO initiated."); |
427 | 501 | }, | 509 | }, |
428 | @@ -1056,6 +1064,10 @@ | |||
429 | 1056 | else if (name === "overlay_components") { | 1064 | else if (name === "overlay_components") { |
430 | 1057 | return ['restricted', null]; | 1065 | return ['restricted', null]; |
431 | 1058 | } | 1066 | } |
432 | 1067 | else { | ||
433 | 1068 | Assert.fail("Unrecognized property: " + name); | ||
434 | 1069 | return null; // Keep lint quiet. | ||
435 | 1070 | } | ||
436 | 1059 | } | 1071 | } |
437 | 1060 | }, | 1072 | }, |
438 | 1061 | architectureChoice: { | 1073 | architectureChoice: { |
439 | @@ -1169,30 +1181,10 @@ | |||
440 | 1169 | Y.one('body').appendChild(node); | 1181 | Y.one('body').appendChild(node); |
441 | 1170 | }, | 1182 | }, |
442 | 1171 | 1183 | ||
443 | 1172 | setUpFirstDerivation: function() { | ||
444 | 1173 | window.LP = {cache: {is_first_derivation: true}}; | ||
445 | 1174 | }, | ||
446 | 1175 | |||
447 | 1176 | setUpNotFirstDerivation: function() { | ||
448 | 1177 | window.LP = {cache: | ||
449 | 1178 | {is_first_derivation: false, | ||
450 | 1179 | previous_series: { | ||
451 | 1180 | api_uri: '/ubuntu/natty', | ||
452 | 1181 | value: '3', | ||
453 | 1182 | title: 'Ubunty: Natty'}, | ||
454 | 1183 | previous_parents: [ | ||
455 | 1184 | {api_uri: '/debian/sid', | ||
456 | 1185 | value: '4', | ||
457 | 1186 | title: 'Debian: Sid'}, | ||
458 | 1187 | {api_uri: '/zz/aa', | ||
459 | 1188 | value: '5', | ||
460 | 1189 | title: 'ZZ: aa'}]}}; | ||
461 | 1190 | }, | ||
462 | 1191 | |||
463 | 1192 | testIsFirstDerivation: function() { | 1184 | testIsFirstDerivation: function() { |
467 | 1193 | this.setUpFirstDerivation(); | 1185 | var cache = {is_first_derivation: true}; |
468 | 1194 | var form_actions = initseries.setupWidgets(); | 1186 | var form_actions = initseries.setupWidgets(cache); |
469 | 1195 | initseries.setupInteraction(form_actions); | 1187 | initseries.setupInteraction(form_actions, cache); |
470 | 1196 | 1188 | ||
471 | 1197 | // No pre-populated parent. | 1189 | // No pre-populated parent. |
472 | 1198 | ArrayAssert.itemsAreEqual( | 1190 | ArrayAssert.itemsAreEqual( |
473 | @@ -1201,8 +1193,21 @@ | |||
474 | 1201 | }, | 1193 | }, |
475 | 1202 | 1194 | ||
476 | 1203 | testIsNotFirstDerivation: function() { | 1195 | testIsNotFirstDerivation: function() { |
479 | 1204 | this.setUpNotFirstDerivation(); | 1196 | var cache = { |
480 | 1205 | var form_actions = initseries.setupWidgets(); | 1197 | is_first_derivation: false, |
481 | 1198 | previous_series: { | ||
482 | 1199 | api_uri: '/ubuntu/natty', | ||
483 | 1200 | value: '3', | ||
484 | 1201 | title: 'Ubunty: Natty' | ||
485 | 1202 | }, | ||
486 | 1203 | previous_parents: [ | ||
487 | 1204 | {api_uri: '/debian/sid', | ||
488 | 1205 | value: '4', title: 'Debian: Sid'}, | ||
489 | 1206 | {api_uri: '/zz/aa', | ||
490 | 1207 | value: '5', title: 'ZZ: aa'} | ||
491 | 1208 | ] | ||
492 | 1209 | }; | ||
493 | 1210 | var form_actions = initseries.setupWidgets(cache); | ||
494 | 1206 | // Monkeypatch LP client. | 1211 | // Monkeypatch LP client. |
495 | 1207 | var client = { | 1212 | var client = { |
496 | 1208 | get: function(path, config) { | 1213 | get: function(path, config) { |
497 | @@ -1220,7 +1225,7 @@ | |||
498 | 1220 | } | 1225 | } |
499 | 1221 | }; | 1226 | }; |
500 | 1222 | form_actions.architectureChoice.client = client; | 1227 | form_actions.architectureChoice.client = client; |
502 | 1223 | initseries.setupInteraction(form_actions); | 1228 | initseries.setupInteraction(form_actions, cache); |
503 | 1224 | 1229 | ||
504 | 1225 | // Parents are populated. | 1230 | // Parents are populated. |
505 | 1226 | ArrayAssert.itemsAreEqual( | 1231 | ArrayAssert.itemsAreEqual( |
506 | @@ -1237,7 +1242,8 @@ | |||
507 | 1237 | }; | 1242 | }; |
508 | 1238 | 1243 | ||
509 | 1239 | suite.add(new Y.Test.Case(testDeriveDistroSeriesSetup)); | 1244 | suite.add(new Y.Test.Case(testDeriveDistroSeriesSetup)); |
514 | 1240 | 1245 | namespace.suite = suite; | |
515 | 1241 | Y.lp.testing.Runner.run(suite); | 1246 | |
516 | 1242 | 1247 | }, "0.1", {"requires": [ | |
517 | 1243 | }); | 1248 | 'test', 'console', 'node-event-simulate', |
518 | 1249 | 'lp.registry.distroseries.initseries']}); |
This branch looks good.