Ma77Ball commented on code in PR #5849:
URL: https://github.com/apache/texera/pull/5849#discussion_r3480279223


##########
frontend/src/app/app.component.spec.ts:
##########
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 { CommonModule } from "@angular/common";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { RouterTestingModule } from "@angular/router/testing";
+import { AppComponent } from "./app.component";
+import { GuiConfigService } from "./common/service/gui-config.service";
+import { DeploymentVersionService } from 
"./common/service/deployment-version/deployment-version.service";
+import { Version } from "../environments/version";
+
+// GuiConfigService stub whose env getter either returns a value or throws,
+// mirroring "config loaded" vs "config failed to load by APP_INITIALIZER".
+class StubGuiConfigService {
+  shouldThrow = false;
+  deploymentVersionCheckEnabled = true;
+  get env(): unknown {
+    if (this.shouldThrow) {
+      throw new Error("config not loaded");
+    }
+    return { deploymentVersionCheckEnabled: this.deploymentVersionCheckEnabled 
};
+  }
+}
+
+// Records start() invocations without a spy framework.
+class FakeDeploymentVersionService {

Review Comment:
   Done. Uses the real service with `vi.spyOn(service, 
"startPollingForUpdates")` instead of a fake.



##########
frontend/src/app/app.component.ts:
##########
@@ -40,7 +42,10 @@ import { UntilDestroy } from "@ngneat/until-destroy";
 export class AppComponent {
   configLoaded = false;
 
-  constructor(private config: GuiConfigService) {
+  constructor(
+    private config: GuiConfigService,
+    private deploymentVersion: DeploymentVersionService

Review Comment:
   Done. Renamed to `configService` and `deploymentVersionService`.



##########
frontend/src/app/app.component.ts:
##########
@@ -49,6 +54,13 @@ export class AppComponent {
     } catch {
       this.configLoaded = false;
     }
+
+    // Poll for new deployments only when the config opts in (off by default),
+    // config actually loaded, and this isn't the "dev" placeholder build where
+    // no deployments occur.
+    if (this.configLoaded && this.config.env.deploymentVersionCheckEnabled && 
Version.buildNumber !== "dev") {
+      this.deploymentVersion.start();

Review Comment:
   Done. Renamed `start()` to `startPollingForUpdates()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to