-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not unmount boards in mobile responsive mode
refs: SHELL-79 (#239)
1 parent
f959e19
commit 697e1e0
Showing
4 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
import React, { FC } from 'react'; | ||
import { act, screen } from '@testing-library/react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { setup } from '../test/utils'; | ||
import ShellView from './shell-view'; | ||
import { useBoardStore } from '../store/boards'; | ||
import { Board } from '../../types'; | ||
import { useAppStore } from '../store/app'; | ||
import { useBridge } from '../store/context-bridge'; | ||
|
||
const ContextBridge: FC = () => { | ||
const history = useHistory(); | ||
useBridge({ | ||
functions: { | ||
getHistory: () => history | ||
} | ||
}); | ||
return null; | ||
}; | ||
|
||
const Dummy: FC = () => null; | ||
|
||
jest.mock('../utility-bar/bar', () => ({ | ||
ShellUtilityBar: Dummy | ||
})); | ||
|
||
jest.mock('./shell-header', () => Dummy); | ||
|
||
test('When resizing under mobile breakpoint, board does not disappear', () => { | ||
const boards: Record<string, Board> = { | ||
'board-1': { id: 'board-1', url: '/url', app: 'app', title: 'title1', icon: 'CubeOutline' } | ||
}; | ||
|
||
useBoardStore.setState(() => ({ | ||
boards, | ||
orderedBoards: ['board-1'], | ||
current: 'board-1' | ||
})); | ||
|
||
useAppStore.getState().setters.addApps([ | ||
{ | ||
commit: '', | ||
description: 'Mails module', | ||
display: 'Mails', | ||
icon: 'MailModOutline', | ||
js_entrypoint: '', | ||
name: 'carbonio-mails-ui', | ||
priority: 1, | ||
type: 'carbonio', | ||
version: '0.0.1' | ||
} | ||
]); | ||
useAppStore.getState().setters.addRoute({ | ||
id: 'mails', | ||
route: 'mails', | ||
position: 1, | ||
visible: true, | ||
label: 'Mails', | ||
primaryBar: 'MailModOutline', | ||
appView: () => <div></div>, | ||
badge: { show: false }, | ||
app: 'carbonio-mails-ui' | ||
}); | ||
|
||
setup( | ||
<> | ||
<ContextBridge /> <ShellView /> | ||
</> | ||
); | ||
|
||
expect(screen.getByText('title1')).toBeVisible(); | ||
act(() => { | ||
window.resizeTo(500, 300); | ||
}); | ||
expect(screen.getByText('title1')).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.