summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html')
-rw-r--r--polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html226
1 files changed, 219 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html
index 5da8382e85..582ca61db0 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<!--
+@license
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,11 +53,39 @@ limitations under the License.
sandbox.restore();
});
+ test('link visibility', () => {
+ element.loading = true;
+ assert.equal(getComputedStyle(element.$$('.accountContainer')).display,
+ 'none');
+ element.loading = false;
+ element.loggedIn = false;
+ assert.notEqual(getComputedStyle(element.$$('.accountContainer')).display,
+ 'none');
+ assert.notEqual(getComputedStyle(element.$$('.loginButton')).display,
+ 'none');
+ assert.notEqual(getComputedStyle(element.$$('.registerButton')).display,
+ 'none');
+ assert.equal(getComputedStyle(element.$$('gr-account-dropdown')).display,
+ 'none');
+ assert.equal(getComputedStyle(element.$$('.settingsButton')).display,
+ 'none');
+ element.loggedIn = true;
+ assert.equal(getComputedStyle(element.$$('.loginButton')).display,
+ 'none');
+ assert.equal(getComputedStyle(element.$$('.registerButton')).display,
+ 'none');
+ assert.notEqual(getComputedStyle(element.$$('gr-account-dropdown'))
+ .display,
+ 'none');
+ assert.notEqual(getComputedStyle(element.$$('.settingsButton')).display,
+ 'none');
+ });
+
test('fix my menu item', () => {
assert.deepEqual([
{url: 'https://awesometown.com/#hashyhash'},
{url: 'url', target: '_blank'},
- ].map(element._fixMyMenuItem), [
+ ].map(element._fixCustomMenuItem), [
{url: 'https://awesometown.com/#hashyhash', external: true},
{url: 'url', external: true},
]);
@@ -73,7 +102,6 @@ limitations under the License.
]);
});
-
test('user links', () => {
const defaultLinks = [{
title: 'Faves',
@@ -86,15 +114,28 @@ limitations under the License.
name: 'Facebook',
url: 'https://facebook.com',
}];
+ const adminLinks = [{
+ name: 'Repos',
+ url: '/repos',
+ }];
// When no admin links are passed, it should use the default.
- assert.deepEqual(element._computeLinks(defaultLinks, []), defaultLinks);
- assert.deepEqual(
- element._computeLinks(defaultLinks, userLinks),
+ assert.deepEqual(element._computeLinks(defaultLinks, [], adminLinks, []),
defaultLinks.concat({
- title: 'Your',
- links: userLinks,
+ title: 'Browse',
+ links: adminLinks,
}));
+ assert.deepEqual(
+ element._computeLinks(defaultLinks, userLinks, adminLinks, []),
+ defaultLinks.concat([
+ {
+ title: 'Your',
+ links: userLinks,
+ },
+ {
+ title: 'Browse',
+ links: adminLinks,
+ }]));
});
test('documentation links', () => {
@@ -122,5 +163,176 @@ limitations under the License.
url: 'base/index.html',
}]);
});
+
+ test('top menus', () => {
+ const adminLinks = [{
+ name: 'Repos',
+ url: '/repos',
+ }];
+ const topMenus = [{
+ name: 'Plugins',
+ items: [{
+ name: 'Manage',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }];
+ assert.deepEqual(element._computeLinks([], [], adminLinks, topMenus), [{
+ title: 'Browse',
+ links: adminLinks,
+ },
+ {
+ title: 'Plugins',
+ links: [{
+ name: 'Manage',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }]);
+ });
+
+ test('merge top menus', () => {
+ const adminLinks = [{
+ name: 'Repos',
+ url: '/repos',
+ }];
+ const topMenus = [{
+ name: 'Plugins',
+ items: [{
+ name: 'Manage',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }, {
+ name: 'Plugins',
+ items: [{
+ name: 'Create',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/create.html',
+ }],
+ }];
+ assert.deepEqual(element._computeLinks([], [], adminLinks, topMenus), [{
+ title: 'Browse',
+ links: adminLinks,
+ }, {
+ title: 'Plugins',
+ links: [{
+ name: 'Manage',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }, {
+ name: 'Create',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/create.html',
+ }],
+ }]);
+ });
+
+ test('merge top menus in default links', () => {
+ const defaultLinks = [{
+ title: 'Faves',
+ links: [{
+ name: 'Pinterest',
+ url: 'https://pinterest.com',
+ }],
+ }];
+ const topMenus = [{
+ name: 'Faves',
+ items: [{
+ name: 'Manage',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }];
+ assert.deepEqual(element._computeLinks(defaultLinks, [], [], topMenus), [{
+ title: 'Faves',
+ links: defaultLinks[0].links.concat([{
+ name: 'Manage',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }]),
+ }, {
+ title: 'Browse',
+ links: [],
+ }]);
+ });
+
+ test('merge top menus in user links', () => {
+ const userLinks = [{
+ name: 'Facebook',
+ url: 'https://facebook.com',
+ }];
+ const topMenus = [{
+ name: 'Your',
+ items: [{
+ name: 'Manage',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }];
+ assert.deepEqual(element._computeLinks([], userLinks, [], topMenus), [{
+ title: 'Your',
+ links: userLinks.concat([{
+ name: 'Manage',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }]),
+ }, {
+ title: 'Browse',
+ links: [],
+ }]);
+ });
+
+ test('merge top menus in admin links', () => {
+ const adminLinks = [{
+ name: 'Repos',
+ url: '/repos',
+ }];
+ const topMenus = [{
+ name: 'Browse',
+ items: [{
+ name: 'Manage',
+ target: '_blank',
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }],
+ }];
+ assert.deepEqual(element._computeLinks([], [], adminLinks, topMenus), [{
+ title: 'Browse',
+ links: adminLinks.concat([{
+ name: 'Manage',
+ external: true,
+ url: 'https://gerrit/plugins/plugin-manager/static/index.html',
+ }]),
+ }]);
+ });
+
+ test('register URL', () => {
+ const config = {
+ auth: {
+ auth_type: 'LDAP',
+ register_url: 'https//gerrit.example.com/register',
+ },
+ };
+ element._retrieveRegisterURL(config);
+ assert.equal(element._registerURL, config.auth.register_url);
+ assert.equal(element._registerText, 'Sign up');
+
+ config.auth.register_text = 'Create account';
+ element._retrieveRegisterURL(config);
+ assert.equal(element._registerURL, config.auth.register_url);
+ assert.equal(element._registerText, config.auth.register_text);
+ });
+
+ test('register URL ignored for wrong auth type', () => {
+ const config = {
+ auth: {
+ auth_type: 'OPENID',
+ register_url: 'https//gerrit.example.com/register',
+ },
+ };
+ element._retrieveRegisterURL(config);
+ assert.equal(element._registerURL, null);
+ assert.equal(element._registerText, 'Sign up');
+ });
});
</script>