1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Mobile: Editor: Switch to a scrolling toolbar, allow adding/removing toolbar items (#11472)

This commit is contained in:
Henry Heino
2024-12-11 04:31:05 -08:00
committed by GitHub
parent 5d84f80ad1
commit d935a491ba
65 changed files with 1326 additions and 1154 deletions

View File

@ -7,10 +7,18 @@ import '@testing-library/jest-native';
import NoteEditor from './NoteEditor';
import Setting from '@joplin/lib/models/Setting';
import { _ } from '@joplin/lib/locale';
import { MenuProvider } from 'react-native-popup-menu';
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
import commandDeclarations from './commandDeclarations';
import CommandService from '@joplin/lib/services/CommandService';
import CommandService, { RegisteredRuntime } from '@joplin/lib/services/CommandService';
import TestProviderStack from '../testing/TestProviderStack';
import createMockReduxStore from '../../utils/testing/createMockReduxStore';
import mockCommandRuntimes from '../EditorToolbar/testing/mockCommandRuntimes';
import setupGlobalStore from '../../utils/testing/setupGlobalStore';
import { Store } from 'redux';
import { AppState } from '../../utils/types';
let store: Store<AppState>;
let registeredRuntime: RegisteredRuntime;
describe('NoteEditor', () => {
beforeAll(() => {
@ -24,11 +32,19 @@ describe('NoteEditor', () => {
// Required to use ExtendedWebView
await setupDatabaseAndSynchronizer(0);
await switchClient(0);
store = createMockReduxStore();
setupGlobalStore(store);
registeredRuntime = mockCommandRuntimes(store);
});
afterEach(() => {
registeredRuntime.deregister();
});
it('should hide the markdown toolbar when the window is small', async () => {
const wrappedNoteEditor = render(
<MenuProvider>
<TestProviderStack store={store}>
<NoteEditor
themeId={Setting.THEME_ARITIM_DARK}
initialText='Testing...'
@ -41,7 +57,7 @@ describe('NoteEditor', () => {
onAttach={async ()=>{}}
plugins={{}}
/>
</MenuProvider>,
</TestProviderStack>,
);
// Maps from screen height to whether the markdown toolbar should be visible.
@ -70,11 +86,11 @@ describe('NoteEditor', () => {
setRootHeight(height);
await waitFor(async () => {
const showMoreButton = await screen.queryByLabelText(_('Show more actions'));
const toolbarButton = await screen.queryByLabelText(_('Bold'));
if (visible) {
expect(showMoreButton).not.toBeNull();
expect(toolbarButton).not.toBeNull();
} else {
expect(showMoreButton).toBeNull();
expect(toolbarButton).toBeNull();
}
});
}