Files
gerrit/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.html
Becky Siegel d8e1b270b5 Fix blank audit log names
The GWT UI fell back to displaying email addresses (everything before
the @) if a user did not have a name or username.

This change adds the same fallback to PolyGerrit.

Bug: Issue 7989
Change-Id: Ieff1cc6a0faf9ecb1aafebf91d86f91ab89582f1
2017-12-21 22:46:12 +00:00

122 lines
3.2 KiB
HTML

<!DOCTYPE html>
<!--
Copyright (C) 2017 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-group-audit-log</title>
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script src="../../../bower_components/web-component-tester/browser.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<link rel="import" href="gr-group-audit-log.html">
<script>void(0);</script>
<test-fixture id="basic">
<template>
<gr-group-audit-log></gr-group-audit-log>
</template>
</test-fixture>
<script>
suite('gr-group-audit-log tests', () => {
let element;
setup(() => {
element = fixture('basic');
});
suite('members', () => {
test('test getNameForMember', () => {
let account = {
member: {
username: 'test-user',
_account_id: 12,
},
};
assert.equal(element._getNameForMember(account.member, false),
'test-user');
account = {
member: {
name: 'test-name',
_account_id: 12,
},
};
assert.equal(element._getNameForMember(account.member), 'test-name');
account = {
user: {
email: 'test-email@gmail.com',
},
};
assert.equal(element._getNameForMember(account.user), 'test-email');
});
});
suite('users', () => {
test('test _getName', () => {
let account = {
user: {
username: 'test-user',
_account_id: 12,
},
};
assert.equal(element._getNameForUser(account.user), 'test-user (12)');
account = {
user: {
name: 'test-name',
_account_id: 12,
},
};
assert.equal(element._getNameForUser(account.user), 'test-name (12)');
account = {
user: {
email: 'test-email@gmail.com',
_account_id: 12,
},
};
assert.equal(element._getNameForUser(account.user), 'test-email (12)');
});
test('test _account_id not present', () => {
let account = {
user: {
username: 'test-user',
},
};
assert.equal(element._getNameForUser(account.user), 'test-user');
account = {
user: {
name: 'test-name',
},
};
assert.equal(element._getNameForUser(account.user), 'test-name');
account = {
user: {
email: 'test-email@gmail.com',
},
};
assert.equal(element._getNameForUser(account.user), 'test-email');
});
});
});
</script>