OLD | NEW |
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 cr.define('user_manager.create_profile_tests', function() { | 5 cr.define('user_manager.create_profile_tests', function() { |
6 /** @return {!CreateProfileElement} */ | 6 /** @return {!CreateProfileElement} */ |
7 function createElement() { | 7 function createElement() { |
8 PolymerTest.clearBody(); | 8 PolymerTest.clearBody(); |
9 var createProfileElement = document.createElement('create-profile'); | 9 var createProfileElement = document.createElement('create-profile'); |
10 document.body.appendChild(createProfileElement); | 10 document.body.appendChild(createProfileElement); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 test('Handles signed in users', function() { | 50 test('Handles signed in users', function() { |
51 return browserProxy.whenCalled('getSignedInUsers').then(function() { | 51 return browserProxy.whenCalled('getSignedInUsers').then(function() { |
52 assertEquals(1, createProfileElement.signedInUsers_.length); | 52 assertEquals(1, createProfileElement.signedInUsers_.length); |
53 assertEquals('username', | 53 assertEquals('username', |
54 createProfileElement.signedInUsers_[0].username); | 54 createProfileElement.signedInUsers_[0].username); |
55 assertEquals('path/to/profile', | 55 assertEquals('path/to/profile', |
56 createProfileElement.signedInUsers_[0].profilePath); | 56 createProfileElement.signedInUsers_[0].profilePath); |
57 | 57 |
58 // The 'learn more' link is visible. | 58 // The 'learn more' link is visible. |
59 assertTrue(!!createProfileElement.$$('#learn-more')); | 59 assertTrue(!!createProfileElement.$$('#learn-more > a')); |
60 | 60 |
61 // The dropdown menu is visible only when the checkbox is checked. | 61 // The dropdown menu becomes visible when the checkbox is checked. |
62 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); | 62 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); |
63 | 63 |
64 // Simulate checking the checkbox. | 64 // Simulate checking the checkbox. |
65 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 65 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
66 Polymer.dom.flush(); | 66 Polymer.dom.flush(); |
67 | 67 |
68 // The dropdown menu is visible and is populated with the sentinel | 68 // The dropdown menu is visible and is populated with the sentinel |
69 // item as well as the signed in users. | 69 // item as well as the signed in users. |
70 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); | 70 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); |
71 assertTrue(!!dropdownMenu); | 71 assertTrue(!!dropdownMenu); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 348 |
349 test('Learn more link takes you to the correct page', function() { | 349 test('Learn more link takes you to the correct page', function() { |
350 return new Promise(function(resolve, reject) { | 350 return new Promise(function(resolve, reject) { |
351 // Create is not in progress. We expect to leave the page. | 351 // Create is not in progress. We expect to leave the page. |
352 createProfileElement.addEventListener('change-page', function(event) { | 352 createProfileElement.addEventListener('change-page', function(event) { |
353 if (event.detail.page == 'supervised-learn-more-page') | 353 if (event.detail.page == 'supervised-learn-more-page') |
354 resolve(); | 354 resolve(); |
355 }); | 355 }); |
356 | 356 |
357 // Simulate clicking 'Learn more'. | 357 // Simulate clicking 'Learn more'. |
358 MockInteractions.tap(createProfileElement.$$('#learn-more')); | 358 MockInteractions.tap(createProfileElement.$$('#learn-more > a')); |
359 }); | 359 }); |
360 }); | 360 }); |
361 }); | 361 }); |
362 | 362 |
363 suite('CreateProfileTestsNoSignedInUser', function() { | 363 suite('CreateProfileTestsNoSignedInUser', function() { |
364 setup(function() { | 364 setup(function() { |
365 browserProxy = new TestProfileBrowserProxy(); | 365 browserProxy = new TestProfileBrowserProxy(); |
366 // Replace real proxy with mock proxy. | 366 // Replace real proxy with mock proxy. |
367 signin.ProfileBrowserProxyImpl.instance_ = browserProxy; | 367 signin.ProfileBrowserProxyImpl.instance_ = browserProxy; |
368 | 368 |
369 createProfileElement = createElement(); | 369 createProfileElement = createElement(); |
370 | 370 |
371 // Make sure DOM is up to date. | 371 // Make sure DOM is up to date. |
372 Polymer.dom.flush(); | 372 Polymer.dom.flush(); |
373 }); | 373 }); |
374 | 374 |
375 teardown(function() { createProfileElement.remove(); }); | 375 teardown(function() { createProfileElement.remove(); }); |
376 | 376 |
377 test('Handles no signed in users', function() { | 377 test('Handles no signed in users', function() { |
378 return browserProxy.whenCalled('getSignedInUsers').then(function() { | 378 return browserProxy.whenCalled('getSignedInUsers').then(function() { |
379 assertEquals(0, createProfileElement.signedInUsers_.length); | 379 assertEquals(0, createProfileElement.signedInUsers_.length); |
380 | 380 |
381 // '#supervised-user-container' is not present in the DOM. | 381 // Simulate checking the checkbox. |
382 var container = createProfileElement.$$('#supervised-user-container'); | 382 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
383 assertFalse(!!container); | 383 Polymer.dom.flush(); |
| 384 |
| 385 // The dropdown menu is not visible when there are no signed in users. |
| 386 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); |
| 387 |
| 388 // Instead a message containing a link to the Help Center on how |
| 389 // to sign in to Chrome is displaying. |
| 390 assertTrue(!!createProfileElement.$$('#sign-in-to-chrome')); |
384 }); | 391 }); |
385 }); | 392 }); |
386 | 393 |
387 test('Create button is disabled', function() { | 394 test('Create button is disabled', function() { |
388 assertTrue(createProfileElement.$.save.disabled); | 395 assertTrue(createProfileElement.$.save.disabled); |
389 }); | 396 }); |
390 }); | 397 }); |
391 } | 398 } |
392 | 399 |
393 return { | 400 return { |
394 registerTests: registerTests, | 401 registerTests: registerTests, |
395 }; | 402 }; |
396 }); | 403 }); |
OLD | NEW |