Commit 7c0a178e authored by Alex Ilin's avatar Alex Ilin Committed by Chromium LUCI CQ

[ProfilePicker] Add tests for profile-card-menu

This CL adds more tests to profile_card_menu_test.js test suite. The
new tests check:
- profile and account names in the remove confirmation dialog
- statistics table in the remove confirmation dialog

Change-Id: I9284b85d1b0ece2f958da60dd1566f9addf2857f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630048
Auto-Submit: Alex Ilin <alexilin@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Commit-Queue: Monica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844539}
parent 8715ede9
......@@ -27,7 +27,7 @@ import {ManageProfilesBrowserProxy, ManageProfilesBrowserProxyImpl, ProfileState
* Autofill: number,
* }}
*/
let Statistics;
export let Statistics;
/**
* This is the data structure sent back and forth between C++ and JS.
......@@ -36,7 +36,7 @@ let Statistics;
* statistics: Statistics,
* }}
*/
let StatisticsResult;
export let StatisticsResult;
/**
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import './profile_picker_app.js';
export {ensureLazyLoaded} from './ensure_lazy_loaded.js';
export {AutogeneratedThemeColorInfo, ManageProfilesBrowserProxy, ManageProfilesBrowserProxyImpl, ProfileState} from './manage_profiles_browser_proxy.js';
export {navigateTo, navigateToStep, NavigationBehavior, ProfileCreationSteps, Routes} from './navigation_behavior.js';
export {Statistics, StatisticsResult} from './profile_card_menu.js';
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {ManageProfilesBrowserProxyImpl, ProfileState} from 'chrome://profile-picker/profile_picker.js';
import {ManageProfilesBrowserProxyImpl, ProfileState, Statistics, StatisticsResult} from 'chrome://profile-picker/profile_picker.js';
import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
import {assertEquals, assertFalse, assertNotEquals, assertTrue} from '../chai_assert.js';
import {waitBeforeNextRender} from '../test_util.m.js';
import {TestManageProfilesBrowserProxy} from './test_manage_profiles_browser_proxy.js';
......@@ -17,11 +17,16 @@ suite('ProfileCardMenuTest', function() {
/** @type {!TestManageProfilesBrowserProxy} */
let browserProxy;
/** @enum {number} */
const menuButtonIndex = {
CUSTOMIZE: 0,
DELETE: 1,
};
/** @type {!Array<string>} */
const statisticsDataTypes =
['BrowsingHistory', 'Passwords', 'Bookmarks', 'Autofill'];
setup(function() {
browserProxy = new TestManageProfilesBrowserProxy();
ManageProfilesBrowserProxyImpl.instance_ = browserProxy;
......@@ -99,4 +104,75 @@ suite('ProfileCardMenuTest', function() {
webUIListenerCallback('profile-removed', 'profilePath');
assertFalse(dialog.open);
});
// The profile info in the remove confirmation dialog is displayed correctly.
test('RemoveConfirmationDialogProfileCard', async function() {
const dialog = profileCardMenuElement.$$('#removeConfirmationDialog');
dialog.showModal();
assertTrue(dialog.open);
assertEquals(dialog.querySelector('#profileName').innerText, 'profile');
assertEquals(dialog.querySelector('#gaiaName').innerText, 'User');
const updatedProfileState = /** @type {!ProfileState} */
(Object.assign({}, profileCardMenuElement.profileState));
updatedProfileState.localProfileName = 'updatedProfile';
updatedProfileState.gaiaName = 'updatedUser';
profileCardMenuElement.profileState = updatedProfileState;
assertEquals(
dialog.querySelector('#profileName').innerText, 'updatedProfile');
assertEquals(dialog.querySelector('#gaiaName').innerText, 'updatedUser');
});
// The profile statistics in the remove confirmation dialog are displayed
// correctly.
test('RemoveConfirmationDialogStatistics', async function() {
const dialog = profileCardMenuElement.$$('#removeConfirmationDialog');
dialog.showModal();
assertTrue(dialog.open);
const statistics = /** @type {!Statistics} */ ({
BrowsingHistory: 1,
Passwords: 2,
Bookmarks: 3,
Autofill: 4,
});
const statisticsResult = /** @type {!StatisticsResult} */ ({
profilePath: 'profilePath',
statistics: statistics,
});
webUIListenerCallback('profile-statistics-received', statisticsResult);
const statisticsCountElements =
dialog.querySelector('.statistics').querySelectorAll('.count');
for (let i = 0; i < statisticsDataTypes.length; i++) {
assertEquals(
statisticsCountElements[i].innerText,
statistics[statisticsDataTypes[i]].toString());
}
});
// The profile statistics of another profile aren't displayed.
test('RemoveConfirmationDialogStatisticsWrongProfile', async function() {
const dialog = profileCardMenuElement.$$('#removeConfirmationDialog');
dialog.showModal();
assertTrue(dialog.open);
const statistics = /** @type {!Statistics} */ ({
BrowsingHistory: 1,
});
const statisticsResult = /** @type {!StatisticsResult} */ ({
profilePath: 'anotherProfilePath',
statistics: statistics,
});
webUIListenerCallback('profile-statistics-received', statisticsResult);
const statisticsCountElements =
dialog.querySelector('.statistics').querySelectorAll('.count');
assertNotEquals(
statisticsCountElements[statisticsDataTypes.indexOf('BrowsingHistory')]
.innerText,
'1');
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment