File tree Expand file tree Collapse file tree
dotcom-rendering/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,3 +151,40 @@ export const InteractionObserver: Story = {
151151 await expect ( canvas . queryByTestId ( 'play-icon' ) ) . not . toBeInTheDocument ( ) ;
152152 } ,
153153} satisfies Story ;
154+
155+ export const FullscreenOpen : Story = {
156+ ...Loop5to4 ,
157+ name : 'Open fullscreen' ,
158+ args : {
159+ ...Loop5to4 . args ,
160+ videoStyle : 'Default' ,
161+ } ,
162+ parameters : {
163+ test : {
164+ // The following error is received without this flag: "TypeError: ophan.trackClickComponentEvent is not a function"
165+ dangerouslyIgnoreUnhandledErrors : true ,
166+ } ,
167+ } ,
168+ play : async ( { canvasElement } ) => {
169+ /**
170+ * Ideally, this interaction test would open and close fullscreen.
171+ * However, the Fullscreen API is not implemented in jsdom, so
172+ * document.fullscreenElement will always be null regardless of what the
173+ * component does. Instead, we spy on requestFullscreen to ensure
174+ * that the correct handler is invoked when the fullscreen button is clicked.
175+ */
176+
177+ const canvas = within ( canvasElement ) ;
178+
179+ const requestFullscreenSpy = spyOn (
180+ HTMLElement . prototype ,
181+ 'requestFullscreen' ,
182+ ) ;
183+
184+ await canvas . findByTestId ( 'fullscreen-icon' ) ;
185+
186+ await userEvent . click ( canvas . getByTestId ( 'fullscreen-icon' ) ) ;
187+
188+ await expect ( requestFullscreenSpy ) . toHaveBeenCalled ( ) ;
189+ } ,
190+ } satisfies Story ;
You can’t perform that action at this time.
0 commit comments