mattermost-mobile-upstream/app/components/post_list/android_thread_scroll.test.ts
Nick Misasi 120f8980af
fix(MM-69538): restore Android thread scroll to root post header
Android inverted thread lists could not scroll far enough to reveal the
root post header after browsing replies. Apply Android-thread-specific
list padding and layout handling, include the root post in the initial
batch, and centralize detection in android_thread_scroll helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 17:14:14 -04:00

52 lines
1.6 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Platform} from 'react-native';
import {Screens} from '@constants';
import {isAndroidThreadRootPost, isAndroidThreadScreen} from './android_thread_scroll';
describe('android_thread_scroll', () => {
const originalOS = Platform.OS;
afterEach(() => {
Object.defineProperty(Platform, 'OS', {value: originalOS});
});
it('should identify Android thread screens only', () => {
Object.defineProperty(Platform, 'OS', {value: 'android'});
expect(isAndroidThreadScreen(Screens.THREAD)).toBe(true);
expect(isAndroidThreadScreen(Screens.CHANNEL)).toBe(false);
Object.defineProperty(Platform, 'OS', {value: 'ios'});
expect(isAndroidThreadScreen(Screens.THREAD)).toBe(false);
});
it('should identify Android thread root posts by root id or reply state', () => {
Object.defineProperty(Platform, 'OS', {value: 'android'});
expect(isAndroidThreadRootPost({
location: Screens.THREAD,
postId: 'root-post-id',
rootId: 'root-post-id',
})).toBe(true);
expect(isAndroidThreadRootPost({
location: Screens.THREAD,
postId: 'reply-post-id',
rootId: 'root-post-id',
})).toBe(false);
expect(isAndroidThreadRootPost({
location: Screens.THREAD,
isReplyPost: false,
})).toBe(true);
expect(isAndroidThreadRootPost({
location: Screens.THREAD,
isReplyPost: true,
})).toBe(false);
});
});