Compare commits

...

1 Commits

Author SHA1 Message Date
Ashwin Bhatkal
2da419ed5a fix(dashboard): disable full screen on browsers without fullscreen support 2026-11-18 19:37:36 +05:30
3 changed files with 35 additions and 0 deletions

View File

@@ -208,6 +208,11 @@ function DashboardActions({
testId: 'dashboard-action-fullscreen',
label: 'Full screen',
prefix: <Fullscreen size={14} />,
...blockedBy(
document.fullscreenEnabled
? ''
: "Full screen isn't supported in this browser",
),
onClick: handleEnterFullScreen,
},
],

View File

@@ -82,6 +82,13 @@ function renderActions(): ReturnType<typeof render> {
}
describe('DashboardActions - AuthZ', () => {
beforeAll(() => {
Object.defineProperty(document, 'fullscreenEnabled', {
configurable: true,
value: true,
});
});
afterEach(() => {
jest.restoreAllMocks();
server.resetHandlers();

View File

@@ -85,6 +85,13 @@ function renderActions(isDashboardLocked = false): Handlers {
return handlers;
}
function setFullscreenEnabled(enabled: boolean): void {
Object.defineProperty(document, 'fullscreenEnabled', {
configurable: true,
value: enabled,
});
}
async function clickRow(testId: string): Promise<void> {
await userEvent.click(screen.getByRole('button', { name: /Actions/ }));
const row = await screen.findByTestId(testId);
@@ -98,6 +105,7 @@ async function clickRow(testId: string): Promise<void> {
describe('DashboardActions menu rows', () => {
beforeEach(() => {
server.use(setupAuthzAdmin());
setFullscreenEnabled(true);
});
afterEach(() => {
@@ -154,6 +162,21 @@ describe('DashboardActions menu rows', () => {
expect(handlers.onLockToggle).not.toHaveBeenCalled();
});
it('Full screen is disabled with a reason when the browser has no fullscreen support', async () => {
setFullscreenEnabled(false);
const handlers = renderActions();
await userEvent.click(screen.getByRole('button', { name: /Actions/ }));
const row = await screen.findByTestId('dashboard-action-fullscreen');
expect(row).toHaveAttribute('data-disabled');
await userEvent.click(row);
expect(handlers.enter).not.toHaveBeenCalled();
await userEvent.hover(row);
await expect(screen.findByRole('tooltip')).resolves.toHaveTextContent(
"Full screen isn't supported in this browser",
);
});
it('New section opens the section title modal', async () => {
const handlers = renderActions();
expect(screen.queryByTestId('section-title-cancel')).not.toBeInTheDocument();