Copilot commented on code in PR #7305:
URL: https://github.com/apache/texera/pull/7305#discussion_r3709687224


##########
amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectResourceSpec.scala:
##########
@@ -254,6 +254,75 @@ class ProjectResourceSpec
     workflowOfProjectCount(wid, pid) shouldBe 0
   }
 
+  it should "accept both 3- and 6-digit hex colours and persist the last one" 
in {
+    val pid = resource.createProject(session(owner), "p").getPid
+
+    resource.updateProjectColor(pid, "AABBCC", session(owner))
+    resource.getProject(pid).getColor shouldBe "AABBCC"
+
+    // The shorthand form is legal too, and the value is stored verbatim 
rather than expanded.
+    resource.updateProjectColor(pid, "f0a", session(owner))
+    resource.getProject(pid).getColor shouldBe "f0a"
+  }
+
+  it should "reject colours that are not 3 or 6 hex digits, leaving the stored 
one intact" in {
+    val pid = resource.createProject(session(owner), "p").getPid
+    resource.updateProjectColor(pid, "123456", session(owner))
+
+    // Wrong length, and a right-length value with a non-hex digit: the guard 
checks both, so a
+    // length-only check would let "GGGGGG" through and a regex-only check 
would let "" through.

Review Comment:
   This comment claims a “regex-only check would let \"\" through”, but 
`colorHex.matches(...)` requires a full-string match and the current regex 
doesn’t match empty strings. That makes the rationale misleading for future 
readers.
   
   Consider rewording to simply state that the cases exercise both the length 
and hex-digit validation branches.



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