mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-07 19:30:14 +00:00
* bumps minSdkVersion to 30 Older versions are past end-of-life for security patches. voximplant service patch is also updated with minSdkVersion set to 30. * removes manifest attributes no longer needed when minSdk is 30 * removes guard to for version lower than O * removes permission check for versions lower than 28 * remove tests related to unsupported android sdk versions * bumps iOS minSdkVersion to 18 * removes iOS 13/15 guards in hardware-keyboard * removes iOS 15 guards in NotificationService * removes iOS 15 guard in Gekidou network delegate since gekidou is iOS only other platform guards are not needed * removes version guard no longer needed in voximplant patch * removes hasWriteStoragePermission dead stub and its call site * removes unused setSoftKeyboardToAdjustResize from rnutils The function had no call sites in JS/TS code and the iOS implementation was a no-op. * removes version guards and updates config after min version bump * updates stale iOS 17 simulator references in CI to iOS 18.1 Co-Authored-By: Carlos Garcia <carlos.garcia@mattermost.com> * fixes malformed patch file headers - voximplant patch: restore missing diff --git header and index line for VIForegroundServiceModule.java, fix stale hunk counter (+11 -> +7) - notifications patch: fix stale hunk line count (+91 -> +89) after KITKAT branch removal Co-Authored-By: Carlos Garcia <carlos.garcia@mattermost.com> * remove code below the supported OS versions * Bump IntuneMAM SDK to 21.8.0 and MSAL to 2.15.0 --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
81 lines
2.8 KiB
TypeScript
81 lines
2.8 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Platform} from 'react-native';
|
|
import {KeyboardController} from 'react-native-keyboard-controller';
|
|
|
|
import {advanceTimers} from '@test/timer_helpers';
|
|
|
|
import {dismissKeyboard, isKeyboardVisible} from './keyboard';
|
|
|
|
describe('dismissKeyboard', () => {
|
|
beforeEach(() => {
|
|
jest.useFakeTimers({doNotFake: ['nextTick']});
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
jest.useRealTimers();
|
|
Platform.OS = 'ios';
|
|
});
|
|
|
|
it('should call KeyboardController.dismiss with animated=false', async () => {
|
|
await dismissKeyboard();
|
|
|
|
expect(KeyboardController.dismiss).toHaveBeenCalledWith({animated: false});
|
|
});
|
|
|
|
// Regression: KeyboardController.dismiss() waits for a `keyboardDidHide` event that
|
|
// can never arrive when the library's internal state is stale. Callers used to await
|
|
// that forever — showPostOptions() then never navigated, so long-pressing a post did
|
|
// nothing at all until the state happened to resync.
|
|
it('should not hang on Android when KeyboardController.dismiss never settles', async () => {
|
|
Platform.OS = 'android';
|
|
jest.mocked(KeyboardController.dismiss).mockReturnValue(new Promise<void>(() => {
|
|
// Never settles, exactly as it behaves after a missed keyboardDidHide.
|
|
}));
|
|
|
|
const dismissPromise = dismissKeyboard();
|
|
await advanceTimers(250);
|
|
|
|
await expect(dismissPromise).resolves.toBeUndefined();
|
|
});
|
|
|
|
// iOS relies on the event to know the keyboard has actually left the screen. Cutting
|
|
// that wait short let callers navigate over a still-visible keyboard.
|
|
// MM-T4865_1, MM-T361_1) that all passed on the commit before it.
|
|
it('should keep awaiting KeyboardController.dismiss on iOS', async () => {
|
|
Platform.OS = 'ios';
|
|
let settle: () => void = () => undefined;
|
|
jest.mocked(KeyboardController.dismiss).mockReturnValue(new Promise<void>((resolve) => {
|
|
settle = resolve;
|
|
}));
|
|
|
|
let resolved = false;
|
|
const dismissPromise = dismissKeyboard().then(() => {
|
|
resolved = true;
|
|
});
|
|
|
|
await advanceTimers(5000);
|
|
expect(resolved).toBe(false);
|
|
|
|
settle();
|
|
await dismissPromise;
|
|
expect(resolved).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('isKeyboardVisible', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('should return KeyboardController.isVisible()', () => {
|
|
jest.mocked(KeyboardController.isVisible).mockReturnValue(true);
|
|
|
|
expect(isKeyboardVisible()).toBe(true);
|
|
expect(KeyboardController.isVisible).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|