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

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

Issue 2654553004: MD Settings: Update Autofill Credit Card Dialog to accept Enter Key (Closed)
Patch Set: update tests Created 3 years, 11 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/passwords_and_forms_page/credit_card_edit_dialog.js ('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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 now.getFullYear().toString(), 296 now.getFullYear().toString(),
297 yearOptions[0].textContent.trim()); 297 yearOptions[0].textContent.trim());
298 assertEquals( 298 assertEquals(
299 maxYear.toString(), 299 maxYear.toString(),
300 yearOptions[yearOptions.length -1].textContent.trim()); 300 yearOptions[yearOptions.length -1].textContent.trim());
301 assertEquals( 301 assertEquals(
302 creditCard.expirationYear, creditCardDialog.$.year.value); 302 creditCard.expirationYear, creditCardDialog.$.year.value);
303 }); 303 });
304 }); 304 });
305 305
306 test('verifySaveExpiredCreditCardEdit', function(done) { 306 test('verify save disabled for expired credit card', function() {
307 var creditCard = FakeDataMaker.emptyCreditCardEntry(); 307 var creditCard = FakeDataMaker.emptyCreditCardEntry();
308 308
309 var now = new Date(); 309 var now = new Date();
310 creditCard.expirationYear = now.getFullYear() - 2; 310 creditCard.expirationYear = now.getFullYear() - 2;
311 // works fine for January. 311 // works fine for January.
312 creditCard.expirationMonth = now.getMonth() - 1; 312 creditCard.expirationMonth = now.getMonth() - 1;
313 313
314 var creditCardDialog = self.createCreditCardDialog_(creditCard); 314 var creditCardDialog = self.createCreditCardDialog_(creditCard);
315 315
316 return test_util.whenAttributeIs( 316 return test_util.whenAttributeIs(
317 creditCardDialog.$.dialog, 'open', true).then(function() { 317 creditCardDialog.$.dialog, 'open', true).then(function() {
318 creditCardDialog.addEventListener('save-credit-card', function() { 318 assertTrue(creditCardDialog.$.saveButton.disabled);
319 // Fail the test because the save event should not be called when
320 // the card is expired.
321 assertTrue(false);
322 });
323 creditCardDialog.addEventListener('tap', function() {
324 // Test is |done| in a timeout in order to ensure that
325 // 'save-credit-card' is NOT fired after this test.
326 assertFalse(creditCardDialog.$.expired.hidden);
327 window.setTimeout(done, 100);
328 });
329 MockInteractions.tap(creditCardDialog.$.saveButton);
330 }); 319 });
331 }); 320 });
332 321
333 // Test will timeout if event is not received. 322 // Test will timeout if event is not received.
334 test('verifySaveCreditCardEdit', function(done) { 323 test('verify save new credit card', function(done) {
335 var creditCard = FakeDataMaker.emptyCreditCardEntry(); 324 var creditCard = FakeDataMaker.emptyCreditCardEntry();
336 var creditCardDialog = self.createCreditCardDialog_(creditCard); 325 var creditCardDialog = self.createCreditCardDialog_(creditCard);
337 326
338 return test_util.whenAttributeIs( 327 return test_util.whenAttributeIs(
339 creditCardDialog.$.dialog, 'open', true).then(function() { 328 creditCardDialog.$.dialog, 'open', true).then(function() {
329 // Not expired, but still can't be saved, because there's no name.
340 assertTrue(creditCardDialog.$.expired.hidden); 330 assertTrue(creditCardDialog.$.expired.hidden);
331 assertTrue(creditCardDialog.$.saveButton.disabled);
332
333 // Add a name and trigger the on-input handler.
334 creditCardDialog.set('creditCard.name', 'Jane Doe');
335 creditCardDialog.onCreditCardNameOrNumberChanged_();
336 Polymer.dom.flush();
337
338 assertTrue(creditCardDialog.$.expired.hidden);
339 assertFalse(creditCardDialog.$.saveButton.disabled);
340
341 creditCardDialog.addEventListener('save-credit-card', function(event) { 341 creditCardDialog.addEventListener('save-credit-card', function(event) {
342 assertEquals(creditCard.guid, event.detail.guid); 342 assertEquals(creditCard.guid, event.detail.guid);
343 done(); 343 done();
344 }); 344 });
345 MockInteractions.tap(creditCardDialog.$.saveButton); 345 MockInteractions.tap(creditCardDialog.$.saveButton);
346 }); 346 });
347 }); 347 });
348 348
349 test('verifyCancelCreditCardEdit', function(done) { 349 test('verifyCancelCreditCardEdit', function(done) {
350 var creditCard = FakeDataMaker.emptyCreditCardEntry(); 350 var creditCard = FakeDataMaker.emptyCreditCardEntry();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 assertEquals(city, cols[0].value); 843 assertEquals(city, cols[0].value);
844 assertEquals(state, cols[1].value); 844 assertEquals(state, cols[1].value);
845 assertEquals(zip, cols[2].value); 845 assertEquals(zip, cols[2].value);
846 }); 846 });
847 }); 847 });
848 }); 848 });
849 }); 849 });
850 850
851 mocha.run(); 851 mocha.run();
852 }); 852 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698