Merge "Accept more than one endpoint from the same plugin"
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
index 35e4292..69d7188 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
@@ -115,7 +115,8 @@
     },
 
     _initModule({moduleName, plugin, type, domHook}) {
-      if (this._initializedPlugins.get(plugin.getPluginName())) {
+      const name = plugin.getPluginName() + '.' + moduleName;
+      if (this._initializedPlugins.get(name)) {
         return;
       }
       let initPromise;
@@ -128,10 +129,9 @@
           break;
       }
       if (!initPromise) {
-        console.warn('Unable to initialize module' +
-            `${moduleName} from ${plugin.getPluginName()}`);
+        console.warn('Unable to initialize module ' + name);
       }
-      this._initializedPlugins.set(plugin.getPluginName(), true);
+      this._initializedPlugins.set(name, true);
       initPromise.then(el => {
         domHook.handleInstanceAttached(el);
         this._domHooks.set(el, domHook);
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
index 65a5f08..fa097ac 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
@@ -129,6 +129,22 @@
       });
     });
 
+    test('two modules', done => {
+      plugin.registerCustomComponent('banana', 'mod-one');
+      plugin.registerCustomComponent('banana', 'mod-two');
+      flush(() => {
+        const element =
+            container.querySelector('gr-endpoint-decorator[name="banana"]');
+        const module1 = Polymer.dom(element.root).children.find(
+            element => element.nodeName === 'MOD-ONE');
+        assert.isOk(module1);
+        const module2 = Polymer.dom(element.root).children.find(
+            element => element.nodeName === 'MOD-TWO');
+        assert.isOk(module2);
+        done();
+      });
+    });
+
     test('late param setup', done => {
       const element =
           container.querySelector('gr-endpoint-decorator[name="banana"]');