
Account links now go to /dashboard/NAME, where NAME is the account's email address (or username or account ID as fallbacks). Change-Id: Ib51c40eb8764e22570e002def6c4a72adfbcffa2
101 lines
3.1 KiB
HTML
101 lines
3.1 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-dashboard-view</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-dashboard-view.html">
|
|
|
|
<script>void(0);</script>
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-dashboard-view></gr-dashboard-view>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-dashboard-view tests', () => {
|
|
let element;
|
|
let sandbox;
|
|
|
|
setup(() => {
|
|
element = fixture('basic');
|
|
sandbox = sinon.sandbox.create();
|
|
getChangesStub = sandbox.stub(element.$.restAPI, 'getChanges',
|
|
() => Promise.resolve());
|
|
});
|
|
|
|
teardown(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
test('nothing happens when user param is falsy', () => {
|
|
element.params = {};
|
|
flushAsynchronousOperations();
|
|
assert.equal(getChangesStub.callCount, 0);
|
|
|
|
element.params = {user: ''};
|
|
flushAsynchronousOperations();
|
|
assert.equal(getChangesStub.callCount, 0);
|
|
});
|
|
|
|
test('content is refreshed when user param is updated', () => {
|
|
element.params = {user: 'self'};
|
|
flushAsynchronousOperations();
|
|
assert.equal(getChangesStub.callCount, 1);
|
|
});
|
|
|
|
test('viewing another user\'s dashboard omits selfOnly sections', () => {
|
|
element._sectionMetadata = [
|
|
{query: '1'},
|
|
{query: '2', selfOnly: true},
|
|
];
|
|
|
|
element.params = {user: 'self'};
|
|
flushAsynchronousOperations();
|
|
assert.isTrue(
|
|
getChangesStub.calledWith(null, ['1', '2'], null, element.options));
|
|
|
|
element.params = {user: 'user'};
|
|
flushAsynchronousOperations();
|
|
assert.isTrue(
|
|
getChangesStub.calledWith(null, ['1'], null, element.options));
|
|
});
|
|
|
|
test('_dashboardQueryForSection', () => {
|
|
const query = 'query for ${user}';
|
|
const suffixForDashboard = 'suffix for ${user}';
|
|
assert.equal(
|
|
element._dashboardQueryForSection({query}, 'user'),
|
|
'query for user');
|
|
assert.equal(
|
|
element._dashboardQueryForSection(
|
|
{query, suffixForDashboard}, 'user'),
|
|
'query for user suffix for user');
|
|
});
|
|
|
|
test('_computeTitle', () => {
|
|
assert.equal(element._computeTitle('self'), 'My Reviews');
|
|
assert.equal(element._computeTitle('not self'), 'Dashboard for not self');
|
|
});
|
|
});
|
|
</script>
|