aglinxinyuan commented on code in PR #6771:
URL: https://github.com/apache/texera/pull/6771#discussion_r3627783987
##########
frontend/src/app/dashboard/component/user/share-access/share-access.component.spec.ts:
##########
@@ -512,4 +512,208 @@ describe("ShareAccessComponent", () => {
expect(notificationSpy.success).toHaveBeenCalledWith("Dataset
unpublished successfully");
});
});
+
+ describe("hasWriteAccess without a resolved email", () => {
+ it("returns false when the current user has no email at all", () => {
+ // an empty string makes the stubbed UserService.getCurrentUser return
undefined,
+ // so this.currentEmail resolves to undefined and the early-return guard
is exercised
+ const c = setupComponent({ currentEmail: "" });
+ expect(c.currentEmail).toBeUndefined();
+ expect(c.hasWriteAccess).toBe(false);
+ });
Review Comment:
Fixed — the test now sets currentEmail directly to undefined and asserts
hasWriteAccess, so it exercises the no-email guard independently of how the
user-service stub resolves an empty email.
##########
frontend/src/app/dashboard/component/user/share-access/share-access.component.spec.ts:
##########
@@ -512,4 +512,208 @@ describe("ShareAccessComponent", () => {
expect(notificationSpy.success).toHaveBeenCalledWith("Dataset
unpublished successfully");
});
});
+
+ describe("hasWriteAccess without a resolved email", () => {
+ it("returns false when the current user has no email at all", () => {
+ // an empty string makes the stubbed UserService.getCurrentUser return
undefined,
+ // so this.currentEmail resolves to undefined and the early-return guard
is exercised
+ const c = setupComponent({ currentEmail: "" });
+ expect(c.currentEmail).toBeUndefined();
+ expect(c.hasWriteAccess).toBe(false);
+ });
+ });
+
+ describe("removeEmailTag", () => {
+ it("removes the matching email and keeps the others", () => {
+ const c = setupComponent();
+ c.emailTags = ["[email protected]", "[email protected]",
"[email protected]"];
+ c.removeEmailTag("[email protected]");
+ expect(c.emailTags).toEqual(["[email protected]", "[email protected]"]);
+ });
+
+ it("leaves tags unchanged when the email is not present", () => {
+ const c = setupComponent();
+ c.emailTags = ["[email protected]"];
+ c.removeEmailTag("[email protected]");
+ expect(c.emailTags).toEqual(["[email protected]"]);
+ });
+ });
+
+ describe("onChange", () => {
+ it("filters allOwners case-insensitively by the typed value", () => {
+ const c = setupComponent();
+ (c as any).allOwners = ["Alice", "Bob", "alfred"];
+ c.onChange("al");
Review Comment:
Fixed — allOwners is now populated via c.allOwners.push(...) (the field is
readonly but the array is mutable), no more cast to any.
##########
frontend/src/app/dashboard/component/user/share-access/share-access.component.spec.ts:
##########
@@ -512,4 +512,208 @@ describe("ShareAccessComponent", () => {
expect(notificationSpy.success).toHaveBeenCalledWith("Dataset
unpublished successfully");
});
});
+
+ describe("hasWriteAccess without a resolved email", () => {
+ it("returns false when the current user has no email at all", () => {
+ // an empty string makes the stubbed UserService.getCurrentUser return
undefined,
+ // so this.currentEmail resolves to undefined and the early-return guard
is exercised
+ const c = setupComponent({ currentEmail: "" });
+ expect(c.currentEmail).toBeUndefined();
+ expect(c.hasWriteAccess).toBe(false);
+ });
+ });
+
+ describe("removeEmailTag", () => {
+ it("removes the matching email and keeps the others", () => {
+ const c = setupComponent();
+ c.emailTags = ["[email protected]", "[email protected]",
"[email protected]"];
+ c.removeEmailTag("[email protected]");
+ expect(c.emailTags).toEqual(["[email protected]", "[email protected]"]);
+ });
+
+ it("leaves tags unchanged when the email is not present", () => {
+ const c = setupComponent();
+ c.emailTags = ["[email protected]"];
+ c.removeEmailTag("[email protected]");
+ expect(c.emailTags).toEqual(["[email protected]"]);
+ });
+ });
+
+ describe("onChange", () => {
+ it("filters allOwners case-insensitively by the typed value", () => {
+ const c = setupComponent();
+ (c as any).allOwners = ["Alice", "Bob", "alfred"];
+ c.onChange("al");
+ expect(c.filteredOwners).toEqual(["Alice", "alfred"]);
+ });
+
+ it("clears filteredOwners when the value is null", () => {
+ const c = setupComponent();
+ (c as any).allOwners = ["Alice"];
+ c.filteredOwners = ["stale"];
Review Comment:
Fixed — same here, populated via push() instead of casting to any to
reassign.
--
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]