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


##########
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:
   Good catch, this was a real bug. I moved the parentheses so the `undefined` 
check guards both mode comparisons, and added a regression test that 
`isWebDataUpdate(undefined)` returns false without throwing.
   



##########
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:
   Making `Terminated` a non-execution state changes production behavior and 
could affect the UI, so I would rather handle it in a separate PR and keep this 
one test-only.
   



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