
This is a partial roll-forward of c/106190. It adds a dependency on the latest version of polymer-resin. Later CLs will actually use this dependency. Change-Id: I3cf5f9c823d74da58a8b1326153a672959fa3f13
131 lines
3.5 KiB
HTML
131 lines
3.5 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-admin-group-list</title>
|
|
|
|
<script src="../../../bower_components/page/page.js"></script>
|
|
<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-admin-group-list.html">
|
|
|
|
<script>void(0);</script>
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-admin-group-list></gr-admin-group-list>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
let counter = 0;
|
|
const groupGenerator = () => {
|
|
return {
|
|
name: `test${++counter}`,
|
|
id: '59b92f35489e62c80d1ab1bf0c2d17843038df8b',
|
|
url: '#/admin/groups/uuid-59b92f35489e62c80d1ab1bf0c2d17843038df8b',
|
|
options: {
|
|
visible_to_all: false,
|
|
},
|
|
description: 'Gerrit Site Administrators',
|
|
group_id: 1,
|
|
owner: 'Administrators',
|
|
owner_id: '7ca042f4d5847936fcb90ca91057673157fd06fc',
|
|
};
|
|
};
|
|
|
|
suite('gr-admin-group-list tests', () => {
|
|
let element;
|
|
let groups;
|
|
let sandbox;
|
|
let value;
|
|
|
|
setup(() => {
|
|
sandbox = sinon.sandbox.create();
|
|
element = fixture('basic');
|
|
});
|
|
|
|
teardown(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
suite('list with groups', () => {
|
|
setup(done => {
|
|
groups = _.times(26, groupGenerator);
|
|
|
|
stub('gr-rest-api-interface', {
|
|
getGroups(num, offset) {
|
|
return Promise.resolve(groups);
|
|
},
|
|
});
|
|
|
|
element._paramsChanged(value).then(() => { flush(done); });
|
|
});
|
|
|
|
test('test for test group in the list', done => {
|
|
flush(() => {
|
|
assert.equal(element._groups[1].name, 'test2');
|
|
assert.equal(element._groups[1].options.visible_to_all, false);
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('_shownGroups', () => {
|
|
assert.equal(element._shownGroups.length, 25);
|
|
});
|
|
});
|
|
|
|
suite('test with less then 25 groups', () => {
|
|
setup(done => {
|
|
groups = _.times(25, groupGenerator);
|
|
|
|
stub('gr-rest-api-interface', {
|
|
getGroups(num, offset) {
|
|
return Promise.resolve(groups);
|
|
},
|
|
});
|
|
|
|
element._paramsChanged(value).then(() => { flush(done); });
|
|
});
|
|
|
|
test('_shownGroups', () => {
|
|
assert.equal(element._shownGroups.length, 25);
|
|
});
|
|
});
|
|
|
|
suite('filter', () => {
|
|
test('_paramsChanged', done => {
|
|
sandbox.stub(element.$.restAPI, 'getGroups', () => {
|
|
return Promise.resolve(groups);
|
|
});
|
|
const value = {
|
|
filter: 'test',
|
|
offset: 25,
|
|
};
|
|
element._paramsChanged(value).then(() => {
|
|
assert.isTrue(element.$.restAPI.getGroups.lastCall
|
|
.calledWithExactly('test', 25, 25));
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
</script>
|