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

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

Issue 2382943002: MD Settings: Migrating add/edit address dropdowns to native select. (Closed)
Patch Set: Addressing comment. Created 4 years, 2 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
« no previous file with comments | « chrome/browser/resources/settings/select_css.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 var title = dialog.$$('.title'); 422 var title = dialog.$$('.title');
423 assertEquals(self.i18nStrings.editAddressTitle, title.textContent); 423 assertEquals(self.i18nStrings.editAddressTitle, title.textContent);
424 // Should be possible to save when editing because fields are populated. 424 // Should be possible to save when editing because fields are populated.
425 assertFalse(dialog.$.saveButton.disabled); 425 assertFalse(dialog.$.saveButton.disabled);
426 }); 426 });
427 }); 427 });
428 428
429 test('verifyCountryIsSaved', function() { 429 test('verifyCountryIsSaved', function() {
430 var address = FakeDataMaker.emptyAddressEntry(); 430 var address = FakeDataMaker.emptyAddressEntry();
431 return self.createAddressDialog_(address).then(function(dialog) { 431 return self.createAddressDialog_(address).then(function(dialog) {
432 assertEquals(undefined, dialog.$.countryList.selected); 432 var countrySelect = dialog.$$('select');
433 assertEquals('', countrySelect.value);
433 assertEquals(undefined, address.countryCode); 434 assertEquals(undefined, address.countryCode);
434 dialog.$.countryList.selected = 'US'; 435 countrySelect.value = 'US';
436 countrySelect.dispatchEvent(new CustomEvent('change'));
435 Polymer.dom.flush(); 437 Polymer.dom.flush();
436 assertEquals('US', dialog.$.countryList.selected); 438 assertEquals('US', countrySelect.value);
437 assertEquals('US', address.countryCode); 439 assertEquals('US', address.countryCode);
438 }); 440 });
439 }); 441 });
440 442
441 test('verifyPhoneAndEmailAreSaved', function() { 443 test('verifyPhoneAndEmailAreSaved', function() {
442 var address = FakeDataMaker.emptyAddressEntry(); 444 var address = FakeDataMaker.emptyAddressEntry();
443 return self.createAddressDialog_(address).then(function(dialog) { 445 return self.createAddressDialog_(address).then(function(dialog) {
444 assertEquals('', dialog.$.phoneInput.value); 446 assertEquals('', dialog.$.phoneInput.value);
445 assertFalse(!!(address.phoneNumbers && address.phoneNumbers[0])); 447 assertFalse(!!(address.phoneNumbers && address.phoneNumbers[0]));
446 448
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 }); 518 });
517 }).then(function() { 519 }).then(function() {
518 assertTrue(saveButton.disabled); 520 assertTrue(saveButton.disabled);
519 }); 521 });
520 }); 522 });
521 }); 523 });
522 }); 524 });
523 525
524 // Setting the country should allow the address to be saved. 526 // Setting the country should allow the address to be saved.
525 test('verifySaveIsNotClickableIfCountryNotSet', function() { 527 test('verifySaveIsNotClickableIfCountryNotSet', function() {
528 var dialog = null;
529
530 var simulateCountryChange = function(countryCode) {
531 var countrySelect = dialog.$$('select');
532 countrySelect.value = countryCode;
533 countrySelect.dispatchEvent(new CustomEvent('change'));
534 };
535
526 return self.createAddressDialog_( 536 return self.createAddressDialog_(
527 FakeDataMaker.emptyAddressEntry()).then(function(dialog) { 537 FakeDataMaker.emptyAddressEntry()).then(function(d) {
528 var saveButton = dialog.$.saveButton; 538 dialog = d;
529 var countries = dialog.$.countryList; 539 assertTrue(dialog.$.saveButton.disabled);
530 540
531 return expectEvent(dialog, 'on-update-can-save', function() { 541 return expectEvent(
532 assertTrue(saveButton.disabled); 542 dialog, 'on-update-can-save',
533 countries.selected = 'US'; 543 simulateCountryChange.bind(null, 'US'));
534 }).then(function() { 544 }).then(function() {
535 assertFalse(saveButton.disabled); 545 assertFalse(dialog.$.saveButton.disabled);
536 countries.selected = ''; 546
537 }).then(function() { 547 return expectEvent(
538 assertTrue(saveButton.disabled); 548 dialog, 'on-update-can-save',
539 }); 549 simulateCountryChange.bind(null, ''));
550 }).then(function() {
551 assertTrue(dialog.$.saveButton.disabled);
540 }); 552 });
541 }); 553 });
542 554
543 // Test will timeout if save-address event is not fired. 555 // Test will timeout if save-address event is not fired.
544 test('verifyDefaultCountryIsAppliedWhenSaving', function() { 556 test('verifyDefaultCountryIsAppliedWhenSaving', function() {
545 var address = FakeDataMaker.emptyAddressEntry(); 557 var address = FakeDataMaker.emptyAddressEntry();
546 address.companyName = 'Google'; 558 address.companyName = 'Google';
547 return self.createAddressDialog_(address).then(function(dialog) { 559 return self.createAddressDialog_(address).then(function(dialog) {
548 return expectEvent(dialog, 'save-address', function() { 560 return expectEvent(dialog, 'save-address', function() {
549 // Verify |countryCode| is not set. 561 // Verify |countryCode| is not set.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 row = rows[3]; 633 row = rows[3];
622 cols = row.querySelectorAll('.address-column'); 634 cols = row.querySelectorAll('.address-column');
623 assertEquals(3, cols.length); 635 assertEquals(3, cols.length);
624 assertEquals(address.addressLevel2, cols[0].value); 636 assertEquals(address.addressLevel2, cols[0].value);
625 assertEquals(address.addressLevel1, cols[1].value); 637 assertEquals(address.addressLevel1, cols[1].value);
626 assertEquals(address.postalCode, cols[2].value); 638 assertEquals(address.postalCode, cols[2].value);
627 // Country 639 // Country
628 row = rows[4]; 640 row = rows[4];
629 cols = row.querySelectorAll('.address-column'); 641 cols = row.querySelectorAll('.address-column');
630 assertEquals(1, cols.length); 642 assertEquals(1, cols.length);
631 assertEquals('United States', cols[0].value); 643 var countrySelect = /** @type {!HTMLSelectElement} */ (cols[0]);
644 assertEquals(
645 'United States',
646 countrySelect.selectedOptions[0].textContent.trim());
632 // Phone, Email 647 // Phone, Email
633 row = rows[5]; 648 row = rows[5];
634 cols = row.querySelectorAll('.address-column'); 649 cols = row.querySelectorAll('.address-column');
635 assertEquals(2, cols.length); 650 assertEquals(2, cols.length);
636 assertEquals(address.phoneNumbers[0], cols[0].value); 651 assertEquals(address.phoneNumbers[0], cols[0].value);
637 assertEquals(address.emailAddresses[0], cols[1].value); 652 assertEquals(address.emailAddresses[0], cols[1].value);
638 }); 653 });
639 }); 654 });
640 655
641 // GB address has 1 field per line for all lines that change. 656 // GB address has 1 field per line for all lines that change.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 assertEquals(address.addressLevel1, cols[0].value); 698 assertEquals(address.addressLevel1, cols[0].value);
684 // Postal code 699 // Postal code
685 row = rows[5]; 700 row = rows[5];
686 cols = row.querySelectorAll('.address-column'); 701 cols = row.querySelectorAll('.address-column');
687 assertEquals(1, cols.length); 702 assertEquals(1, cols.length);
688 assertEquals(address.postalCode, cols[0].value); 703 assertEquals(address.postalCode, cols[0].value);
689 // Country 704 // Country
690 row = rows[6]; 705 row = rows[6];
691 cols = row.querySelectorAll('.address-column'); 706 cols = row.querySelectorAll('.address-column');
692 assertEquals(1, cols.length); 707 assertEquals(1, cols.length);
693 assertEquals('United Kingdom', cols[0].value); 708 assertEquals(
709 'United Kingdom', cols[0].selectedOptions[0].textContent.trim());
694 // Phone, Email 710 // Phone, Email
695 row = rows[7]; 711 row = rows[7];
696 cols = row.querySelectorAll('.address-column'); 712 cols = row.querySelectorAll('.address-column');
697 assertEquals(2, cols.length); 713 assertEquals(2, cols.length);
698 assertEquals(address.phoneNumbers[0], cols[0].value); 714 assertEquals(address.phoneNumbers[0], cols[0].value);
699 assertEquals(address.emailAddresses[0], cols[1].value); 715 assertEquals(address.emailAddresses[0], cols[1].value);
700 }); 716 });
701 }); 717 });
702 718
703 // IL address has 2 fields on the same line and is an RTL locale. 719 // IL address has 2 fields on the same line and is an RTL locale.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // City, Postal code 752 // City, Postal code
737 row = rows[3]; 753 row = rows[3];
738 cols = row.querySelectorAll('.address-column'); 754 cols = row.querySelectorAll('.address-column');
739 assertEquals(2, cols.length); 755 assertEquals(2, cols.length);
740 assertEquals(address.addressLevel2, cols[0].value); 756 assertEquals(address.addressLevel2, cols[0].value);
741 assertEquals(address.postalCode, cols[1].value); 757 assertEquals(address.postalCode, cols[1].value);
742 // Country 758 // Country
743 row = rows[4]; 759 row = rows[4];
744 cols = row.querySelectorAll('.address-column'); 760 cols = row.querySelectorAll('.address-column');
745 assertEquals(1, cols.length); 761 assertEquals(1, cols.length);
746 assertEquals('Israel', cols[0].value); 762 assertEquals(
763 'Israel', cols[0].selectedOptions[0].textContent.trim());
747 // Phone, Email 764 // Phone, Email
748 row = rows[5]; 765 row = rows[5];
749 cols = row.querySelectorAll('.address-column'); 766 cols = row.querySelectorAll('.address-column');
750 assertEquals(2, cols.length); 767 assertEquals(2, cols.length);
751 assertEquals(address.phoneNumbers[0], cols[0].value); 768 assertEquals(address.phoneNumbers[0], cols[0].value);
752 assertEquals(address.emailAddresses[0], cols[1].value); 769 assertEquals(address.emailAddresses[0], cols[1].value);
753 }); 770 });
754 }); 771 });
755 772
756 // US has an extra field 'State'. Validate that this field is 773 // US has an extra field 'State'. Validate that this field is
757 // persisted when switching to IL then back to US. 774 // persisted when switching to IL then back to US.
758 test('verifyAddressPersistanceWhenSwitchingCountries', function() { 775 test('verifyAddressPersistanceWhenSwitchingCountries', function() {
759 var address = FakeDataMaker.emptyAddressEntry(); 776 var address = FakeDataMaker.emptyAddressEntry();
760 address.countryCode = 'US'; 777 address.countryCode = 'US';
761 778
762 return self.createAddressDialog_(address).then(function(dialog) { 779 return self.createAddressDialog_(address).then(function(dialog) {
763 var city = 'Los Angeles'; 780 var city = 'Los Angeles';
764 var state = 'CA'; 781 var state = 'CA';
765 var zip = '90291'; 782 var zip = '90291';
783 var countrySelect = dialog.$$('select');
766 784
767 return expectEvent(dialog, 'on-update-address-wrapper', function() { 785 return expectEvent(dialog, 'on-update-address-wrapper', function() {
768 // US: 786 // US:
769 var rows = dialog.$.dialog.querySelectorAll('.address-row'); 787 var rows = dialog.$.dialog.querySelectorAll('.address-row');
770 assertEquals(6, rows.length); 788 assertEquals(6, rows.length);
771 789
772 // City, State, ZIP code 790 // City, State, ZIP code
773 var row = rows[3]; 791 var row = rows[3];
774 var cols = row.querySelectorAll('.address-column'); 792 var cols = row.querySelectorAll('.address-column');
775 assertEquals(3, cols.length); 793 assertEquals(3, cols.length);
776 cols[0].value = city; 794 cols[0].value = city;
777 cols[1].value = state; 795 cols[1].value = state;
778 cols[2].value = zip; 796 cols[2].value = zip;
779 797
780 dialog.$.countryList.selected = 'IL'; 798 countrySelect.value = 'IL';
799 countrySelect.dispatchEvent(new CustomEvent('change'));
781 }).then(function() { 800 }).then(function() {
782 return expectEvent(dialog, 'on-update-address-wrapper', function() { 801 return expectEvent(dialog, 'on-update-address-wrapper', function() {
783 // IL: 802 // IL:
784 rows = dialog.$.dialog.querySelectorAll('.address-row'); 803 rows = dialog.$.dialog.querySelectorAll('.address-row');
785 assertEquals(6, rows.length); 804 assertEquals(6, rows.length);
786 805
787 // City, Postal code 806 // City, Postal code
788 row = rows[3]; 807 row = rows[3];
789 cols = row.querySelectorAll('.address-column'); 808 cols = row.querySelectorAll('.address-column');
790 assertEquals(2, cols.length); 809 assertEquals(2, cols.length);
791 assertEquals(city, cols[0].value); 810 assertEquals(city, cols[0].value);
792 assertEquals(zip, cols[1].value); 811 assertEquals(zip, cols[1].value);
793 812
794 dialog.$.countryList.selected = 'US'; 813 countrySelect.value = 'US';
814 countrySelect.dispatchEvent(new CustomEvent('change'));
795 }); 815 });
796 }).then(function() { 816 }).then(function() {
797 // US: 817 // US:
798 var rows = dialog.$.dialog.querySelectorAll('.address-row'); 818 var rows = dialog.$.dialog.querySelectorAll('.address-row');
799 assertEquals(6, rows.length); 819 assertEquals(6, rows.length);
800 820
801 // City, State, ZIP code 821 // City, State, ZIP code
802 row = rows[3]; 822 row = rows[3];
803 cols = row.querySelectorAll('.address-column'); 823 cols = row.querySelectorAll('.address-column');
804 assertEquals(3, cols.length); 824 assertEquals(3, cols.length);
805 assertEquals(city, cols[0].value); 825 assertEquals(city, cols[0].value);
806 assertEquals(state, cols[1].value); 826 assertEquals(state, cols[1].value);
807 assertEquals(zip, cols[2].value); 827 assertEquals(zip, cols[2].value);
808 }); 828 });
809 }); 829 });
810 }); 830 });
811 }); 831 });
812 832
813 mocha.run(); 833 mocha.run();
814 }); 834 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/select_css.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698