3df4b92863
* This uses gr-account-link where possible except if the rest api returns id which only groups return. * This will not add a url if it is not a user or does not include url in the rest api. * This makes gr-group-audit-log show users avatars thus makes the page look alot better. Change-Id: I1d227953a997ebe7ab72ce0dd12cbf6c5105bbc5
116 lines
3.1 KiB
HTML
116 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
@license
|
|
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;
|
|
let sandbox;
|
|
|
|
setup(() => {
|
|
sandbox = sinon.sandbox.create();
|
|
element = fixture('basic');
|
|
});
|
|
|
|
teardown(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
suite('members', () => {
|
|
test('test _getNameForGroup', () => {
|
|
let group = {
|
|
member: {
|
|
name: 'test-name',
|
|
},
|
|
};
|
|
assert.equal(element._getNameForGroup(group.member), 'test-name');
|
|
|
|
group = {
|
|
member: {
|
|
id: 'test-id',
|
|
},
|
|
};
|
|
assert.equal(element._getNameForGroup(group.member), 'test-id');
|
|
});
|
|
|
|
test('test _isGroupEvent', () => {
|
|
assert.isTrue(element._isGroupEvent('ADD_GROUP'));
|
|
assert.isTrue(element._isGroupEvent('REMOVE_GROUP'));
|
|
|
|
assert.isFalse(element._isGroupEvent('ADD_USER'));
|
|
assert.isFalse(element._isGroupEvent('REMOVE_USER'));
|
|
});
|
|
});
|
|
|
|
suite('users', () => {
|
|
test('test _getIdForUser', () => {
|
|
const account = {
|
|
user: {
|
|
username: 'test-user',
|
|
_account_id: 12,
|
|
},
|
|
};
|
|
assert.equal(element._getIdForUser(account.user), ' (12)');
|
|
});
|
|
|
|
test('test _account_id not present', () => {
|
|
const account = {
|
|
user: {
|
|
username: 'test-user',
|
|
},
|
|
};
|
|
assert.equal(element._getIdForUser(account.user), '');
|
|
});
|
|
});
|
|
|
|
suite('404', () => {
|
|
test('fires page-error', done => {
|
|
element.groupId = 1;
|
|
|
|
const response = {status: 404};
|
|
sandbox.stub(
|
|
element.$.restAPI, 'getGroupAuditLog', (group, errFn) => {
|
|
errFn(response);
|
|
});
|
|
|
|
element.addEventListener('page-error', e => {
|
|
assert.deepEqual(e.detail.response, response);
|
|
done();
|
|
});
|
|
|
|
element._getAuditLogs();
|
|
});
|
|
});
|
|
});
|
|
</script>
|