Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/test/data/webui/settings/settings_autofill_section_browsertest.js

Issue 2079853002: Add Edit/Create Address Dialog to MD Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Runs the Polymer Autofill Settings tests. */ 5 /** @fileoverview Runs the Polymer Autofill Settings tests. */
6 6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../'; 8 var ROOT_PATH = '../../../../../';
9 9
10 // Polymer BrowserTest fixture. 10 // Polymer BrowserTest fixture.
11 GEN_INCLUDE([ 11 GEN_INCLUDE([
12 ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js', 12 ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js',
13 ROOT_PATH + 13 ROOT_PATH +
14 'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js', 14 'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js',
15 ROOT_PATH + 'ui/webui/resources/js/load_time_data.js', 15 ROOT_PATH + 'ui/webui/resources/js/load_time_data.js',
16 ]); 16 ]);
17 17
18 /** 18 /**
19 * Test implementation.
20 * @implements {settings.address.CountryDetailManager}
21 * @constructor
22 */
23 function CountryDetailManagerTestImpl() {}
24 CountryDetailManagerTestImpl.prototype = {
25 /** @override */
26 getCountryList: function() {
27 // Fake promise that resolves synchronously.
28 return {
michaelpg 2016/06/27 21:29:18 If this doesn't *have* to be synchronous, use a re
hcarmona 2016/06/28 00:27:10 This is now async. In order to make this async, I
29 then: function(callback) {
30 callback([
31 {name: 'United States', countryCode: 'US'}, // Default test country.
32 {name: 'Israel', countryCode: 'IL'},
33 {name: 'United Kingdom', countryCode: 'GB'},
34 ]);
35 },
36 };
37 },
38
39 /** @override */
40 getAddressFormat: function(countryCode) {
41 return new Promise(function(callback) {
42 chrome.autofillPrivate.getAddressComponents(countryCode, callback);
43 });
44 },
45 };
46
47 /**
48 * Will call |loopBody| for each item in |items|. Will only move to the next
49 * item after the promise from |loopBody| resolves.
50 * @param {!Array<object>} items
michaelpg 2016/06/27 21:29:18 capitalize Object
hcarmona 2016/06/28 00:27:10 Done.
51 * @param {!function(!object):!Promise} loopBody
michaelpg 2016/06/27 21:29:19 capitalize Object
hcarmona 2016/06/28 00:27:11 Done.
52 * @return {!Promise}
53 */
54 function asyncForEach(items, loopBody) {
55 return new Promise(function(finish) {
56 var index = 0;
57 var next;
58
59 function loop() {
60 var item = items[index++];
61 if (item)
62 loopBody(item).then(next);
michaelpg 2016/06/27 21:29:18 i think this can just be then(loop) and we don't n
hcarmona 2016/06/28 00:27:10 Done.
63 else
64 finish();
65 };
66
67 next = loop;
68 loop();
69 });
70 }
71
72 /**
73 * Resolves the promise after the element throws the expected event. Will add
michaelpg 2016/06/27 21:29:19 nit: s/throws/fires, throws implies an error :-)
hcarmona 2016/06/28 00:27:10 Done.
74 * and remove the listener so it is only triggered once. |causeEvent| is called
75 * after adding a listener to make sure that the event is captured.
76 * @param {!Element} element
77 * @param {string} eventName
78 * @param {function():void} causeEvent
79 * @return {!Promise}
80 */
81 function expectEvent(element, eventName, causeEvent) {
82 return new Promise(function(resolve) {
83 var callback = function() {
84 element.removeEventListener(eventName, callback);
85 resolve.apply(this, arguments);
86 };
87 element.addEventListener(eventName, callback);
88 causeEvent();
89 });
90 }
91
92 /**
19 * @constructor 93 * @constructor
20 * @extends {PolymerTest} 94 * @extends {PolymerTest}
21 */ 95 */
22 function SettingsAutofillSectionBrowserTest() {} 96 function SettingsAutofillSectionBrowserTest() {}
23 97
24 SettingsAutofillSectionBrowserTest.prototype = { 98 SettingsAutofillSectionBrowserTest.prototype = {
25 __proto__: PolymerTest.prototype, 99 __proto__: PolymerTest.prototype,
26 100
27 /** @override */ 101 /** @override */
28 browsePreload: 102 browsePreload:
29 'chrome://md-settings/passwords_and_forms_page/autofill_section.html', 103 'chrome://md-settings/passwords_and_forms_page/autofill_section.html',
30 104
31 /** @override */ 105 /** @override */
32 extraLibraries: PolymerTest.getLibraries(ROOT_PATH), 106 extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
33 107
108 i18nStrings: {
109 addAddressTitle: 'add-title',
110 addCreditCardTitle: 'add-title',
111 editAddressTitle: 'edit-title',
112 editCreditCardTitle: 'edit-title',
113 },
114
34 /** @override */ 115 /** @override */
35 setUp: function() { 116 setUp: function() {
36 PolymerTest.prototype.setUp.call(this); 117 PolymerTest.prototype.setUp.call(this);
37 118
38 // Test is run on an individual element that won't have a page language. 119 // Test is run on an individual element that won't have a page language.
39 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); 120 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing');
40 121
41 // Faking 'strings.js' for this test. 122 // Faking 'strings.js' for this test.
42 loadTimeData.data = { 123 loadTimeData.data = this.i18nStrings;
43 editCreditCardTitle: 'edit-title', 124
44 addCreditCardTitle: 'add-title' 125 settings.address.CountryDetailManagerImpl.instance_ =
45 }; 126 new CountryDetailManagerTestImpl();
46 }, 127 },
47 128
48 /** 129 /**
49 * Allow the iron-list to be sized properly. 130 * Allow the iron-list to be sized properly.
50 * @param {!Object} autofillSection 131 * @param {!Object} autofillSection
51 * @private 132 * @private
52 */ 133 */
53 flushAutofillSection_: function(autofillSection) { 134 flushAutofillSection_: function(autofillSection) {
54 autofillSection.$.addressList.notifyResize(); 135 autofillSection.$.addressList.notifyResize();
55 autofillSection.$.creditCardList.notifyResize(); 136 autofillSection.$.creditCardList.notifyResize();
(...skipping 10 matching lines...) Expand all
66 createAutofillSection_: function(addresses, creditCards) { 147 createAutofillSection_: function(addresses, creditCards) {
67 var section = document.createElement('settings-autofill-section'); 148 var section = document.createElement('settings-autofill-section');
68 section.addresses = addresses; 149 section.addresses = addresses;
69 section.creditCards = creditCards; 150 section.creditCards = creditCards;
70 document.body.appendChild(section); 151 document.body.appendChild(section);
71 this.flushAutofillSection_(section); 152 this.flushAutofillSection_(section);
72 return section; 153 return section;
73 }, 154 },
74 155
75 /** 156 /**
157 * Creates the Edit Address dialog and fulfills the promise when the dialog
158 * has actually opened.
159 * @param {!chrome.autofillPrivate.AddressEntry} address
160 * @return {!Promise<Object>}
161 */
162 createAddressDialog_: function(address) {
163 return new Promise(function(resolve) {
164 var section = document.createElement('settings-address-edit-dialog');
165 document.body.appendChild(section);
166 var onOpen = function() {
167 resolve(section);
168 };
169 section.addEventListener('iron-overlay-opened', onOpen);
170 section.open(address); // Opening the dialog will add the item.
171 Polymer.dom.flush();
172 });
173 },
174
175 /**
76 * Creates the Edit Credit Card dialog. 176 * Creates the Edit Credit Card dialog.
77 * @param {!chrome.autofillPrivate.CreditCardEntry} creditCardItem 177 * @param {!chrome.autofillPrivate.CreditCardEntry} creditCardItem
78 * @return {!Object} 178 * @return {!Object}
79 */ 179 */
80 createCreditCardDialog_: function(creditCardItem) { 180 createCreditCardDialog_: function(creditCardItem) {
81 var section = document.createElement('settings-credit-card-edit-dialog'); 181 var section = document.createElement('settings-credit-card-edit-dialog');
82 document.body.appendChild(section); 182 document.body.appendChild(section);
83 section.open(creditCardItem); // Opening the dialog will add the item. 183 section.open(creditCardItem); // Opening the dialog will add the item.
84 Polymer.dom.flush(); 184 Polymer.dom.flush();
85 return section; 185 return section;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 done(); 303 done();
204 }); 304 });
205 305
206 MockInteractions.tap(creditCardDialog.$.saveButton); 306 MockInteractions.tap(creditCardDialog.$.saveButton);
207 }), 307 }),
208 308
209 test('verifyCancelCreditCardEdit', function(done) { 309 test('verifyCancelCreditCardEdit', function(done) {
210 var creditCard = FakeDataMaker.emptyCreditCardEntry(); 310 var creditCard = FakeDataMaker.emptyCreditCardEntry();
211 var creditCardDialog = self.createCreditCardDialog_(creditCard); 311 var creditCardDialog = self.createCreditCardDialog_(creditCard);
212 312
213 creditCardDialog.addEventListener('save-credit-card', function(event) { 313 creditCardDialog.addEventListener('save-credit-card', function() {
214 // Fail the test because the save event should not be called when cancel 314 // Fail the test because the save event should not be called when cancel
215 // is clicked. 315 // is clicked.
216 assertTrue(false); 316 assertTrue(false);
217 done(); 317 done();
218 }); 318 });
219 319
220 creditCardDialog.addEventListener('iron-overlay-closed', function(event) { 320 creditCardDialog.addEventListener('iron-overlay-closed', function() {
221 // Test is |done| in a timeout in order to ensure that 321 // Test is |done| in a timeout in order to ensure that
222 // 'save-credit-card' is NOT fired after this test. 322 // 'save-credit-card' is NOT fired after this test.
223 window.setTimeout(done, 100); 323 window.setTimeout(done, 100);
224 }); 324 });
225 325
226 MockInteractions.tap(creditCardDialog.$.cancelButton); 326 MockInteractions.tap(creditCardDialog.$.cancelButton);
227 }), 327 }),
228 328
229 test('verifyAddressCount', function() { 329 test('verifyAddressCount', function() {
230 var addresses = [ 330 var addresses = [
(...skipping 20 matching lines...) Expand all
251 var addressList = section.$.addressList; 351 var addressList = section.$.addressList;
252 var row = addressList.children[1]; // Skip over the template. 352 var row = addressList.children[1]; // Skip over the template.
253 assertTrue(!!row); 353 assertTrue(!!row);
254 354
255 var addressSummary = address.metadata.summaryLabel + 355 var addressSummary = address.metadata.summaryLabel +
256 address.metadata.summarySublabel; 356 address.metadata.summarySublabel;
257 357
258 assertEquals(addressSummary, 358 assertEquals(addressSummary,
259 row.querySelector('#addressSummary').textContent); 359 row.querySelector('#addressSummary').textContent);
260 }); 360 });
361
362 test('verifyAddAddressDialog', function() {
363 return self.createAddressDialog_(
364 FakeDataMaker.emptyAddressEntry()).then(function(dialog) {
365 var title = dialog.$$('.title');
366 assertEquals(self.i18nStrings.addAddressTitle, title.textContent);
367 // Shouldn't be possible to save until something is typed in.
368 assertTrue(dialog.$.saveButton.disabled);
369 });
370 });
371
372 test('verifyEditAddressDialog', function() {
373 return self.createAddressDialog_(
374 FakeDataMaker.addressEntry()).then(function(dialog) {
375 var title = dialog.$$('.title');
376 assertEquals(self.i18nStrings.editAddressTitle, title.textContent);
377 // Should be possible to save when editing because fields are populated.
378 assertFalse(dialog.$.saveButton.disabled);
379 });
380 });
381
382 test('verifyCountryIsSaved', function() {
383 var address = FakeDataMaker.emptyAddressEntry();
384 return self.createAddressDialog_(address).then(function(dialog) {
385 assertEquals(undefined, dialog.$.countryList.selected);
386 assertEquals(undefined, address.countryCode);
387 dialog.$.countryList.selected = 'US';
388 Polymer.dom.flush();
389 assertEquals('US', dialog.$.countryList.selected);
390 assertEquals('US', address.countryCode);
391 });
392 });
393
394 test('verifyPhoneAndEmailAreSaved', function() {
395 var address = FakeDataMaker.emptyAddressEntry();
396 return self.createAddressDialog_(address).then(function(dialog) {
397 assertEquals('', dialog.$.phoneInput.value);
398 assertFalse(!!(address.phoneNumbers && address.phoneNumbers[0]));
399
400 assertEquals('', dialog.$.emailInput.value);
401 assertFalse(!!(address.emailAddresses && address.emailAddresses[0]));
402
403 var phoneNumber = '(555) 555-5555';
404 var emailAddress = 'no-reply@chromium.org';
405
406 dialog.$.phoneInput.value = phoneNumber;
407 dialog.$.emailInput.value = emailAddress;
408
409 Polymer.dom.flush();
410
411 assertEquals(phoneNumber, dialog.$.phoneInput.value);
412 assertEquals(phoneNumber, address.phoneNumbers[0]);
413
414 assertEquals(emailAddress, dialog.$.emailInput.value);
415 assertEquals(emailAddress, address.emailAddresses[0]);
416 });
417 });
418
419 // Test will set a value of 'foo' in each text field and verify that the
420 // save button is enabled, then it will clear the field and verify that the
421 // save button is disabled. Test passes after all elements have been tested.
422 test('verifySaveIsNotClickableIfAllInputFieldsAreEmpty', function() {
423 return self.createAddressDialog_(
424 FakeDataMaker.emptyAddressEntry()).then(function(dialog) {
425 var saveButton = dialog.$.saveButton;
426 var testElements =
427 dialog.$.dialog.querySelectorAll('paper-input,paper-textarea');
428
429 // Default country is 'US' expecting: Name, Organization,
430 // Street address, City, State, ZIP code, Phone, and Email.
431 assertEquals(8, testElements.length);
432
433 return asyncForEach(testElements, function(element) {
michaelpg 2016/06/27 21:29:18 Thank you! Much nicer.
hcarmona 2016/06/28 00:27:10 Thanks!
434 return expectEvent(dialog, 'on-update-can-save', function() {
435 assertTrue(saveButton.disabled);
436 element.value = 'foo';
437 }).then(function() {
438 return expectEvent(dialog, 'on-update-can-save', function() {
439 assertFalse(saveButton.disabled);
440 element.value = '';
441 });
442 }).then(function() {
443 assertTrue(saveButton.disabled);
444 });
445 });
446 });
447 });
448
449 // Setting the country should allow the address to be saved.
450 test('verifySaveIsNotClickableIfCountryNotSet', function() {
451 return self.createAddressDialog_(
452 FakeDataMaker.emptyAddressEntry()).then(function(dialog) {
453 var saveButton = dialog.$.saveButton;
454 var countries = dialog.$.countryList;
455
456 return expectEvent(dialog, 'on-update-can-save', function() {
457 assertTrue(saveButton.disabled);
458 countries.selected = 'US';
459 }).then(function() {
460 assertFalse(saveButton.disabled);
461 countries.selected = '';
462 }).then(function() {
463 assertTrue(saveButton.disabled);
464 });
465 });
466 });
467
468 // Test will timeout if save-address event is not fired.
469 test('verifyDefaultCountryIsAppliedWhenSaving', function() {
470 var address = FakeDataMaker.emptyAddressEntry();
471 address.companyName = 'Google';
472 return self.createAddressDialog_(address).then(function(dialog) {
473 return expectEvent(dialog, 'save-address', function() {
474 // Verify |countryCode| is not set.
475 assertEquals(undefined, address.countryCode);
476 MockInteractions.tap(dialog.$.saveButton);
477 }).then(function(event) {
478 // 'US' is the default country for these tests.
479 assertEquals('US', event.detail.countryCode);
480 });
481 });
482 });
483
484 test('verifyCancelDoesNotSaveAddress', function(done) {
485 self.createAddressDialog_(
486 FakeDataMaker.addressEntry()).then(function(dialog) {
487 dialog.addEventListener('save-address', function() {
488 // Fail the test because the save event should not be called when
489 // cancel is clicked.
490 assertTrue(false);
491 done();
492 });
493
494 dialog.addEventListener('iron-overlay-closed', function() {
495 // Test is |done| in a timeout in order to ensure that
496 // 'save-address' is NOT fired after this test.
497 window.setTimeout(done, 100);
498 });
499
500 MockInteractions.tap(dialog.$.cancelButton);
501 });
502 });
503
504 // US address has 3 fields on the same line.
505 test('verifyEditingUSAddress', function() {
506 var address = FakeDataMaker.emptyAddressEntry();
507
508 address.fullNames = [ 'Name' ];
509 address.companyName = 'Organization';
510 address.addressLines = 'Street address';
511 address.addressLevel2 = 'City';
512 address.addressLevel1 = 'State';
513 address.postalCode = 'ZIP code';
514 address.countryCode = 'US';
515 address.phoneNumbers = [ 'Phone' ];
516 address.emailAddresses = [ 'Email' ];
517
518 return self.createAddressDialog_(address).then(function(dialog) {
519 var rows = dialog.$.dialog.querySelectorAll('.address-row');
520 assertEquals(6, rows.length);
521
522 // Name
523 var row = rows[0];
524 var cols = row.querySelectorAll('.address-column');
525 assertEquals(1, cols.length);
526 assertEquals(address.fullNames[0], cols[0].value);
527 // Organization
528 row = rows[1];
529 cols = row.querySelectorAll('.address-column');
530 assertEquals(1, cols.length);
531 assertEquals(address.companyName, cols[0].value);
532 // Street address
533 row = rows[2];
534 cols = row.querySelectorAll('.address-column');
535 assertEquals(1, cols.length);
536 assertEquals(address.addressLines, cols[0].value);
537 // City, State, ZIP code
538 row = rows[3];
539 cols = row.querySelectorAll('.address-column');
540 assertEquals(3, cols.length);
541 assertEquals(address.addressLevel2, cols[0].value);
542 assertEquals(address.addressLevel1, cols[1].value);
543 assertEquals(address.postalCode, cols[2].value);
544 // Country
545 row = rows[4];
546 cols = row.querySelectorAll('.address-column');
547 assertEquals(1, cols.length);
548 assertEquals('United States', cols[0].value);
549 // Phone, Email
550 row = rows[5];
551 cols = row.querySelectorAll('.address-column');
552 assertEquals(2, cols.length);
553 assertEquals(address.phoneNumbers[0], cols[0].value);
554 assertEquals(address.emailAddresses[0], cols[1].value);
555 });
556 });
557
558 // GB address has 1 field per line for all lines that change.
559 test('verifyEditingGBAddress', function() {
560 var address = FakeDataMaker.emptyAddressEntry();
561
562 address.fullNames = [ 'Name' ];
563 address.companyName = 'Organization';
564 address.addressLines = 'Street address';
565 address.addressLevel2 = 'Post town';
566 address.addressLevel1 = 'County';
567 address.postalCode = 'Postal code';
568 address.countryCode = 'GB';
569 address.phoneNumbers = [ 'Phone' ];
570 address.emailAddresses = [ 'Email' ];
571
572 return self.createAddressDialog_(address).then(function(dialog) {
573 var rows = dialog.$.dialog.querySelectorAll('.address-row');
574 assertEquals(8, rows.length);
575
576 // Name
577 var row = rows[0];
578 var cols = row.querySelectorAll('.address-column');
579 assertEquals(1, cols.length);
580 assertEquals(address.fullNames[0], cols[0].value);
581 // Organization
582 row = rows[1];
583 cols = row.querySelectorAll('.address-column');
584 assertEquals(1, cols.length);
585 assertEquals(address.companyName, cols[0].value);
586 // Street address
587 row = rows[2];
588 cols = row.querySelectorAll('.address-column');
589 assertEquals(1, cols.length);
590 assertEquals(address.addressLines, cols[0].value);
591 // Post Town
592 row = rows[3];
593 cols = row.querySelectorAll('.address-column');
594 assertEquals(1, cols.length);
595 assertEquals(address.addressLevel2, cols[0].value);
596 // County
597 row = rows[4];
598 cols = row.querySelectorAll('.address-column');
599 assertEquals(1, cols.length);
600 assertEquals(address.addressLevel1, cols[0].value);
601 // Postal code
602 row = rows[5];
603 cols = row.querySelectorAll('.address-column');
604 assertEquals(1, cols.length);
605 assertEquals(address.postalCode, cols[0].value);
606 // Country
607 row = rows[6];
608 cols = row.querySelectorAll('.address-column');
609 assertEquals(1, cols.length);
610 assertEquals('United Kingdom', cols[0].value);
611 // Phone, Email
612 row = rows[7];
613 cols = row.querySelectorAll('.address-column');
614 assertEquals(2, cols.length);
615 assertEquals(address.phoneNumbers[0], cols[0].value);
616 assertEquals(address.emailAddresses[0], cols[1].value);
617 });
618 });
619
620 // IL address has 2 fields on the same line and is an RTL locale.
621 // RTL locale shouldn't affect this test.
622 test('verifyEditingILAddress', function() {
623 var address = FakeDataMaker.emptyAddressEntry();
624
625 address.fullNames = [ 'Name' ];
626 address.companyName = 'Organization';
627 address.addressLines = 'Street address';
628 address.addressLevel2 = 'City';
629 address.postalCode = 'Postal code';
630 address.countryCode = 'IL';
631 address.phoneNumbers = [ 'Phone' ];
632 address.emailAddresses = [ 'Email' ];
633
634 return self.createAddressDialog_(address).then(function(dialog) {
635 var rows = dialog.$.dialog.querySelectorAll('.address-row');
636 assertEquals(6, rows.length);
637
638 // Name
639 var row = rows[0];
640 var cols = row.querySelectorAll('.address-column');
641 assertEquals(1, cols.length);
642 assertEquals(address.fullNames[0], cols[0].value);
643 // Organization
644 row = rows[1];
645 cols = row.querySelectorAll('.address-column');
646 assertEquals(1, cols.length);
647 assertEquals(address.companyName, cols[0].value);
648 // Street address
649 row = rows[2];
650 cols = row.querySelectorAll('.address-column');
651 assertEquals(1, cols.length);
652 assertEquals(address.addressLines, cols[0].value);
653 // City, Postal code
654 row = rows[3];
655 cols = row.querySelectorAll('.address-column');
656 assertEquals(2, cols.length);
657 assertEquals(address.addressLevel2, cols[0].value);
658 assertEquals(address.postalCode, cols[1].value);
659 // Country
660 row = rows[4];
661 cols = row.querySelectorAll('.address-column');
662 assertEquals(1, cols.length);
663 assertEquals('Israel', cols[0].value);
664 // Phone, Email
665 row = rows[5];
666 cols = row.querySelectorAll('.address-column');
667 assertEquals(2, cols.length);
668 assertEquals(address.phoneNumbers[0], cols[0].value);
669 assertEquals(address.emailAddresses[0], cols[1].value);
670 });
671 });
672
673 // US has an extra field 'State'. Validate that this field is
674 // persisted when switching to IL then back to US.
675 test('verifyAddressPersistanceWhenSwitchingCountries', function() {
676 var address = FakeDataMaker.emptyAddressEntry();
677 address.countryCode = 'US';
678
679 return self.createAddressDialog_(address).then(function(dialog) {
680 var city = 'Los Angeles';
681 var state = 'CA';
682 var zip = '90291';
683
684 return expectEvent(dialog, 'on-update-address-wrapper', function() {
685 // US:
686 var rows = dialog.$.dialog.querySelectorAll('.address-row');
687 assertEquals(6, rows.length);
688
689 // City, State, ZIP code
690 var row = rows[3];
691 var cols = row.querySelectorAll('.address-column');
692 assertEquals(3, cols.length);
693 cols[0].value = city;
694 cols[1].value = state;
695 cols[2].value = zip;
696
697 dialog.$.countryList.selected = 'IL';
698 }).then(function() {
699 return expectEvent(dialog, 'on-update-address-wrapper', function() {
700 // IL:
701 rows = dialog.$.dialog.querySelectorAll('.address-row');
702 assertEquals(6, rows.length);
703
704 // City, Postal code
705 row = rows[3];
706 cols = row.querySelectorAll('.address-column');
707 assertEquals(2, cols.length);
708 assertEquals(city, cols[0].value);
709 assertEquals(zip, cols[1].value);
710
711 dialog.$.countryList.selected = 'US';
712 });
713 }).then(function() {
714 // US:
715 var rows = dialog.$.dialog.querySelectorAll('.address-row');
716 assertEquals(6, rows.length);
717
718 // City, State, ZIP code
719 row = rows[3];
720 cols = row.querySelectorAll('.address-column');
721 assertEquals(3, cols.length);
722 assertEquals(city, cols[0].value);
723 assertEquals(state, cols[1].value);
724 assertEquals(zip, cols[2].value);
725 });
726 });
727 });
261 }); 728 });
262 729
263 mocha.run(); 730 mocha.run();
264 }); 731 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698