aglinxinyuan commented on code in PR #7464:
URL: https://github.com/apache/texera/pull/7464#discussion_r3870712210


##########
amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala:
##########
@@ -680,99 +633,92 @@ class WorkflowResourceSpec
     )
   }
 
-  "/search API" should "be able to search for resources in different tables" 
in {
+  "/search API" should "be able to search for resources by keyword" in {
 
-    // create different types of resources, project, workflow, and file
-    projectResource.createProject(sessionUser1, "test project1")
     workflowResource.persistWorkflow(testWorkflow1, sessionUser1)
     // search
     val DashboardClickableFileEntryList =
       dashboardResource.searchAllResourcesCall(
         sessionUser1,
         SearchQueryParams(getKeywordsArray("test"))
       )
-    assert(DashboardClickableFileEntryList.results.length == 2)
+    assert(DashboardClickableFileEntryList.results.length == 1)
 
   }
 
   it should "return all resources when no keyword provided" in {
-    projectResource.createProject(sessionUser1, "test project1")
     workflowResource.persistWorkflow(testWorkflow1, sessionUser1)
     val DashboardClickableFileEntryList =
       dashboardResource.searchAllResourcesCall(
         sessionUser1,
         SearchQueryParams(getKeywordsArray(""))
       )
-    assert(DashboardClickableFileEntryList.results.length == 2)
+    assert(DashboardClickableFileEntryList.results.length == 1)
   }
 
   it should "return multiple matching resources from a single resource type" 
in {
     workflowResource.persistWorkflow(testWorkflow1, sessionUser1)
-    projectResource.createProject(sessionUser1, "common project1")
-    projectResource.createProject(sessionUser1, "common project2")
+    workflowResource.persistWorkflow(testWorkflow2, sessionUser1)
     val DashboardClickableFileEntryList =
       dashboardResource.searchAllResourcesCall(
         sessionUser1,
-        SearchQueryParams(getKeywordsArray("common"))
+        SearchQueryParams(getKeywordsArray("test"))
       )
     assert(DashboardClickableFileEntryList.results.length == 2)
   }
 
   it should "handle multiple keywords correctly" in {
-    projectResource.createProject(sessionUser1, "test project1")
     workflowResource.persistWorkflow(testWorkflow1, sessionUser1)
+    workflowResource.persistWorkflow(testWorkflow2, sessionUser1)
     val DashboardClickableFileEntryList =
       dashboardResource.searchAllResourcesCall(
         sessionUser1,
-        SearchQueryParams(getKeywordsArray("test", "project1"))
+        SearchQueryParams(getKeywordsArray("test", "workflow1"))
       )
     assert(
       DashboardClickableFileEntryList.results.length == 1
-    ) // should only return the project
+    ) // should only return test_workflow1
   }
 
   it should "filter results by different resourceType" in {

Review Comment:
   Agreed on the diagnosis, but the suggested numbers can't hold in this spec, 
so I strengthened it differently.
   
   I tried it: seeded a dataset + `dataset_user_access` grant and asserted 
all==4 / workflow==3 / dataset==1. It fails. `VersionedResourceTables.hydrate` 
sizes every LakeFS-backed resource and returns `None` when it can't, and the 
caller drops those rows:
   
       LakeFS ApiException for dataset repository 'test-dataset-repo':
       java.net.ConnectException: Failed to connect to 
localhost/[0:0:0:0:0:0:0:1]:8000
   
   So the seeded dataset is found by the query and then dropped during 
hydration — dataset==0, all==3. Making it pass needs the HttpServer LakeFS stub 
that `DatasetSearchQueryBuilderSpec` stands up, and that spec already covers 
the positive dataset path against it. Since workflow is the only non-LakeFS 
searchable type, there is no second row available here.
   
   Instead I pinned the property your comment is really after — that 
`resourceType` is dispatched on rather than ignored — without needing LakeFS:
   
       assertThrows[IllegalArgumentException] {
         dashboardResource.searchAllResourcesCall(
           sessionUser1,
           SearchQueryParams(resourceType = "project", keywords = 
getKeywordsArray("test"))
         )
       }
   
   An ignored filter would return the 3 workflows; the throw only happens if 
the value reaches the `case _` in `searchAllResources`. It also pins the 500 
behind the sequencing must-fix. Comment explains why the dataset row isn't 
seeded here. Happy to add the stub instead if you'd rather have the positive 
assertion in this spec.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



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