This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 0ba5d1a22a test(frontend): add unit tests for execute-workflow guards 
(#6649)
0ba5d1a22a is described below

commit 0ba5d1a22a3baaa61a36d1bbb8c4573d40e89b5c
Author: Matthew B. <[email protected]>
AuthorDate: Wed Jul 22 22:08:22 2026 -0700

    test(frontend): add unit tests for execute-workflow guards (#6649)
    
    ### What changes were proposed in this PR?
    - Add
    `frontend/src/app/workspace/types/execute-workflow.interface.spec.ts`, a
    new Vitest spec for the execute-workflow type guards, which previously
    had no dedicated unit tests.
    - Cover isWebPaginationUpdate (pagination vs snapshot/delta) and
    isWebDataUpdate (snapshot/delta vs pagination).
    - Cover isNotInExecution for all four terminal/uninitialized states
    (true) and the seven active states (false).
    ### Any related issues, documentation, discussions?
    Closes: #6648
    ### How was this PR tested?
    - Run: `cd frontend && node --max-old-space-size=8192
    ./node_modules/nx/dist/bin/nx.js test gui --watch=false
    --include=src/app/workspace/types/execute-workflow.interface.spec.ts`,
    expect all 6 tests passing.
    - Test-only change; no production code is modified.
    ### Was this PR authored or co-authored using generative AI tooling?
    Co-authored with Claude Opus 4.8 in compliance with ASF
    
    ---------
    
    Co-authored-by: Claude Opus 4.8 <[email protected]>
    Co-authored-by: Xinyuan Lin <[email protected]>
---
 .../types/execute-workflow.interface.spec.ts       | 88 ++++++++++++++++++++++
 .../workspace/types/execute-workflow.interface.ts  |  2 +-
 2 files changed, 89 insertions(+), 1 deletion(-)

diff --git 
a/frontend/src/app/workspace/types/execute-workflow.interface.spec.ts 
b/frontend/src/app/workspace/types/execute-workflow.interface.spec.ts
new file mode 100644
index 0000000000..04cab470b4
--- /dev/null
+++ b/frontend/src/app/workspace/types/execute-workflow.interface.spec.ts
@@ -0,0 +1,88 @@
+/**
+ * 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);
+  });
+
+  it("returns false for an undefined update without throwing", () => {
+    expect(isWebDataUpdate(undefined as any)).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);
+  });
+});
diff --git a/frontend/src/app/workspace/types/execute-workflow.interface.ts 
b/frontend/src/app/workspace/types/execute-workflow.interface.ts
index 1fc99e7a60..8bb7696edf 100644
--- a/frontend/src/app/workspace/types/execute-workflow.interface.ts
+++ b/frontend/src/app/workspace/types/execute-workflow.interface.ts
@@ -135,7 +135,7 @@ export function isWebPaginationUpdate(update: 
WebResultUpdate): update is WebPag
 }
 
 export function isWebDataUpdate(update: WebResultUpdate): update is 
WebDataUpdate {
-  return (update !== undefined && update.mode.type === "SetSnapshotMode") || 
update.mode.type === "SetDeltaMode";
+  return update !== undefined && (update.mode.type === "SetSnapshotMode" || 
update.mode.type === "SetDeltaMode");
 }
 
 export function isNotInExecution(state: ExecutionState) {

Reply via email to