fix: show the thread when it has zero messages (#5182)
* fix tcount logic
* add tests
* update timeout
* 🙄
* update snapshot
---------
Co-authored-by: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com>
This commit is contained in:
parent
3f476871bd
commit
7e7d42780f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -69,7 +69,11 @@ const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IT
|
|||
<View style={styles.detailsContainer}>
|
||||
<View style={styles.detailContainer}>
|
||||
<CustomIcon name='threads' size={24} color={themes[theme].auxiliaryText} />
|
||||
<Text style={[styles.detailText, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
|
||||
<Text
|
||||
testID={`thread-count-${count}`}
|
||||
style={[styles.detailText, { color: themes[theme].auxiliaryText }]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{count}
|
||||
</Text>
|
||||
</View>
|
||||
|
|
|
@ -14,7 +14,7 @@ const Thread = React.memo(
|
|||
const { theme } = useTheme();
|
||||
const { threadBadgeColor, toggleFollowThread, user, replies } = useContext(MessageContext);
|
||||
|
||||
if (!tlm || isThreadRoom || tcount === 0) {
|
||||
if (!tlm || isThreadRoom || tcount === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,18 +9,20 @@ import {
|
|||
TTextMatcher,
|
||||
tapAndWaitFor,
|
||||
navigateToRoom,
|
||||
mockMessage
|
||||
mockMessage,
|
||||
tryTapping
|
||||
} from '../../helpers/app';
|
||||
import { createRandomRoom, createRandomUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Threads', () => {
|
||||
let room: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let alertButtonType: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
const user = await createRandomUser();
|
||||
({ name: room } = await createRandomRoom(user));
|
||||
({ textMatcher } = platformTypes[device.getPlatform()]);
|
||||
({ textMatcher, alertButtonType } = platformTypes[device.getPlatform()]);
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(user.username, user.password);
|
||||
|
@ -219,6 +221,30 @@ describe('Threads', () => {
|
|||
|
||||
await tapAndWaitFor(element(by.id(`message-thread-button-${thread}`)), element(by.id(`room-view-title-${thread}`)), 2000);
|
||||
await expect(element(by.id('messagebox-input-thread'))).toHaveText('');
|
||||
await tapBack();
|
||||
});
|
||||
|
||||
it('should create thread delete the message and the thread show the correct number of messages', async () => {
|
||||
thread = await mockMessage('thread-message-count');
|
||||
await element(by[textMatcher](thread)).atIndex(0).tap();
|
||||
await element(by[textMatcher](thread)).atIndex(0).longPress();
|
||||
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
||||
await element(by[textMatcher]('Reply in thread')).atIndex(0).tap();
|
||||
await element(by.id('messagebox-input')).replaceText('replied');
|
||||
await element(by.id('messagebox-send-message')).tap();
|
||||
await waitFor(element(by.id(`thread-count-1`)))
|
||||
.toExist()
|
||||
.withTimeout(5000);
|
||||
await element(by.id(`message-thread-button-${thread}`)).tap();
|
||||
await tryTapping(element(by[textMatcher]('replied')).atIndex(0), 2000, true);
|
||||
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
||||
await sleep(300); // wait for animation
|
||||
await element(by[textMatcher]('Delete')).atIndex(0).tap();
|
||||
await element(by[textMatcher]('Delete').and(by.type(alertButtonType))).tap();
|
||||
await tapBack();
|
||||
await waitFor(element(by.id(`thread-count-0`)))
|
||||
.toExist()
|
||||
.withTimeout(5000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue