@@ -63,16 +63,19 @@ describe("useTaskSearch", () => {
6363 it ( "returns all tasks by default" , ( ) => {
6464 const { result } = renderHook ( ( ) => useTaskSearch ( ) )
6565
66- expect ( result . current . tasks ) . toHaveLength ( 2 ) // Only tasks from current workspace
66+ expect ( result . current . tasks ) . toHaveLength ( 3 ) // All tasks from all workspaces
6767 expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-2" ) // Newest first
6868 expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-1" )
69+ expect ( result . current . tasks [ 2 ] . id ) . toBe ( "task-3" )
6970 } )
7071
71- it ( "filters tasks by current workspace by default " , ( ) => {
72+ it ( "shows tasks from all workspaces " , ( ) => {
7273 const { result } = renderHook ( ( ) => useTaskSearch ( ) )
7374
74- expect ( result . current . tasks ) . toHaveLength ( 2 )
75- expect ( result . current . tasks . every ( ( task ) => task . workspace === "/workspace/project1" ) ) . toBe ( true )
75+ expect ( result . current . tasks ) . toHaveLength ( 3 )
76+ const workspaces = result . current . tasks . map ( ( task ) => task . workspace )
77+ expect ( workspaces ) . toContain ( "/workspace/project1" )
78+ expect ( workspaces ) . toContain ( "/workspace/project2" )
7679 } )
7780
7881 it ( "sorts by newest by default" , ( ) => {
@@ -90,8 +93,9 @@ describe("useTaskSearch", () => {
9093 result . current . setSortOption ( "oldest" )
9194 } )
9295
93- expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-1" ) // Feb 16
94- expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-2" ) // Feb 17
96+ expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-3" ) // Feb 15
97+ expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-1" ) // Feb 16
98+ expect ( result . current . tasks [ 2 ] . id ) . toBe ( "task-2" ) // Feb 17
9599 } )
96100
97101 it ( "sorts by most expensive" , ( ) => {
@@ -101,8 +105,9 @@ describe("useTaskSearch", () => {
101105 result . current . setSortOption ( "mostExpensive" )
102106 } )
103107
104- expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-2" ) // $0.02
105- expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-1" ) // $0.01
108+ expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-3" ) // $0.05
109+ expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-2" ) // $0.02
110+ expect ( result . current . tasks [ 2 ] . id ) . toBe ( "task-1" ) // $0.01
106111 } )
107112
108113 it ( "sorts by most tokens" , ( ) => {
@@ -113,9 +118,11 @@ describe("useTaskSearch", () => {
113118 } )
114119
115120 // task-2: 200 + 100 + 25 + 10 = 335 tokens
121+ // task-3: 150 + 75 = 225 tokens
116122 // task-1: 100 + 50 = 150 tokens
117123 expect ( result . current . tasks [ 0 ] . id ) . toBe ( "task-2" )
118- expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-1" )
124+ expect ( result . current . tasks [ 1 ] . id ) . toBe ( "task-3" )
125+ expect ( result . current . tasks [ 2 ] . id ) . toBe ( "task-1" )
119126 } )
120127
121128 it ( "filters tasks by search query" , ( ) => {
@@ -227,8 +234,8 @@ describe("useTaskSearch", () => {
227234
228235 const { result } = renderHook ( ( ) => useTaskSearch ( ) )
229236
230- // Should only include tasks with both ts and task content from current workspace
231- expect ( result . current . tasks ) . toHaveLength ( 2 )
237+ // Should only include tasks with both ts and task content from all workspaces
238+ expect ( result . current . tasks ) . toHaveLength ( 3 )
232239 expect ( result . current . tasks . every ( ( task ) => task . ts && task . task ) ) . toBe ( true )
233240 } )
234241
0 commit comments