about summary refs log blame commit diff
path: root/third_party/gerrit/polygerrit-revert-typescript.patch
blob: 4f549ee554d760f44111369f87a36b4f6b4e2bed (plain) (tree)

















































































































































































































                                                                                                                                                      
commit a969f220b8e6e0e8b9f3bab2b1f0b7ec20c3be94
Author: David Ostrovsky <david@ostrovsky.org>
Date:   Mon Mar 29 08:29:17 2021 +0000

    Revert "Convert gr-app_test to typescript"
    
    This reverts commit 56fa576885bf7fbddd38a8af2404ea7e5d1d625f.
    
    Reason for revert: It broke PolyGerrit UI.
    
    Bug: Issue 14300
    Change-Id: Ice0a70801dad8daea0822ce489ae24892c08ebcd

diff --git a/polygerrit-ui/app/elements/gr-app.ts b/polygerrit-ui/app/elements/gr-app.ts
index 463fab920f..2d3289d479 100644
--- a/polygerrit-ui/app/elements/gr-app.ts
+++ b/polygerrit-ui/app/elements/gr-app.ts
@@ -45,7 +45,7 @@ import {installPolymerResin} from '../scripts/polymer-resin-install';
 installPolymerResin(safeTypesBridge);
 
 @customElement('gr-app')
-export class GrApp extends PolymerElement {
+class GrApp extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/gr-app_test.js b/polygerrit-ui/app/elements/gr-app_test.js
new file mode 100644
index 0000000000..8178c89732
--- /dev/null
+++ b/polygerrit-ui/app/elements/gr-app_test.js
@@ -0,0 +1,77 @@
+/**
+ * @license
+ * Copyright (C) 2016 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.
+ */
+
+import '../test/common-test-setup-karma.js';
+import './gr-app.js';
+import {appContext} from '../services/app-context.js';
+import {GerritNav} from './core/gr-navigation/gr-navigation.js';
+import {html} from '@polymer/polymer/lib/utils/html-tag.js';
+import {stubRestApi} from '../test/test-utils.js';
+
+const basicFixture = fixtureFromTemplate(html`<gr-app id="app"></gr-app>`);
+
+suite('gr-app tests', () => {
+  let element;
+  let configStub;
+
+  setup(done => {
+    sinon.stub(appContext.reportingService, 'appStarted');
+    stub('gr-account-dropdown', '_getTopContent');
+    stub('gr-router', 'start');
+    stubRestApi('getAccount').returns(Promise.resolve({}));
+    stubRestApi('getAccountCapabilities').returns(Promise.resolve({}));
+    configStub = stubRestApi('getConfig').returns(Promise.resolve({
+      plugin: {},
+      auth: {
+        auth_type: undefined,
+      },
+    }));
+    stubRestApi('getPreferences').returns(Promise.resolve({my: []}));
+    stubRestApi('getVersion').returns(Promise.resolve(42));
+    stubRestApi('probePath').returns(Promise.resolve(42));
+
+    element = basicFixture.instantiate();
+    flush(done);
+  });
+
+  const appElement = () => element.$['app-element'];
+
+  test('reporting', () => {
+    assert.isTrue(appElement().reporting.appStarted.calledOnce);
+  });
+
+  test('reporting called before router start', () => {
+    const element = appElement();
+    const appStartedStub = element.reporting.appStarted;
+    const routerStartStub = element.$.router.start;
+    sinon.assert.callOrder(appStartedStub, routerStartStub);
+  });
+
+  test('passes config to gr-plugin-host', () =>
+    configStub.lastCall.returnValue.then(config => {
+      assert.deepEqual(appElement().$.plugins.config, config);
+    })
+  );
+
+  test('_paramsChanged sets search page', () => {
+    appElement()._paramsChanged({base: {view: GerritNav.View.CHANGE}});
+    assert.notOk(appElement()._lastSearchPage);
+    appElement()._paramsChanged({base: {view: GerritNav.View.SEARCH}});
+    assert.ok(appElement()._lastSearchPage);
+  });
+});
+
diff --git a/polygerrit-ui/app/elements/gr-app_test.ts b/polygerrit-ui/app/elements/gr-app_test.ts
deleted file mode 100644
index 3583a6a3a2..0000000000
--- a/polygerrit-ui/app/elements/gr-app_test.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 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.
- */
-
-import '../test/common-test-setup-karma';
-import {GrApp} from './gr-app';
-import {appContext} from '../services/app-context';
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-import {queryAndAssert} from '../test/test-utils';
-import {createServerInfo} from '../test/test-data-generators';
-import {GrAppElement} from './gr-app-element';
-import {GrPluginHost} from './plugins/gr-plugin-host/gr-plugin-host';
-import {GerritView} from '../services/router/router-model';
-import {
-  AppElementChangeViewParams,
-  AppElementSearchParam,
-} from './gr-app-types';
-import {GrRouter} from './core/gr-router/gr-router';
-import {ReportingService} from '../services/gr-reporting/gr-reporting';
-
-const basicFixture = fixtureFromTemplate(html`<gr-app id="app"></gr-app>`);
-
-suite('gr-app tests', () => {
-  let element: GrApp;
-  let appStartedStub: sinon.SinonStubbedMember<ReportingService['appStarted']>;
-  let routerStartStub: sinon.SinonStubbedMember<GrRouter['start']>;
-
-  setup(done => {
-    appStartedStub = sinon.stub(appContext.reportingService, 'appStarted');
-    routerStartStub = stub('gr-router', 'start');
-    stub('gr-account-dropdown', '_getTopContent');
-
-    element = basicFixture.instantiate() as GrApp;
-    flush(done);
-  });
-
-  const appElement = () =>
-    queryAndAssert<GrAppElement>(element, '#app-element');
-
-  test('reporting', () => {
-    assert.isTrue(appStartedStub.calledOnce);
-  });
-
-  test('reporting called before router start', () => {
-    sinon.assert.callOrder(appStartedStub, routerStartStub);
-  });
-
-  test('passes config to gr-plugin-host', () => {
-    assert.deepEqual(
-      queryAndAssert<GrPluginHost>(appElement(), 'gr-plugin-host').config,
-      createServerInfo()
-    );
-  });
-
-  test('_paramsChanged sets search page', () => {
-    appElement()._paramsChanged({
-      path: '',
-      value: undefined,
-      base: {view: GerritView.CHANGE} as AppElementChangeViewParams,
-    });
-    assert.notOk(appElement()._lastSearchPage);
-    appElement()._paramsChanged({
-      path: '',
-      value: undefined,
-      base: {view: GerritView.SEARCH} as AppElementSearchParam,
-    });
-    assert.ok(appElement()._lastSearchPage);
-  });
-});
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
index 651eac4e28..ac493a2556 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
@@ -20,7 +20,7 @@ import {customElement, property} from '@polymer/decorators';
 import {ServerInfo} from '../../../types/common';
 
 @customElement('gr-plugin-host')
-export class GrPluginHost extends PolymerElement {
+class GrPluginHost extends PolymerElement {
   @property({type: Object, observer: '_configChanged'})
   config?: ServerInfo;