11import { expectDefined } from "@openclaw/normalization-core" ;
22import { afterEach , beforeAll , describe , expect , it , vi } from "vitest" ;
33import "../../../styles.css" ;
4+ import "../../../styles/chat.css" ;
45import "./chat-sidebar.ts" ;
56
67// The root jsdom ui shard also collects *.browser.test.ts files; CodeMirror
@@ -42,13 +43,23 @@ type DetailPanel = HTMLElement & {
4243 updateComplete : Promise < unknown > ;
4344} ;
4445
45- const mounted : DetailPanel [ ] = [ ] ;
46+ const mounted : HTMLElement [ ] = [ ] ;
4647
47- async function mountFile ( content : FileSidebarContent ) : Promise < DetailPanel > {
48+ async function mountFile ( content : FileSidebarContent , width ?: number ) : Promise < DetailPanel > {
4849 const panel = document . createElement ( "openclaw-chat-detail-panel" ) as DetailPanel ;
4950 panel . content = content ;
50- document . body . append ( panel ) ;
51- mounted . push ( panel ) ;
51+ if ( width === undefined ) {
52+ document . body . append ( panel ) ;
53+ mounted . push ( panel ) ;
54+ } else {
55+ const container = document . createElement ( "div" ) ;
56+ container . className = "side-panel__panel" ;
57+ container . style . cssText = `display:flex;width:${ width } px;height:320px;` ;
58+ panel . className = "chat-sidebar" ;
59+ container . append ( panel ) ;
60+ document . body . append ( container ) ;
61+ mounted . push ( container ) ;
62+ }
5263 await panel . updateComplete ;
5364 await expect . poll ( ( ) => panel . querySelector ( ".cm-editor" ) , { timeout : 5_000 } ) . not . toBeNull ( ) ;
5465 return panel ;
@@ -72,6 +83,26 @@ afterEach(() => {
7283} ) ;
7384
7485describe . runIf ( browserMode ) ( "chat file editor" , ( ) => {
86+ it ( "keeps long lines inside Review and gives horizontal scroll to the editor" , async ( ) => {
87+ const panel = await mountFile (
88+ {
89+ kind : "file" ,
90+ path : "src/long-line.ts" ,
91+ name : "long-line.ts" ,
92+ content : `export const value = "${ "long-content-" . repeat ( 80 ) } ";` ,
93+ } ,
94+ 320 ,
95+ ) ;
96+
97+ const fileView = panel . querySelector < HTMLElement > ( ".file-view" ) ! ;
98+ const scroller = panel . querySelector < HTMLElement > ( ".cm-scroller" ) ! ;
99+ await expect . poll ( ( ) => fileView . clientWidth ) . toBeGreaterThan ( 0 ) ;
100+ expect ( fileView . clientWidth ) . toBeLessThanOrEqual ( panel . parentElement ! . clientWidth ) ;
101+ expect ( fileView . scrollWidth ) . toBe ( fileView . clientWidth ) ;
102+ expect ( scroller . scrollWidth ) . toBeGreaterThan ( scroller . clientWidth ) ;
103+ expect ( getComputedStyle ( scroller ) . overflowX ) . toBe ( "auto" ) ;
104+ } ) ;
105+
75106 it ( "renders content and decorates the requested line" , async ( ) => {
76107 const panel = await mountFile ( {
77108 kind : "file" ,
0 commit comments