@@ -198,7 +198,7 @@ it("renders four exclusive sections with all setups on one exact-key card", asyn
198198 ) . not . toBeVisible ( ) ;
199199 fireEvent . click (
200200 within ( card ) . queryByText ( "Identity & sources" ) ??
201- within ( card ) . getByText ( "Identity & sources" ) ,
201+ within ( card ) . getByLabelText ( / ^ D e t a i l s f o r / ) ,
202202 ) ;
203203 expect (
204204 within ( card ) . getByText ( "Installed Buzz · Development Buzz" ) ,
@@ -220,6 +220,86 @@ it("renders four exclusive sections with all setups on one exact-key card", asyn
220220 ) . toBeVisible ( ) ;
221221} ) ;
222222
223+ it ( "nests local rows by saved community once, with unknown last" , async ( ) => {
224+ setup ( "connected" , ( f ) => {
225+ const agent = { ...f . agent } ;
226+ f . data . agents = [
227+ {
228+ ...agent ,
229+ id : "z" ,
230+ name : "Several setups" ,
231+ relayUrl : "wss://z.example" ,
232+ } ,
233+ {
234+ ...agent ,
235+ id : "a" ,
236+ name : "Several setups" ,
237+ relayUrl : "wss://a.example" ,
238+ } ,
239+ {
240+ ...agent ,
241+ id : "b" ,
242+ pubkey : "bb" . repeat ( 32 ) ,
243+ name : "Second" ,
244+ relayUrl : "wss://b.example" ,
245+ } ,
246+ {
247+ ...agent ,
248+ id : "unknown" ,
249+ pubkey : "aa" . repeat ( 32 ) ,
250+ name : "Legacy" ,
251+ relayUrl : "" ,
252+ configured : false ,
253+ } ,
254+ ] ;
255+ } ) ;
256+ const group = await screen . findByRole ( "region" , {
257+ name : "Local agents in other communities" ,
258+ } ) ;
259+ expect (
260+ within ( group )
261+ . getAllByRole ( "heading" , { level : 3 } )
262+ . map ( ( h ) => h . textContent ) ,
263+ ) . toEqual ( [ "https://a.example" , "https://b.example" , "Community unknown" ] ) ;
264+ const first = within ( group ) . getByRole ( "region" , {
265+ name : "https://a.example" ,
266+ } ) ;
267+ const row = within ( first ) . getByRole ( "article" , {
268+ name : "Agent Several setups" ,
269+ } ) ;
270+ expect (
271+ screen . getAllByRole ( "article" , { name : "Agent Several setups" } ) ,
272+ ) . toHaveLength ( 1 ) ;
273+ expect ( within ( row ) . getByRole ( "heading" , { level : 4 } ) ) . toHaveTextContent (
274+ "Several setups" ,
275+ ) ;
276+ // Every saved setup of the key keeps its exact controls on the one row.
277+ expect ( within ( row ) . getAllByRole ( "button" , { name : "Stop" } ) ) . toHaveLength ( 2 ) ;
278+ fireEvent . click ( within ( row ) . getByLabelText ( / ^ D e t a i l s f o r / ) ) ;
279+ // The z setup keeps its own controls, so it names its community there.
280+ expect ( within ( row ) . getByText ( "wss://z.example" ) ) . toBeVisible ( ) ;
281+ expect ( within ( row ) . queryByText ( "wss://a.example" ) ) . toBeNull ( ) ;
282+ expect ( within ( row ) . queryByRole ( "button" , { name : "Use here" } ) ) . toBeNull ( ) ;
283+ fireEvent . click ( within ( row ) . getByLabelText ( "Details for Several setups" ) ) ;
284+ expect ( within ( row ) . getByRole ( "button" , { name : "Clone" } ) ) . toBeVisible ( ) ;
285+ expect (
286+ within ( group ) . getByRole ( "region" , { name : "Community unknown" } ) ,
287+ ) . toHaveTextContent ( "Legacy" ) ;
288+ } ) ;
289+
290+ it ( "does not invent a community for library-only relay identities" , async ( ) => {
291+ setup ( "connected" , ( ) => { } , [ ] ) ;
292+ const group = await screen . findByRole ( "region" , {
293+ name : "Relay-only agents" ,
294+ } ) ;
295+ const unknown = within ( group ) . getByRole ( "region" , {
296+ name : "Community unknown" ,
297+ } ) ;
298+ expect (
299+ within ( unknown ) . getByRole ( "article" , { name : "Agent Not imported" } ) ,
300+ ) . toBeVisible ( ) ;
301+ } ) ;
302+
223303it ( "retains the chosen source when an identity card unmounts and returns" , ( ) => {
224304 const { rows, redraw, onImport } = setup ( "connected" , ( f ) => {
225305 f . data . parked = [
0 commit comments