
When the server config reports `note_db_enabled` is true, we have the opportunity to display reviewers by state. There are just two states we care about: `REVIEWER` and `CC`. Reviewers in the `REVIEWER` state will continue to be managed in the existing "Reviewers" fields in <gr-change-metadata> and <gr-reply-dialog>. We need similar but separate "CC" fields in the same elements for managing reviewers in the `CC` state. Because the reply dialog may now have two editable account lists, the logic for tracking reviewer state and filtering autocomplete suggestions needs to move to <gr-reply-dialog>. In particular, we don't want pending additions in one field to show up as suggestions in the other field. We also need to make sure that the large group confirmation overlay can handle confirmations for either field, and return focus to the right element when closed. Feature: Issue 3810 Change-Id: Id5111220906ad728707087f6fb2ddb085c34a9b8
122 lines
3.8 KiB
HTML
122 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Copyright (C) 2016 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
<title>gr-account-entry</title>
|
|
|
|
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
|
<script src="../../../bower_components/web-component-tester/browser.js"></script>
|
|
<script src="../../../scripts/util.js"></script>
|
|
|
|
<link rel="import" href="../../../bower_components/iron-test-helpers/iron-test-helpers.html">
|
|
<link rel="import" href="gr-account-entry.html">
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-account-entry></gr-account-entry>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-account-entry tests', function() {
|
|
var _nextAccountId = 0;
|
|
var makeAccount = function() {
|
|
var accountId = ++_nextAccountId;
|
|
return {
|
|
_account_id: accountId,
|
|
name: 'name ' + accountId,
|
|
email: 'email ' + accountId,
|
|
};
|
|
};
|
|
|
|
var owner;
|
|
var existingReviewer1;
|
|
var existingReviewer2;
|
|
var suggestion1;
|
|
var suggestion2;
|
|
var suggestion3;
|
|
var element;
|
|
|
|
setup(function() {
|
|
owner = makeAccount();
|
|
existingReviewer1 = makeAccount();
|
|
existingReviewer2 = makeAccount();
|
|
suggestion1 = {account: makeAccount()};
|
|
suggestion2 = {account: makeAccount()};
|
|
suggestion3 = {
|
|
group: {
|
|
id: 'suggested group id',
|
|
name: 'suggested group',
|
|
},
|
|
};
|
|
|
|
element = fixture('basic');
|
|
element.change = {
|
|
owner: owner,
|
|
reviewers: {
|
|
CC: [existingReviewer1],
|
|
REVIEWER: [existingReviewer2],
|
|
},
|
|
};
|
|
|
|
stub('gr-rest-api-interface', {
|
|
getChangeSuggestedReviewers: function() {
|
|
var redundantSuggestion1 = {account: existingReviewer1};
|
|
var redundantSuggestion2 = {account: existingReviewer2};
|
|
var redundantSuggestion3 = {account: owner};
|
|
return Promise.resolve([redundantSuggestion1, redundantSuggestion2,
|
|
redundantSuggestion3, suggestion1, suggestion2, suggestion3]);
|
|
},
|
|
});
|
|
});
|
|
|
|
test('_makeSuggestion formats account or group accordingly', function() {
|
|
var account = makeAccount();
|
|
var suggestion = element._makeSuggestion({account: account});
|
|
assert.deepEqual(suggestion, {
|
|
name: account.name + ' (' + account.email + ')',
|
|
value: {account: account},
|
|
});
|
|
|
|
var group = {name: 'test'};
|
|
suggestion = element._makeSuggestion({group: group});
|
|
assert.deepEqual(suggestion, {
|
|
name: group.name + ' (group)',
|
|
value: {group: group},
|
|
});
|
|
});
|
|
|
|
test('_getReviewerSuggestions excludes owner+reviewers', function(done) {
|
|
element._getReviewerSuggestions().then(function(reviewers) {
|
|
// Default is no filtering.
|
|
assert.equal(reviewers.length, 6);
|
|
|
|
// Set up filter that only accepts suggestion1.
|
|
var accountId = suggestion1.account._account_id;
|
|
element.filter = function(suggestion) {
|
|
return suggestion.account &&
|
|
suggestion.account._account_id === accountId;
|
|
};
|
|
|
|
element._getReviewerSuggestions().then(function(reviewers) {
|
|
assert.deepEqual(reviewers, [element._makeSuggestion(suggestion1)]);
|
|
}).then(done);
|
|
});
|
|
});
|
|
});
|
|
</script>
|