@@ -17,6 +17,7 @@ afterAll(() => {
1717} )
1818
1919const {
20+ accountScope,
2021 boundAttachSnapshot,
2122 buildStatusView,
2223 loadStatusView,
@@ -106,6 +107,14 @@ describe("buildStatusView", () => {
106107 expect ( statusHeadline ( view ) ) . toBe ( "2 of 5 integration tools available · 3 need attention" )
107108 } )
108109
110+ test ( "a selection the attach could only read in part is never reported as changed" , ( ) => {
111+ // The attach-time read omitted the list or an integration's tools. (codex)
112+ const partial = snapshot ( )
113+ partial . declared = { ...partial . declared ! , partial : true }
114+ const view = buildStatusView ( partial , { selection : [ { id : "slack" , tools : [ { key : "slack_post" } ] } ] , catalog } )
115+ expect ( view . selectionChanged ) . toBe ( false )
116+ } )
117+
109118 test ( "the same selection in another order is not a change" , ( ) => {
110119 const view = buildStatusView ( snapshot ( ) , { selection : [ ...selection ] . reverse ( ) , catalog } )
111120 expect ( view . selectionChanged ) . toBe ( false )
@@ -153,6 +162,16 @@ describe("buildStatusView", () => {
153162 )
154163 expect ( view . rows [ 0 ] . served ) . toHaveLength ( 1 )
155164 expect ( rowLine ( view . rows [ 0 ] ) ) . toStartWith ( "1 of 2" )
165+ // Nor are they two dropped tools when neither is served. (coderabbit)
166+ const dropped = buildStatusView (
167+ snapshot ( {
168+ declared : { keys : [ "jira.search" , "jira_search" ] , extensionKeys : [ ] , integrations : declared } ,
169+ present : [ ] ,
170+ unfulfilled : [ ] ,
171+ } ) ,
172+ null ,
173+ )
174+ expect ( dropped . rows [ 0 ] . unreported ) . toEqual ( [ "jira.search" ] )
156175 } )
157176
158177 test ( "a row shows every distinct error its gaps carry" , ( ) => {
@@ -292,7 +311,7 @@ describe("loadStatusView", () => {
292311 } )
293312} )
294313
295- describe ( "boundAttachSnapshot" , ( ) => {
314+ describe ( "boundAttachSnapshot and accountScope " , ( ) => {
296315 const DIR = "/proj/bound"
297316 const creds = { altimateUrl : "https://api.example.com" , altimateInstanceName : "acme" , altimateApiKey : "key-1" }
298317 let configured : ReturnType < typeof spyOn >
@@ -307,29 +326,32 @@ describe("boundAttachSnapshot", () => {
307326 credentials . mockRestore ( )
308327 } )
309328 // The scope the overlay writes a snapshot under: the binding cache's, with the credential digest.
310- const accountScope = ( apiKey : string ) =>
329+ const scopeFor = ( apiKey : string ) =>
311330 scopeStringOf ( {
312331 tenant : creds . altimateInstanceName ,
313332 apiUrl : creds . altimateUrl ,
314333 account : credentialDigest ( creds . altimateUrl , creds . altimateInstanceName , apiKey ) ,
315334 } )
316-
317- test ( "finds the attach the overlay wrote under the full account scope" , async ( ) => {
318- // The sidebar matched it under `tenant|apiUrl` and never found it. (kilo)
335+ const written = ( apiKey : string ) =>
319336 writeAttachSnapshot (
320337 DIR ,
321- snapshot ( { workspace : { id : "6" , name : "e2e-demo-live" , key : workspaceIdentity ( accountScope ( "key-1" ) , 6 ) } } ) ,
338+ snapshot ( { workspace : { id : "6" , name : "e2e-demo-live" , key : workspaceIdentity ( scopeFor ( apiKey ) , 6 ) } } ) ,
322339 )
323- expect ( ( await boundAttachSnapshot ( DIR , { datamateId : 6 } ) ) ?. workspace . id ) . toBe ( "6" )
340+
341+ test ( "accountScope is the full scope the overlay writes the snapshot under" , async ( ) => {
342+ // The sidebar matched under `tenant|apiUrl` and never found it. (kilo)
343+ written ( "key-1" )
344+ const scope = await accountScope ( )
345+ expect ( scope ) . toBe ( scopeFor ( "key-1" ) )
346+ expect ( boundAttachSnapshot ( DIR , { datamateId : 6 } , scope ) ?. workspace . id ) . toBe ( "6" )
324347 } )
325348
326- test ( "finds nothing for another key on the same tenant, or with no binding" , async ( ) => {
327- writeAttachSnapshot (
328- DIR ,
329- snapshot ( { workspace : { id : "6" , name : "e2e-demo-live" , key : workspaceIdentity ( accountScope ( "key-2" ) , 6 ) } } ) ,
330- )
331- expect ( await boundAttachSnapshot ( DIR , { datamateId : 6 } ) ) . toBeUndefined ( )
332- expect ( await boundAttachSnapshot ( DIR , null ) ) . toBeUndefined ( )
349+ test ( "a snapshot matches only under the scope the binding was resolved under" , ( ) => {
350+ // Another key on the same tenant is another account; no binding or no scope finds nothing. (codex)
351+ written ( "key-2" )
352+ expect ( boundAttachSnapshot ( DIR , { datamateId : 6 } , scopeFor ( "key-1" ) ) ) . toBeUndefined ( )
353+ expect ( boundAttachSnapshot ( DIR , { datamateId : 6 } , scopeFor ( "key-2" ) ) ?. workspace . id ) . toBe ( "6" )
354+ expect ( boundAttachSnapshot ( DIR , null , scopeFor ( "key-2" ) ) ) . toBeUndefined ( )
355+ expect ( boundAttachSnapshot ( DIR , { datamateId : 6 } , null ) ) . toBeUndefined ( )
333356 } )
334357} )
335-
0 commit comments