MM-47110 : Migrate "components/advanced_create_comment/advanced_create_comment.test.jsx" to Typescript (#24257)

This commit is contained in:
abhinav700 2023-09-04 14:15:00 +05:30 committed by GitHub
parent 918fff378d
commit 5443f9d371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 512 additions and 323 deletions

View File

@ -14,15 +14,62 @@ exports[`components/AdvancedCreateComment should match snapshot when cannot post
currentUserId="zaktnt8bpbgu8mb6ez9k64r7sa"
draft={
Object {
"channelId": "",
"createAt": 0,
"fileInfos": Array [
Object {},
Object {},
Object {},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
],
"message": "Test message",
"uploadsInProgress": Array [
Object {},
],
"rootId": "",
"updateAt": 0,
"uploadsInProgress": Array [],
}
}
emitTypingEvent={[Function]}
@ -87,8 +134,12 @@ exports[`components/AdvancedCreateComment should match snapshot, comment with me
currentUserId="zaktnt8bpbgu8mb6ez9k64r7sa"
draft={
Object {
"channelId": "",
"createAt": 0,
"fileInfos": Array [],
"message": "Test message",
"rootId": "",
"updateAt": 0,
"uploadsInProgress": Array [],
}
}
@ -155,15 +206,62 @@ exports[`components/AdvancedCreateComment should match snapshot, emoji picker di
currentUserId="zaktnt8bpbgu8mb6ez9k64r7sa"
draft={
Object {
"channelId": "",
"createAt": 0,
"fileInfos": Array [
Object {},
Object {},
Object {},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
],
"message": "Test message",
"uploadsInProgress": Array [
Object {},
],
"rootId": "",
"updateAt": 0,
"uploadsInProgress": Array [],
}
}
emitTypingEvent={[Function]}
@ -228,8 +326,12 @@ exports[`components/AdvancedCreateComment should match snapshot, empty comment 1
currentUserId="zaktnt8bpbgu8mb6ez9k64r7sa"
draft={
Object {
"channelId": "",
"createAt": 0,
"fileInfos": Array [],
"message": "",
"rootId": "",
"updateAt": 0,
"uploadsInProgress": Array [],
}
}
@ -296,15 +398,62 @@ exports[`components/AdvancedCreateComment should match snapshot, non-empty messa
currentUserId="zaktnt8bpbgu8mb6ez9k64r7sa"
draft={
Object {
"channelId": "",
"createAt": 0,
"fileInfos": Array [
Object {},
Object {},
Object {},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
Object {
"archived": false,
"clientId": "client_id",
"create_at": 1,
"delete_at": 1,
"extension": "jpg",
"has_preview_image": true,
"height": 200,
"id": "file_info_id",
"mime_type": "mime_type",
"name": "name",
"size": 1,
"update_at": 1,
"user_id": "user_id",
"width": 350,
},
],
"message": "Test message",
"uploadsInProgress": Array [
Object {},
],
"rootId": "",
"updateAt": 0,
"uploadsInProgress": Array [],
}
}
emitTypingEvent={[Function]}

View File

@ -60,7 +60,7 @@ import FileLimitStickyBanner from 'components/file_limit_sticky_banner';
const KeyCodes = Constants.KeyCodes;
type Props = {
export type Props = {
currentTeamId: string;
// The channel for which this comment is a part of
@ -219,10 +219,13 @@ function isDraftEmpty(draft: PostDraft): boolean {
}
class AdvancedCreateComment extends React.PureComponent<Props, State> {
private lastBlurAt = 0;
private draftsForPost: {[postID: string]: PostDraft | null} = {};
private doInitialScrollToBottom = false;
// public because accessed in advanced_create_comment.test.tsx
public draftsForPost: {[postID: string]: PostDraft | null} = {};
public doInitialScrollToBottom = false;
private readonly textboxRef: React.RefObject<TextboxClass>;
private lastBlurAt = 0;
private saveDraftFrame?: number | null;
private isDraftSubmitting = false;
@ -230,7 +233,6 @@ class AdvancedCreateComment extends React.PureComponent<Props, State> {
private isNonFormattedPaste = false;
private timeoutId: number | null = null;
private readonly textboxRef: React.RefObject<TextboxClass>;
private readonly fileUploadRef: React.RefObject<FileUploadClass>;
static defaultProps = {

View File

@ -2,3 +2,4 @@
// See LICENSE.txt for license information.
declare const COMMIT_HASH: string;

View File

@ -20,8 +20,21 @@ import {PreferenceType} from '@mattermost/types/preferences';
import {Reaction} from '@mattermost/types/reactions';
import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils';
import {Invoice, Product, Subscription, CloudCustomer} from '@mattermost/types/cloud';
import {PostDraft} from 'types/store/draft';
export class TestHelper {
public static getPostDraftMock(override?: Partial<PostDraft>): PostDraft {
const defaultPostDraft: PostDraft = {
message: 'Test message',
fileInfos: [],
uploadsInProgress: [],
channelId: '',
rootId: '',
createAt: 0,
updateAt: 0,
};
return Object.assign({}, defaultPostDraft, override);
}
public static getUserMock(override: Partial<UserProfile> = {}): UserProfile {
const defaultUser: UserProfile = {
id: 'user_id',