@@ -21,6 +21,16 @@ vi.mock(import("../../state/server"), async (original) => {
2121 } ;
2222} ) ;
2323
24+ vi . mock ( import ( "../../hooks/useSettings" ) , async ( original ) => {
25+ const actual = await original ( ) ;
26+ type Settings = ReturnType < typeof actual . getClientSettings > ;
27+ function useClientSettings < T = Settings > ( select ?: ( settings : Settings ) => T ) : T {
28+ const settings = { ...actual . getClientSettings ( ) , mathRenderingEnabled : true } ;
29+ return select ? select ( settings ) : ( settings as T ) ;
30+ }
31+ return { ...actual , useClientSettings } ;
32+ } ) ;
33+
2434import { page , userEvent } from "vite-plus/test/browser" ;
2535import { ComposerPendingUserInputPanel } from "./ComposerPendingUserInputPanel" ;
2636import { act , fakeTimers , render } from "../../../test/render" ;
@@ -287,3 +297,26 @@ it("opens option images without answering", async () => {
287297 expect ( select ) . not . toHaveBeenCalled ( ) ;
288298 expect ( advance ) . not . toHaveBeenCalled ( ) ;
289299} ) ;
300+
301+ it ( "scrolls option equations without answering" , async ( ) => {
302+ const select = vi . fn ( ) ;
303+ const advance = vi . fn ( ) ;
304+ const container = document . createElement ( "div" ) ;
305+ container . style . width = "400px" ;
306+ await using screen = await render (
307+ markdownPanel ( select , advance , {
308+ label : "Equation" ,
309+ description : "$$\n" + Array ( 100 ) . fill ( "x_i" ) . join ( " + " ) + "\n$$" ,
310+ } ) ,
311+ { container } ,
312+ ) ;
313+ const scroller = screen . getByLabelText ( "Scroll display equation" ) ;
314+ await expect . element ( scroller ) . toBeVisible ( ) ;
315+ const element = scroller . element ( ) ;
316+ await vi . waitFor ( ( ) => expect ( element . scrollWidth ) . toBeGreaterThan ( element . clientWidth ) ) ;
317+ await userEvent . click ( scroller ) ;
318+ await userEvent . wheel ( element , { delta : { x : 200 , y : 0 } } ) ;
319+ await vi . waitFor ( ( ) => expect ( element . scrollLeft ) . toBeGreaterThan ( 0 ) ) ;
320+ expect ( select ) . not . toHaveBeenCalled ( ) ;
321+ expect ( advance ) . not . toHaveBeenCalled ( ) ;
322+ } ) ;
0 commit comments