Rename getChangeDetail in gr-change-view

getChangeDetail in GrChangeView isn't requesting the ChangeDetail
anymore, it's the responsibility of ChangeModel instead so update the
method name.

Change-Id: I86d93b685e0efc045795b1220df95c09846d8f0f
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 2625bf5..4c9c80e 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -1893,7 +1893,13 @@
     });
   }
 
-  _getChangeDetail() {
+  /**
+   * Process edits
+   * Check if a revert of this change has been submitted
+   * Calculate selected revision
+   */
+  // private but used in tests
+  performPostChangeLoadTasks() {
     if (!this._changeNum) {
       throw new Error('missing required changeNum property');
     }
@@ -2098,7 +2104,11 @@
 
     // Resolves when the change detail and the edit patch set (if available)
     // are loaded.
-    const detailCompletes = this._getChangeDetail();
+    const detailCompletes = until(
+      this.changeModel.changeLoadingStatus$,
+      status => status === LoadingStatus.LOADED
+    );
+    this.performPostChangeLoadTasks();
     allDataPromises.push(detailCompletes);
 
     // Resolves when the loading flag is set to false, meaning that some
@@ -2120,8 +2130,8 @@
       });
 
     // Resolves when the project config has successfully loaded.
-    const projectConfigLoaded = detailCompletes.then(success => {
-      if (!success) return Promise.resolve();
+    const projectConfigLoaded = detailCompletes.then(() => {
+      if (!this._change) return Promise.resolve();
       return this._getProjectConfig();
     });
     allDataPromises.push(projectConfigLoaded);
@@ -2142,8 +2152,6 @@
         loadingFlagSet,
       ]);
 
-      // _getChangeDetail triggers reload of change actions already.
-
       // The core data is loaded when mergeability is known.
       coreDataPromise = detailAndPatchResourcesLoaded.then(() =>
         this._getMergeability()
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index 7114217..2f3e8e6 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -1548,7 +1548,7 @@
       },
     });
 
-    await element._getChangeDetail();
+    await element.performPostChangeLoadTasks();
     assert.isNull(element._change!.topic);
   });
 
@@ -1564,7 +1564,7 @@
       },
     });
 
-    await element._getChangeDetail();
+    await element.performPostChangeLoadTasks();
     assert.equal('foo', element._commitInfo!.commit);
   });
 
@@ -1594,7 +1594,7 @@
     );
     element._patchRange = {};
 
-    return element._getChangeDetail().then(() => {
+    return element.performPostChangeLoadTasks().then(() => {
       const revs = element._change!.revisions!;
       assert.equal(Object.keys(revs).length, 2);
       assert.deepEqual(revs['foo'], changeRevision);
@@ -2011,7 +2011,7 @@
       .stub(element, '_getPreferences')
       .returns(Promise.resolve(createPreferences()));
     element._patchRange = {patchNum: 2 as RevisionPatchSetNum};
-    return element._getChangeDetail().then(() => {
+    return element.performPostChangeLoadTasks().then(() => {
       assert.strictEqual(element._selectedRevision, revision2);
 
       element.set('_patchRange.patchNum', '1');
@@ -2042,7 +2042,7 @@
       .stub(element, '_getPreferences')
       .returns(Promise.resolve(createPreferences()));
     element._patchRange = {patchNum: EditPatchSetNum};
-    return element._getChangeDetail().then(() => {
+    return element.performPostChangeLoadTasks().then(() => {
       assert.strictEqual(element._selectedRevision, revision3);
     });
   });
@@ -2263,7 +2263,9 @@
         basePatchNum: ParentPatchSetNum,
         patchNum: 1 as RevisionPatchSetNum,
       };
-      sinon.stub(element, '_getChangeDetail').returns(Promise.resolve(false));
+      sinon
+        .stub(element, 'performPostChangeLoadTasks')
+        .returns(Promise.resolve(false));
       sinon.stub(element, '_getProjectConfig').returns(Promise.resolve());
       sinon.stub(element, '_getMergeability').returns(Promise.resolve());
       sinon.stub(element, '_getLatestCommitMessage').returns(Promise.resolve());
@@ -2303,6 +2305,15 @@
         changeNum: TEST_NUMERIC_CHANGE_ID,
         project: TEST_PROJECT_NAME,
       };
+      element.changeModel.setState({
+        loadingStatus: LoadingStatus.LOADED,
+        change: {
+          ...createChangeViewChange(),
+          labels: {},
+          current_revision: 'foo' as CommitId,
+          revisions: {foo: createRevision()},
+        },
+      });
       await flush();
       assert.isTrue(changeDisplayStub.called);
       assert.isTrue(changeFullyLoadedStub.called);