* Add autotranslations * Develop latest changes and missing features * i18n-extract * Fix tests and update api behavior * Fix minor bugs * adjustments to shimmer animation, showtranslation modal style * Update post.tsx * Update show_translation.tsx * adjust sizing and opacity of translate icon * Add channel header translated icon * Disable auto translation item if it is not a supported language * Move channel info to the top * Update edit channel to channel info * Fix align of option items * Fix i18n * Add detox related changes for channel settings changes * Add tests * Address changes around the my channel column change * Address feedback * Fix test * Fix bad import * Fix set my channel autotranslation * Fix test * Address feedback * Add missing files from last commit * Remove unneeded change --------- Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
90 lines
2.7 KiB
TypeScript
90 lines
2.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {screen} from '@testing-library/react-native';
|
|
import React from 'react';
|
|
|
|
import CompassIcon from '@components/compass_icon';
|
|
import ExpiryCountdown from '@components/post_list/post/header/expiry_timer';
|
|
import {PostTypes} from '@constants/post';
|
|
import {renderWithIntlAndTheme} from '@test/intl-test-helper';
|
|
import TestHelper from '@test/test_helper';
|
|
|
|
import Header from './header';
|
|
|
|
jest.mock('@components/compass_icon', () => ({
|
|
__esModule: true,
|
|
default: jest.fn(),
|
|
}));
|
|
jest.mocked(CompassIcon).mockImplementation(
|
|
(props) => React.createElement('CompassIcon', {testID: `compass-icon${props.name ? '-' + props.name : ''}`, ...props}) as any,
|
|
);
|
|
|
|
jest.mock('@components/post_list/post/header/expiry_timer', () => ({
|
|
__esModule: true,
|
|
default: jest.fn(),
|
|
}));
|
|
jest.mocked(ExpiryCountdown).mockImplementation(
|
|
(props) => React.createElement('ExpiryCountdown', {testID: 'expiry-timer', ...props}) as any,
|
|
);
|
|
|
|
describe('Header', () => {
|
|
const currentUser = TestHelper.fakeUserModel();
|
|
|
|
const defaultProps = {
|
|
commentCount: 0,
|
|
enablePostUsernameOverride: false,
|
|
isAutoResponse: false,
|
|
isCustomStatusEnabled: false,
|
|
isEphemeral: false,
|
|
isMilitaryTime: false,
|
|
isPendingOrFailed: false,
|
|
isSystemPost: false,
|
|
isWebHook: false,
|
|
location: 'About' as const,
|
|
showPostPriority: false,
|
|
teammateNameDisplay: '',
|
|
hideGuestTags: false,
|
|
currentUser,
|
|
isChannelAutotranslated: false,
|
|
};
|
|
|
|
it('Should show BoR icon for own BoR post', () => {
|
|
const ownBoRPost = TestHelper.fakePostModel({
|
|
type: PostTypes.BURN_ON_READ,
|
|
userId: currentUser.id,
|
|
metadata: {
|
|
|
|
// missing expire_at key indicates unrevealed BoR post
|
|
},
|
|
});
|
|
|
|
renderWithIntlAndTheme(
|
|
<Header
|
|
{...defaultProps}
|
|
post={ownBoRPost}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.queryByTestId('compass-icon-fire')).toBeVisible();
|
|
expect(screen.queryByTestId('expiry-timer')).not.toBeVisible();
|
|
});
|
|
|
|
it('Should show BoR countdown for revealed BoR post', () => {
|
|
const ownBoRPost = TestHelper.fakePostModel({
|
|
type: PostTypes.BURN_ON_READ,
|
|
metadata: {
|
|
expire_at: Date.now() + 60000,
|
|
},
|
|
});
|
|
|
|
renderWithIntlAndTheme(
|
|
<Header
|
|
{...defaultProps}
|
|
post={ownBoRPost}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.queryByTestId('expiry-timer')).toBeVisible();
|
|
});
|
|
});
|