@@ -152,9 +152,9 @@ export const InteractionObserver: Story = {
152152 } ,
153153} satisfies Story ;
154154
155- export const FullscreenOpen : Story = {
155+ export const FullscreenButtonOpen : Story = {
156156 ...Loop5to4 ,
157- name : 'Open fullscreen' ,
157+ name : 'Open fullscreen with button ' ,
158158 args : {
159159 ...Loop5to4 . args ,
160160 videoStyle : 'Default' ,
@@ -181,9 +181,48 @@ export const FullscreenOpen: Story = {
181181 'requestFullscreen' ,
182182 ) ;
183183
184- await canvas . findByTestId ( 'fullscreen-icon' ) ;
184+ const fullscreenIcon = await canvas . findByTestId ( 'fullscreen-icon' ) ;
185185
186- await userEvent . click ( canvas . getByTestId ( 'fullscreen-icon' ) ) ;
186+ await userEvent . click ( fullscreenIcon ) ;
187+
188+ await expect ( requestFullscreenSpy ) . toHaveBeenCalled ( ) ;
189+ } ,
190+ } satisfies Story ;
191+
192+ export const FullscreenDoubleClickOpen : Story = {
193+ ...Loop5to4 ,
194+ name : 'Open fullscreen with a double click' ,
195+ args : {
196+ ...Loop5to4 . args ,
197+ videoStyle : 'Default' ,
198+ } ,
199+ parameters : {
200+ test : {
201+ // The following error is received without this flag: "TypeError: ophan.trackClickComponentEvent is not a function"
202+ dangerouslyIgnoreUnhandledErrors : true ,
203+ } ,
204+ } ,
205+ play : async ( { canvasElement } ) => {
206+ /**
207+ * Ideally, this interaction test would open and close fullscreen.
208+ * However, the Fullscreen API is not implemented in jsdom, so
209+ * document.fullscreenElement will always be null regardless of what the
210+ * component does. Instead, we spy on requestFullscreen to ensure
211+ * that the correct handler is invoked when the fullscreen button is clicked.
212+ */
213+
214+ const canvas = within ( canvasElement ) ;
215+
216+ const requestFullscreenSpy = spyOn (
217+ HTMLElement . prototype ,
218+ 'requestFullscreen' ,
219+ ) ;
220+
221+ const selfHostedPlayer = await canvas . findByTestId (
222+ 'self-hosted-video-player' ,
223+ ) ;
224+
225+ await userEvent . dblClick ( selfHostedPlayer ) ;
187226
188227 await expect ( requestFullscreenSpy ) . toHaveBeenCalled ( ) ;
189228 } ,
0 commit comments