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

Side by Side Diff: chrome/test/data/webui/md_user_manager/create_profile_tests.js

Issue 2561243002: Hide supervised user creation from UserManager when force sign in is enabled. (Closed)
Patch Set: moe's comments Created 4 years 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/md_user_manager/create_profile.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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 assertEquals('path/to/profile', 59 assertEquals('path/to/profile',
60 createProfileElement.signedInUsers_[0].profilePath); 60 createProfileElement.signedInUsers_[0].profilePath);
61 61
62 // The 'learn more' link is visible. 62 // The 'learn more' link is visible.
63 assertTrue(!!createProfileElement.$$('#learn-more > a')); 63 assertTrue(!!createProfileElement.$$('#learn-more > a'));
64 64
65 // The dropdown menu becomes visible when the checkbox is checked. 65 // The dropdown menu becomes visible when the checkbox is checked.
66 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); 66 assertFalse(!!createProfileElement.$$('paper-dropdown-menu'));
67 67
68 // Simulate checking the supervised user checkbox. 68 // Simulate checking the supervised user checkbox.
69 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 69 MockInteractions.tap(
70 createProfileElement.$$("#makeSupervisedCheckbox"));
70 Polymer.dom.flush(); 71 Polymer.dom.flush();
71 72
72 // The dropdown menu is visible and is populated with signed in users. 73 // The dropdown menu is visible and is populated with signed in users.
73 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); 74 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu');
74 assertTrue(!!dropdownMenu); 75 assertTrue(!!dropdownMenu);
75 var users = dropdownMenu.querySelectorAll('paper-item'); 76 var users = dropdownMenu.querySelectorAll('paper-item');
76 assertEquals(1, users.length); 77 assertEquals(1, users.length);
77 }); 78 });
78 }); 79 });
79 80
(...skipping 28 matching lines...) Expand all
108 assertEquals('icon1.png', args.profileIconUrl); 109 assertEquals('icon1.png', args.profileIconUrl);
109 assertFalse(args.createShortcut); 110 assertFalse(args.createShortcut);
110 assertFalse(args.isSupervised); 111 assertFalse(args.isSupervised);
111 assertEquals('', args.supervisedUserId); 112 assertEquals('', args.supervisedUserId);
112 assertEquals('', args.custodianProfilePath); 113 assertEquals('', args.custodianProfilePath);
113 }); 114 });
114 }); 115 });
115 116
116 test('Has to select a custodian for the supervised profile', function() { 117 test('Has to select a custodian for the supervised profile', function() {
117 // Simulate checking the supervised user checkbox. 118 // Simulate checking the supervised user checkbox.
118 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 119 MockInteractions.tap(
120 createProfileElement.$$("#makeSupervisedCheckbox"));
119 Polymer.dom.flush(); 121 Polymer.dom.flush();
120 122
121 // Simulate clicking 'Create'. 123 // Simulate clicking 'Create'.
122 MockInteractions.tap(createProfileElement.$.save); 124 MockInteractions.tap(createProfileElement.$.save);
123 125
124 // Create is not in progress. 126 // Create is not in progress.
125 assertFalse(createProfileElement.createInProgress_); 127 assertFalse(createProfileElement.createInProgress_);
126 // Message container is visible. 128 // Message container is visible.
127 var messageContainer = 129 var messageContainer =
128 createProfileElement.$$('#message-container'); 130 createProfileElement.$$('#message-container');
129 assertTrue(messageContainer.clientHeight > 0); 131 assertTrue(messageContainer.clientHeight > 0);
130 // Error message is set. 132 // Error message is set.
131 assertEquals( 133 assertEquals(
132 loadTimeData.getString('custodianAccountNotSelectedError'), 134 loadTimeData.getString('custodianAccountNotSelectedError'),
133 createProfileElement.$.message.innerHTML); 135 createProfileElement.$.message.innerHTML);
134 }); 136 });
135 137
136 test('Supervised profile name is duplicate (on the device)', function() { 138 test('Supervised profile name is duplicate (on the device)', function() {
137 // Simulate checking the supervised user checkbox. 139 // Simulate checking the supervised user checkbox.
138 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 140 MockInteractions.tap(
141 createProfileElement.$$("#makeSupervisedCheckbox"));
139 Polymer.dom.flush(); 142 Polymer.dom.flush();
140 143
141 // There is an existing supervised user with this name on the device. 144 // There is an existing supervised user with this name on the device.
142 createProfileElement.$.nameInput.value = 'existing name 1'; 145 createProfileElement.$.nameInput.value = 'existing name 1';
143 146
144 // Select the first signed in user. 147 // Select the first signed in user.
145 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); 148 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu');
146 var selector = dropdownMenu.querySelector('paper-listbox'); 149 var selector = dropdownMenu.querySelector('paper-listbox');
147 selector.selected = 0; 150 selector.selected = 0;
148 151
(...skipping 10 matching lines...) Expand all
159 assertTrue(messageContainer.clientHeight > 0); 162 assertTrue(messageContainer.clientHeight > 0);
160 // Error message is set. 163 // Error message is set.
161 var message = loadTimeData.getString( 164 var message = loadTimeData.getString(
162 'managedProfilesExistingLocalSupervisedUser'); 165 'managedProfilesExistingLocalSupervisedUser');
163 assertEquals(message, createProfileElement.$.message.innerHTML); 166 assertEquals(message, createProfileElement.$.message.innerHTML);
164 }); 167 });
165 }); 168 });
166 169
167 test('Supervised profile name is duplicate (remote)', function() { 170 test('Supervised profile name is duplicate (remote)', function() {
168 // Simulate checking the supervised user checkbox. 171 // Simulate checking the supervised user checkbox.
169 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 172 MockInteractions.tap(
173 createProfileElement.$$("#makeSupervisedCheckbox"));
170 Polymer.dom.flush(); 174 Polymer.dom.flush();
171 175
172 // There is an existing supervised user with this name on the device. 176 // There is an existing supervised user with this name on the device.
173 createProfileElement.$.nameInput.value = 'existing name 2'; 177 createProfileElement.$.nameInput.value = 'existing name 2';
174 178
175 // Select the first signed in user. 179 // Select the first signed in user.
176 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); 180 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu');
177 var selector = dropdownMenu.querySelector('paper-listbox'); 181 var selector = dropdownMenu.querySelector('paper-listbox');
178 selector.selected = 0; 182 selector.selected = 0;
179 183
(...skipping 12 matching lines...) Expand all
192 var message = createProfileElement.$.message; 196 var message = createProfileElement.$.message;
193 assertTrue( 197 assertTrue(
194 !!message.querySelector('#supervised-user-import-existing')); 198 !!message.querySelector('#supervised-user-import-existing'));
195 }); 199 });
196 }); 200 });
197 201
198 test('Displays error if custodian has no supervised users', function() { 202 test('Displays error if custodian has no supervised users', function() {
199 browserProxy.setExistingSupervisedUsers([]); 203 browserProxy.setExistingSupervisedUsers([]);
200 204
201 // Simulate checking the supervised user checkbox. 205 // Simulate checking the supervised user checkbox.
202 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 206 MockInteractions.tap(
207 createProfileElement.$$("#makeSupervisedCheckbox"));
203 Polymer.dom.flush(); 208 Polymer.dom.flush();
204 209
205 // Select the first signed in user. 210 // Select the first signed in user.
206 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); 211 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu');
207 var selector = dropdownMenu.querySelector('paper-listbox'); 212 var selector = dropdownMenu.querySelector('paper-listbox');
208 selector.selected = 0; 213 selector.selected = 0;
209 214
210 // Simulate clicking 'Import supervised user'. 215 // Simulate clicking 'Import supervised user'.
211 MockInteractions.tap(createProfileElement.$$('#import-user')); 216 MockInteractions.tap(createProfileElement.$$('#import-user'));
212 217
213 return browserProxy.whenCalled('getExistingSupervisedUsers').then( 218 return browserProxy.whenCalled('getExistingSupervisedUsers').then(
214 function(args) { 219 function(args) {
215 // Create is not in progress. 220 // Create is not in progress.
216 assertFalse(createProfileElement.createInProgress_); 221 assertFalse(createProfileElement.createInProgress_);
217 // Message container is visible. 222 // Message container is visible.
218 var messageContainer = 223 var messageContainer =
219 createProfileElement.$$('#message-container'); 224 createProfileElement.$$('#message-container');
220 assertTrue(messageContainer.clientHeight > 0); 225 assertTrue(messageContainer.clientHeight > 0);
221 // Error message is set. 226 // Error message is set.
222 var message = loadTimeData.getString( 227 var message = loadTimeData.getString(
223 'noSupervisedUserImportText'); 228 'noSupervisedUserImportText');
224 assertEquals(message, createProfileElement.$.message.innerHTML); 229 assertEquals(message, createProfileElement.$.message.innerHTML);
225 }); 230 });
226 }); 231 });
227 232
228 test('Create supervised profile', function() { 233 test('Create supervised profile', function() {
229 // Simulate checking the supervised user checkbox. 234 // Simulate checking the supervised user checkbox.
230 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 235 MockInteractions.tap(
236 createProfileElement.$$("#makeSupervisedCheckbox"));
231 Polymer.dom.flush(); 237 Polymer.dom.flush();
232 238
233 // Select the first signed in user. 239 // Select the first signed in user.
234 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); 240 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu');
235 var selector = dropdownMenu.querySelector('paper-listbox'); 241 var selector = dropdownMenu.querySelector('paper-listbox');
236 selector.selected = 0; 242 selector.selected = 0;
237 243
238 // Simulate clicking 'Create'. 244 // Simulate clicking 'Create'.
239 MockInteractions.tap(createProfileElement.$.save); 245 MockInteractions.tap(createProfileElement.$.save);
240 246
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 createProfileElement.remove(); 417 createProfileElement.remove();
412 // Allow asynchronous tasks to finish. 418 // Allow asynchronous tasks to finish.
413 setTimeout(done); 419 setTimeout(done);
414 }); 420 });
415 421
416 test('Handles no signed in users', function() { 422 test('Handles no signed in users', function() {
417 return browserProxy.whenCalled('getSignedInUsers').then(function() { 423 return browserProxy.whenCalled('getSignedInUsers').then(function() {
418 assertEquals(0, createProfileElement.signedInUsers_.length); 424 assertEquals(0, createProfileElement.signedInUsers_.length);
419 425
420 // Simulate checking the supervised user checkbox. 426 // Simulate checking the supervised user checkbox.
421 MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); 427 MockInteractions.tap(
428 createProfileElement.$$("#makeSupervisedCheckbox"));
422 Polymer.dom.flush(); 429 Polymer.dom.flush();
423 430
424 // The dropdown menu is not visible when there are no signed in users. 431 // The dropdown menu is not visible when there are no signed in users.
425 assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); 432 assertFalse(!!createProfileElement.$$('paper-dropdown-menu'));
426 433
427 // Instead a message containing a link to the Help Center on how 434 // Instead a message containing a link to the Help Center on how
428 // to sign in to Chrome is displaying. 435 // to sign in to Chrome is displaying.
429 assertTrue(!!createProfileElement.$$('#sign-in-to-chrome')); 436 assertTrue(!!createProfileElement.$$('#sign-in-to-chrome'));
430 }); 437 });
431 }); 438 });
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return browserProxy.whenCalled('createProfile').then(function(args) { 507 return browserProxy.whenCalled('createProfile').then(function(args) {
501 assertEquals('profile name', args.profileName); 508 assertEquals('profile name', args.profileName);
502 assertEquals('icon1.png', args.profileIconUrl); 509 assertEquals('icon1.png', args.profileIconUrl);
503 assertTrue(args.createShortcut); 510 assertTrue(args.createShortcut);
504 assertFalse(args.isSupervised); 511 assertFalse(args.isSupervised);
505 assertEquals('', args.supervisedUserId); 512 assertEquals('', args.supervisedUserId);
506 assertEquals('', args.custodianProfilePath); 513 assertEquals('', args.custodianProfilePath);
507 }); 514 });
508 }); 515 });
509 }); 516 });
517
518 suite('CreateProfileTestsForceSigninPolicy', function() {
519 setup(function() {
520 browserProxy = new TestProfileBrowserProxy();
521 // Replace real proxy with mock proxy.
522 signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
523 browserProxy.setIcons([{url: 'icon1.png', label: 'icon1'}]);
524 });
525
526 teardown(function(done) {
527 createProfileElement.remove();
528 // Allow asynchronous tasks to finish.
529 setTimeout(done);
530 });
531
532 test('force sign in policy enabled', function () {
533 loadTimeData.overrideValues({
534 isForceSigninEnabled: true,
535 });
536 createProfileElement = createElement();
537 Polymer.dom.flush();
538
539 var createSupervisedUserCheckbox =
540 createProfileElement.$$("#makeSupervisedCheckbox");
541 assertEquals(null, createSupervisedUserCheckbox);
Moe 2016/12/12 21:13:01 do assertFalse(!!createSupervisedUserCheckbox) ins
zmin 2016/12/12 21:38:11 Done.
542 });
543
544 test('force sign in policy not enabled', function () {
545 loadTimeData.overrideValues({
546 isForceSigninEnabled: false,
547 });
548 createProfileElement = createElement();
549 Polymer.dom.flush();
550
551 var createSupervisedUserCheckbox =
552 createProfileElement.$$("#makeSupervisedCheckbox");
553 assertTrue(createSupervisedUserCheckbox.clientHeight > 0);
554 });
555 });
510 } 556 }
511 557
512 return { 558 return {
513 registerTests: registerTests, 559 registerTests: registerTests,
514 }; 560 };
515 }); 561 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_user_manager/create_profile.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698