* Viewing Files in Edit mode in mobile with ability to delete and save * Added upload attachment to keyboard tracker view * using state instread of use ref * Minor * Added tests * intl extract * new function getFiles ById, batch file deletion and tests * Files fetching in edit options and tests * Removed DeviceEventEmitter and used React context * Added support to check minimum required version to show edit file attachments * resolve forward ref issue * Minor * memotized props for context and observe config with value * Ability to show quick action and add files to edit post * type safety for EditPostContext * Reverted back the post priority props * constant shift * Added test for QuickAction to show slashcomand * Added test for edit_post, upload_item and upload_remove * Added test for Edit_post_input and edit_post index * fix the height issue between attachment and keyboard due to safeArea * Minor: removed debugging border color * Changed the Edited text style in the post from (edited) to icon + Edited * Import fixes * Ability to show quick action and add files to edit post * type safety for EditPostContext * Reverted back the post priority props * constant shift * Added test for QuickAction to show slashcomand * Added test for edit_post, upload_item and upload_remove * Added test for Edit_post_input and edit_post index * fix the height issue between attachment and keyboard due to safeArea * Minor: removed debugging border color * Addressed dev review comments * Import fixes * Address UX comments * Fixed props for UploadItem and remove effective Edit mode * handled save button disabled state when uploading attachments * handled newly added and retry file removal without alert message * Test updated * Added test for input_quick_action index.tsx * Added test for not in edit mode for upload_item index * Added test for upload_remove component when not in edit mode * added tests for file_upload_error hook * Added test for calling callback when in edit mode * Test for edit post input for server version check * linter fixes * Changed font size from 16 to 14px for edited * separated common component and test * Removed the margin styles from the text as it is not been applied. * removed the duplicate code from rebase
128 lines
4.2 KiB
TypeScript
128 lines
4.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
|
|
import {Preferences} from '@constants';
|
|
import {renderWithIntlAndTheme} from '@test/intl-test-helper';
|
|
|
|
import EditedIndicator from './index';
|
|
|
|
describe('components/EditedIndicator', () => {
|
|
const baseProps = {
|
|
baseTextStyle: {fontSize: 16, color: '#000'},
|
|
theme: Preferences.THEMES.denim,
|
|
context: ['paragraph'],
|
|
testID: 'edited-indicator-test',
|
|
};
|
|
|
|
it('should render with default props', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator {...baseProps}/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
expect(indicator).toBeTruthy();
|
|
expect(indicator.props.children).toEqual([
|
|
' ', // spacer for paragraph context
|
|
expect.objectContaining({
|
|
props: expect.objectContaining({
|
|
name: 'pencil-outline',
|
|
size: 14, // default icon size
|
|
}),
|
|
}),
|
|
expect.objectContaining({
|
|
props: expect.objectContaining({
|
|
id: 'post_message_view.edited',
|
|
defaultMessage: 'Edited',
|
|
}),
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it('should render with custom icon size', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator
|
|
{...baseProps}
|
|
iconSize={20}
|
|
/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
const icon = indicator.props.children[1];
|
|
expect(icon.props.size).toBe(20);
|
|
});
|
|
|
|
it('should render with custom testID', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator
|
|
{...baseProps}
|
|
testID='custom-test-id'
|
|
/>,
|
|
);
|
|
|
|
expect(getByTestId('custom-test-id')).toBeTruthy();
|
|
});
|
|
|
|
describe('component structure', () => {
|
|
it('should render pencil-outline icon', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator {...baseProps}/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
const icon = indicator.props.children[1];
|
|
expect(icon.props.name).toBe('pencil-outline');
|
|
});
|
|
|
|
it('should render "Edited" text with correct props', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator {...baseProps}/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
const formattedText = indicator.props.children[2];
|
|
expect(formattedText.props.id).toBe('post_message_view.edited');
|
|
expect(formattedText.props.defaultMessage).toBe('Edited');
|
|
});
|
|
});
|
|
|
|
describe('edge cases', () => {
|
|
it('should handle empty context array', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator
|
|
{...baseProps}
|
|
context={[]}
|
|
/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
expect(indicator.props.children[0]).toBe('');
|
|
});
|
|
|
|
it('should handle undefined context elements', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator
|
|
{...baseProps}
|
|
context={[undefined] as any}
|
|
checkHeadings={true}
|
|
/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
expect(indicator.props.children[0]).toBe('');
|
|
});
|
|
|
|
it('should handle context with multiple elements', () => {
|
|
const {getByTestId} = renderWithIntlAndTheme(
|
|
<EditedIndicator
|
|
{...baseProps}
|
|
context={['paragraph', 'strong', 'em']}
|
|
/>,
|
|
);
|
|
|
|
const indicator = getByTestId('edited-indicator-test');
|
|
expect(indicator.props.children[0]).toBe(' ');
|
|
});
|
|
});
|
|
});
|