Skip to content

Commit 0deed4b

Browse files
committed
Add an interaction story
1 parent f2c96a8 commit 0deed4b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

dotcom-rendering/src/components/SelfHostedVideo.stories.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)