mengw15 commented on code in PR #6759:
URL: https://github.com/apache/texera/pull/6759#discussion_r3627679406
##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-file-renderer/user-dataset-file-renderer.component.spec.ts:
##########
@@ -194,4 +194,45 @@ describe("UserDatasetFileRendererComponent", () => {
expect(getMimeType("")).toBe(MIME_TYPES.OCTET_STREAM);
});
});
+
+ describe("file content loading", () => {
+ it("loadTabularFile sets the header and normalizes row lengths", () => {
Review Comment:
Renamed to state the behavior explicitly — short rows are padded to the
header width and longer rows are kept intact (no truncation to the header).
##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-file-renderer/user-dataset-file-renderer.component.spec.ts:
##########
@@ -194,4 +194,45 @@ describe("UserDatasetFileRendererComponent", () => {
expect(getMimeType("")).toBe(MIME_TYPES.OCTET_STREAM);
});
});
+
+ describe("file content loading", () => {
+ it("loadTabularFile sets the header and normalizes row lengths", () => {
+ (component as unknown as { loadTabularFile: (d: unknown[][]) => void
}).loadTabularFile([
+ ["a", "b", "c"],
+ ["1", "2"],
+ ["x", "y", "z", "w"],
+ ]);
+
+ expect(component.tableDataHeader).toEqual(["a", "b", "c"]);
+ expect(component.tableContent[0]).toEqual(["1", "2", ""]); // short row
padded to the header width
+ expect(component.tableContent[1]).toEqual(["x", "y", "z", "w"]);
+ });
+
+ it("loadTabularFile leaves state unchanged for empty data", () => {
+ component.tableDataHeader = ["keep"];
+ (component as unknown as { loadTabularFile: (d: unknown[][]) => void
}).loadTabularFile([]);
+ expect(component.tableDataHeader).toEqual(["keep"]);
+ });
Review Comment:
Added a `tableContent` sentinel (`[["keep-content"]]`) and now assert it
stays unchanged too, so the test fails if empty data ever resets the content
(verified).
--
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]