Copilot commented on code in PR #6649:
URL: https://github.com/apache/texera/pull/6649#discussion_r3617802174


##########
frontend/src/app/workspace/types/execute-workflow.interface.spec.ts:
##########
@@ -0,0 +1,84 @@
+/**
+ * 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 {
+  ExecutionState,
+  isNotInExecution,
+  isWebDataUpdate,
+  isWebPaginationUpdate,
+  WebDataUpdate,
+  WebPaginationUpdate,
+} from "./execute-workflow.interface";
+
+const paginationUpdate: WebPaginationUpdate = {
+  mode: { type: "PaginationMode" },
+  totalNumTuples: 10,
+  dirtyPageIndices: [1, 2],
+};
+
+const snapshotUpdate: WebDataUpdate = {
+  mode: { type: "SetSnapshotMode" },
+  table: [{ a: 1 }],
+};
+
+const deltaUpdate: WebDataUpdate = {
+  mode: { type: "SetDeltaMode" },
+  table: [{ b: 2 }],
+};
+
+describe("isWebPaginationUpdate", () => {
+  it("returns true for a pagination-mode update", () => {
+    expect(isWebPaginationUpdate(paginationUpdate)).toBe(true);
+  });
+
+  it("returns false for snapshot- and delta-mode updates", () => {
+    expect(isWebPaginationUpdate(snapshotUpdate)).toBe(false);
+    expect(isWebPaginationUpdate(deltaUpdate)).toBe(false);
+  });
+});
+
+describe("isWebDataUpdate", () => {
+  it("returns true for snapshot- and delta-mode updates", () => {
+    expect(isWebDataUpdate(snapshotUpdate)).toBe(true);
+    expect(isWebDataUpdate(deltaUpdate)).toBe(true);
+  });
+
+  it("returns false for a pagination-mode update", () => {
+    expect(isWebDataUpdate(paginationUpdate)).toBe(false);
+  });
+});
+
+describe("isNotInExecution", () => {
+  it("returns true for terminal or uninitialized states", () => {
+    expect(isNotInExecution(ExecutionState.Uninitialized)).toBe(true);
+    expect(isNotInExecution(ExecutionState.Failed)).toBe(true);
+    expect(isNotInExecution(ExecutionState.Killed)).toBe(true);
+    expect(isNotInExecution(ExecutionState.Completed)).toBe(true);
+  });
+
+  it("returns false for active execution states", () => {
+    expect(isNotInExecution(ExecutionState.Initializing)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Running)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Pausing)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Paused)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Resuming)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Recovering)).toBe(false);
+    expect(isNotInExecution(ExecutionState.Terminated)).toBe(false);

Review Comment:
   `ExecutionState.Terminated` is treated like a terminal/idle state elsewhere 
in the UI (e.g., the menu shows "Run" for Terminated and workflow modification 
is enabled), but this spec currently asserts 
`isNotInExecution(ExecutionState.Terminated)` is `false`. That codifies an 
inconsistent behavior and would make it harder to correct `isNotInExecution` to 
match the rest of the frontend.
   
   If Terminated is intended to be idle, update the expectation to `true` and 
include `ExecutionState.Terminated` in `isNotInExecution`’s terminal set.



##########
frontend/src/app/workspace/types/execute-workflow.interface.spec.ts:
##########
@@ -0,0 +1,84 @@
+/**
+ * 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 {
+  ExecutionState,
+  isNotInExecution,
+  isWebDataUpdate,
+  isWebPaginationUpdate,
+  WebDataUpdate,
+  WebPaginationUpdate,
+} from "./execute-workflow.interface";
+
+const paginationUpdate: WebPaginationUpdate = {
+  mode: { type: "PaginationMode" },
+  totalNumTuples: 10,
+  dirtyPageIndices: [1, 2],
+};
+
+const snapshotUpdate: WebDataUpdate = {
+  mode: { type: "SetSnapshotMode" },
+  table: [{ a: 1 }],
+};
+
+const deltaUpdate: WebDataUpdate = {
+  mode: { type: "SetDeltaMode" },
+  table: [{ b: 2 }],
+};
+
+describe("isWebPaginationUpdate", () => {
+  it("returns true for a pagination-mode update", () => {
+    expect(isWebPaginationUpdate(paginationUpdate)).toBe(true);
+  });
+
+  it("returns false for snapshot- and delta-mode updates", () => {
+    expect(isWebPaginationUpdate(snapshotUpdate)).toBe(false);
+    expect(isWebPaginationUpdate(deltaUpdate)).toBe(false);
+  });
+});
+
+describe("isWebDataUpdate", () => {
+  it("returns true for snapshot- and delta-mode updates", () => {
+    expect(isWebDataUpdate(snapshotUpdate)).toBe(true);
+    expect(isWebDataUpdate(deltaUpdate)).toBe(true);
+  });

Review Comment:
   The current `isWebDataUpdate` implementation in 
`execute-workflow.interface.ts` can throw at runtime for `undefined` inputs due 
to `... || update.mode.type === "SetDeltaMode"` not being guarded by `update 
!== undefined`. These tests only cover valid updates, so they won’t catch that 
crash path.
   
   Consider adding a regression test that calls `isWebDataUpdate(undefined as 
unknown as any)` and expects it to return `false` (and not throw), and then 
fixing the guard implementation accordingly (e.g., guard `update` before 
reading `mode.type`).



-- 
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