You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by gi...@apache.org on 2026/07/27 21:58:57 UTC
(texera) branch gh-readonly-queue/main/pr-6938-61923c5e4f5699ea2c3a3681c072603bc2da6bbc created (now e08d3e6b42)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-6938-61923c5e4f5699ea2c3a3681c072603bc2da6bbc
in repository https://gitbox.apache.org/repos/asf/texera.git
at e08d3e6b42 test(frontend): add unit tests for serializePortIdentity (#6938)
This branch includes the following new commits:
new e08d3e6b42 test(frontend): add unit tests for serializePortIdentity (#6938)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(texera) 01/01: test(frontend): add unit tests for serializePortIdentity (#6938)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6938-61923c5e4f5699ea2c3a3681c072603bc2da6bbc
in repository https://gitbox.apache.org/repos/asf/texera.git
commit e08d3e6b423b960aa95a41d97b6275b7818b9476
Author: Ranjani Veena Belavadi <16...@users.noreply.github.com>
AuthorDate: Mon Jul 27 14:58:45 2026 -0700
test(frontend): add unit tests for serializePortIdentity (#6938)
### What changes were proposed in this PR?
Adds `port-identity-serde.spec.ts` to cover `serializePortIdentity`, a
previously untested pure utility function in `common/util/` that
serializes a `PortIdentity` into the stable string key `id_internal`.
This format is one half of a cross-language contract: the backend
produces the identical string in
`PortIdentityKeySerializer.portIdToString` and reads it back by
splitting on `"_"` in `PortIdentityKeyDeserializer`. A format mismatch
on either side would cause the frontend's schema lookup to silently
return `undefined` rather than fail, so the exact output is worth
pinning.
Covers four groups of behavior:
- **Format**: exact key for external and internal ports, including the
`id: 0` falsy-number boundary and large and negative ids passing through
unvalidated. These mirror `PortIdentityKeySerializerSpec.scala`'s case
table exactly, so both ends of the contract are now pinned by matching
assertions.
- **Distinctness**: ports differing only by `id`, or only by `internal`,
cannot collide on the same key.
- **Stability**: equal inputs always serialize identically.
- **Real usage**: the key works for object lookup when generated
independently at write and read time, and remains splittable into
exactly two fields for the backend deserializer.
No production code was changed.
### Any related issues, documentation, discussions?
Closes #6631
### How was this PR tested?
Added 12 new unit tests in `port-identity-serde.spec.ts` covering all
behavior described in the issue. Ran locally via `ng test --include
src/app/common/util/port-identity-serde.spec.ts --watch=false`; all 12
pass. Full suite also green via `yarn test` (3817 passed, 2 skipped, 198
files).
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)
Co-authored-by: Yicong Huang <17...@users.noreply.github.com>
---
.../app/common/util/port-identity-serde.spec.ts | 80 ++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/frontend/src/app/common/util/port-identity-serde.spec.ts b/frontend/src/app/common/util/port-identity-serde.spec.ts
new file mode 100644
index 0000000000..b11b27d4db
--- /dev/null
+++ b/frontend/src/app/common/util/port-identity-serde.spec.ts
@@ -0,0 +1,80 @@
+/**
+ * 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 { serializePortIdentity } from "./port-identity-serde";
+import { PortIdentity } from "../type/proto/org/apache/texera/amber/core/workflow";
+
+describe("serializePortIdentity", () => {
+ it("should serialize an external port as id_internal", () => {
+ expect(serializePortIdentity({ id: 3, internal: false })).toBe("3_false");
+ });
+
+ it("should serialize an internal port", () => {
+ expect(serializePortIdentity({ id: 0, internal: true })).toBe("0_true");
+ });
+
+ it("should serialize port id zero", () => {
+ expect(serializePortIdentity({ id: 0, internal: false })).toBe("0_false");
+ });
+
+ it("should serialize a large multi-digit port id", () => {
+ expect(serializePortIdentity({ id: 999999, internal: false })).toBe("999999_false");
+ });
+
+ it("should serialize a large multi-digit internal port id", () => {
+ expect(serializePortIdentity({ id: 999999, internal: true })).toBe("999999_true");
+ });
+
+ it("should pass a negative port id through without validation", () => {
+ expect(serializePortIdentity({ id: -1, internal: false })).toBe("-1_false");
+ });
+
+ it("should pass a negative internal port id through without validation", () => {
+ expect(serializePortIdentity({ id: -1, internal: true })).toBe("-1_true");
+ });
+
+ it("should produce different keys for internal and external ports with the same id", () => {
+ expect(serializePortIdentity({ id: 0, internal: true })).not.toBe(
+ serializePortIdentity({ id: 0, internal: false })
+ );
+ });
+
+ it("should produce different keys for different ids", () => {
+ expect(serializePortIdentity({ id: 0, internal: false })).not.toBe(
+ serializePortIdentity({ id: 1, internal: false })
+ );
+ });
+
+ it("should be deterministic for equal inputs", () => {
+ const first: PortIdentity = { id: 5, internal: true };
+ const second: PortIdentity = { id: 5, internal: true };
+ expect(serializePortIdentity(first)).toBe(serializePortIdentity(second));
+ });
+
+ it("should work as an object key for schema lookup", () => {
+ const key = serializePortIdentity({ id: 1, internal: false });
+ const schemaByPort: Record<string, string> = { [key]: "my-schema" };
+ const lookupKey = serializePortIdentity({ id: 1, internal: false });
+ expect(schemaByPort[lookupKey]).toBe("my-schema");
+ });
+
+ it("should stay parseable by the backend deserializer format", () => {
+ expect(serializePortIdentity({ id: 3, internal: false }).split("_")).toEqual(["3", "false"]);
+ });
+});