@@ -3,13 +3,17 @@ import { describe, expect, it } from "vite-plus/test";
33
44import {
55 browseInputEndPaddingClass ,
6+ buildThreadActionItems ,
67 filterCommandPaletteGroups ,
78 type CommandPaletteActionItem ,
89} from "./CommandPalette.logic" ;
10+ import { makeThreadFixture } from "../test-fixtures" ;
911import {
1012 buildLinkGitHubIssueActionItemFork ,
1113 refreshNewThreadInViewFork ,
1214 scopePaletteProjectEntriesFork ,
15+ scopePalettePickerProjectsFork ,
16+ scopePaletteThreadItemsFork ,
1317 withProjectScopeToggleFork ,
1418} from "./CommandPalette.fork" ;
1519
@@ -78,6 +82,48 @@ describe("palette project scope", () => {
7882 expect ( scopePaletteProjectEntriesFork ( entries , new Set ( ) ) ) . toBe ( entries ) ;
7983 } ) ;
8084
85+ it ( "filters extracted thread items by project and environment, not thread id" , ( ) => {
86+ const threads = [ "local" , "remote" ] . map ( ( environmentId ) =>
87+ makeThreadFixture ( {
88+ id : ThreadId . make ( "shared-thread-id" ) ,
89+ projectId : ProjectId . make ( "api" ) ,
90+ environmentId : EnvironmentId . make ( environmentId ) ,
91+ } ) ,
92+ ) ;
93+ const items = buildThreadActionItems ( {
94+ threads,
95+ projectTitleById : new Map ( ) ,
96+ sortOrder : "updated_at" ,
97+ icon : null ,
98+ runThread : async ( ) => { } ,
99+ } ) ;
100+ const remoteItem = items [ 1 ] ;
101+ scopePaletteThreadItemsFork ( items , new Set ( [ "remote:api" ] ) ) ;
102+ expect ( items ) . toEqual ( [ remoteItem ] ) ;
103+ scopePaletteThreadItemsFork ( items , new Set ( ) ) ;
104+ expect ( items ) . toEqual ( [ ] ) ;
105+ } ) ;
106+
107+ it ( "filters derived picker projects through group members and preserves explicit empty" , ( ) => {
108+ const entries = [ "api" , "web" ] . map ( ( id ) => ( {
109+ ...entryOf ( id ) ,
110+ targetProject : { environmentId : "local" , id } ,
111+ } ) ) ;
112+ entries [ 1 ] ! . group . memberProjectRefs . push ( ref ( "remote" , "alias" ) ) ;
113+ const projects = entries . map ( ( { targetProject } ) => ( { ...targetProject } ) ) ;
114+ scopePalettePickerProjectsFork ( projects , entries , {
115+ projectKeys : new Set ( [ "remote:alias" ] ) ,
116+ toggle : null ,
117+ } ) ;
118+ expect ( projects . map ( ( { id } ) => id ) ) . toEqual ( [ "web" ] ) ;
119+ scopePalettePickerProjectsFork ( projects , entries , {
120+ projectKeys : new Set ( ) ,
121+ preserveEmpty : true ,
122+ toggle : null ,
123+ } ) ;
124+ expect ( projects ) . toEqual ( [ ] ) ;
125+ } ) ;
126+
81127 it ( "Search all: the pushed new-thread picker follows the scope, keeping its lead first" , ( ) => {
82128 const pushed = [ { value : "projects" , label : "Projects" , items : [ item ( "b" ) , item ( "a" ) ] } ] ;
83129 const refreshed = refreshNewThreadInViewFork ( pushed , [ item ( "a" ) , item ( "b" ) , item ( "c" ) ] ) ;
0 commit comments