@@ -1439,6 +1439,52 @@ describe("STATUS message", () => {
14391439 statsClient . destroy ( ) ;
14401440 } ) ;
14411441
1442+ it ( "relinquishes a writable client's geometry constraints when it peeks" , async ( ) => {
1443+ const name = uniqueName ( ) ;
1444+ await startServer ( name , "cat" , [ ] , { rows : 50 , cols : 120 } ) ;
1445+
1446+ const smaller = await connect ( name ) ;
1447+ const smallerReader = new PacketReader ( ) ;
1448+ smaller . write ( encodeAttach ( 30 , 80 ) ) ;
1449+ await waitForType ( smaller , smallerReader , MessageType . SCREEN ) ;
1450+
1451+ const larger = await connect ( name ) ;
1452+ const largerReader = new PacketReader ( ) ;
1453+ larger . write ( encodeAttach ( 50 , 120 ) ) ;
1454+ await waitForType ( larger , largerReader , MessageType . SCREEN ) ;
1455+
1456+ smaller . write ( encodePeek ( ) ) ;
1457+ await waitForType ( smaller , smallerReader , MessageType . SCREEN ) ;
1458+ const geometry = await waitForType ( larger , largerReader , MessageType . GEOMETRY ) ;
1459+ expect ( geometry . payload . readUInt16BE ( 0 ) ) . toBe ( 50 ) ;
1460+ expect ( geometry . payload . readUInt16BE ( 2 ) ) . toBe ( 120 ) ;
1461+
1462+ const statsClient = await connect ( name ) ;
1463+ const statsReader = new PacketReader ( ) ;
1464+ statsClient . write ( encodeStatus ( ) ) ;
1465+ const packet = await waitForType ( statsClient , statsReader , MessageType . STATUS ) ;
1466+ const stats = JSON . parse ( packet . payload . toString ( ) ) ;
1467+
1468+ expect ( stats . terminal ) . toMatchObject ( { rows : 50 , cols : 120 } ) ;
1469+ expect ( stats . clients . connections ) . toEqual ( expect . arrayContaining ( [
1470+ {
1471+ role : "readonly" ,
1472+ constrains : { rows : false , cols : false } ,
1473+ } ,
1474+ {
1475+ role : "writable" ,
1476+ rows : 50 ,
1477+ cols : 120 ,
1478+ lastRequestSequence : 2 ,
1479+ constrains : { rows : true , cols : true } ,
1480+ } ,
1481+ ] ) ) ;
1482+
1483+ smaller . destroy ( ) ;
1484+ larger . destroy ( ) ;
1485+ statsClient . destroy ( ) ;
1486+ } ) ;
1487+
14421488 it ( "reports exited process" , async ( ) => {
14431489 const name = uniqueName ( ) ;
14441490 await startServer ( name , "sh" , [ "-c" , "exit 7" ] ) ;
0 commit comments