Chromium Code Reviews| 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 var createProfileElement = document.createElement('create-profile'); | 8 var createProfileElement = document.createElement('create-profile'); |
| 9 document.body.appendChild(createProfileElement); | 9 document.body.appendChild(createProfileElement); |
| 10 return createProfileElement; | 10 return createProfileElement; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 assertFalse(createProfileElement.createInProgress_); | 176 assertFalse(createProfileElement.createInProgress_); |
| 177 // Message container is visible. | 177 // Message container is visible. |
| 178 assertFalse(createProfileElement.$$('#message-container').hidden); | 178 assertFalse(createProfileElement.$$('#message-container').hidden); |
| 179 // Error message contains a link to import the supervised user. | 179 // Error message contains a link to import the supervised user. |
| 180 var message = createProfileElement.$.message; | 180 var message = createProfileElement.$.message; |
| 181 assertTrue( | 181 assertTrue( |
| 182 !!message.querySelector('#supervised-user-import-existing')); | 182 !!message.querySelector('#supervised-user-import-existing')); |
| 183 }); | 183 }); |
| 184 }); | 184 }); |
| 185 | 185 |
| 186 test('Displays error if custodian has no supervised users', function() { | |
| 187 browserProxy.setExistingSupervisedUsers([]); | |
| 188 | |
| 189 // Simulate checking the checkbox. | |
| 190 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | |
| 191 Polymer.dom.flush(); | |
| 192 | |
| 193 // Select the first signed in user. | |
| 194 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); | |
| 195 var selector = dropdownMenu.querySelector('paper-listbox'); | |
| 196 selector.selected = 0; | |
| 197 | |
| 198 // Simulate clicking 'Import supervised user'. | |
| 199 MockInteractions.tap(createProfileElement.$$('#import-user')); | |
| 200 | |
| 201 return browserProxy.whenCalled('getExistingSupervisedUsers').then( | |
| 202 function(args) { | |
| 203 // Create is not in progress. | |
| 204 assertFalse(createProfileElement.createInProgress_); | |
| 205 // Message container is visible. | |
| 206 assertFalse(createProfileElement.$$('#message-container').hidden); | |
|
michaelpg
2016/08/09 02:53:48
nit: check foo.clientHeight > 0 instead of !foo.hi
Moe
2016/08/09 18:15:42
Done.
| |
| 207 // Error message is set. | |
| 208 var message = loadTimeData.getString( | |
| 209 'noSupervisedUserImportText'); | |
| 210 assertEquals(message, createProfileElement.$.message.innerHTML); | |
| 211 }); | |
| 212 }); | |
| 213 | |
| 186 test('Create supervised profile', function() { | 214 test('Create supervised profile', function() { |
| 187 // Simulate checking the checkbox. | 215 // Simulate checking the checkbox. |
| 188 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 216 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
| 189 Polymer.dom.flush(); | 217 Polymer.dom.flush(); |
| 190 | 218 |
| 191 // Select the first signed in user. | 219 // Select the first signed in user. |
| 192 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); | 220 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); |
| 193 var selector = dropdownMenu.querySelector('paper-listbox'); | 221 var selector = dropdownMenu.querySelector('paper-listbox'); |
| 194 selector.selected = 0; | 222 selector.selected = 0; |
| 195 | 223 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 test('Create button is disabled', function() { | 418 test('Create button is disabled', function() { |
| 391 assertTrue(createProfileElement.$.save.disabled); | 419 assertTrue(createProfileElement.$.save.disabled); |
| 392 }); | 420 }); |
| 393 }); | 421 }); |
| 394 } | 422 } |
| 395 | 423 |
| 396 return { | 424 return { |
| 397 registerTests: registerTests, | 425 registerTests: registerTests, |
| 398 }; | 426 }; |
| 399 }); | 427 }); |
| OLD | NEW |