Skip to content

Commit

Permalink
fix type + test
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Feb 28, 2020
1 parent 4c7edfa commit b0635b3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,26 @@ describe('CaseView ', () => {
);
expect(
wrapper
.find(`[data-test-subj="user-action-1"] [data-test-subj="user-action-avatar"]`)
.find(
`div[data-test-subj="user-action-${data.comments[0].commentId}-avatar"] [data-test-subj="user-action-avatar"]`
)
.first()
.prop('name')
).toEqual(data.comments[0].createdBy.fullName);

expect(
wrapper
.find(`[data-test-subj="user-action-1"] [data-test-subj="user-action-title"] strong`)
.find(
`div[data-test-subj="user-action-${data.comments[0].commentId}"] [data-test-subj="user-action-title"] strong`
)
.first()
.text()
).toEqual(data.comments[0].createdBy.username);

expect(
wrapper
.find(
`[data-test-subj="user-action-1"] [data-test-subj="user-action-content"] [data-test-subj="markdown"]`
`div[data-test-subj="user-action-${data.comments[0].commentId}"] [data-test-subj="markdown"]`
)
.first()
.prop('source')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const UserActionTree = React.memo(
markdown={
<UserActionMarkdown
id={comment.commentId}
content={data.description}
content={comment.comment}
isEditable={manageMarkdownEditIds.includes(comment.commentId)}
onChangeEditable={handleManageMarkdownEditId}
onSaveContent={handleSaveComment.bind(null, comment.commentId)}
Expand All @@ -150,13 +150,13 @@ export const UserActionTree = React.memo(
/>
))}
<UserActionItem
createdAt={data.createdAt}
createdAt={new Date().toISOString()}
id={NewId}
isEditable={true}
isLoading={isLoadingIds.includes(NewId)}
fullName="to be determined"
markdown={MarkdownNewComment}
onEdit={handleManageMarkdownEditId.bind(null, DescriptionId)}
onEdit={handleManageMarkdownEditId.bind(null, NewId)}
userName="to be determined"
/>
</UserAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiAvatar, EuiFlexItem } from '@elastic/eui';
import { EuiAvatar } from '@elastic/eui';
import React from 'react';

interface UserActionAvatarProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ export const UserActionItem = ({
markdown,
onEdit,
userName,
}: UserActionItemProps) => {
return (
<>
<EuiFlexItem grow={false}>
<UserActionAvatar name={fullName ?? userName} />
</EuiFlexItem>
<EuiFlexItem>
{isEditable && markdown}
{!isEditable && (
<EuiPanel className="userAction__panel" paddingSize="none">
<UserActionTitle
createdAt={createdAt}
id={id}
isLoading={isLoading}
labelAction={labelAction ?? ''}
labelTitle={labelTitle ?? ''}
userName={userName}
onEdit={onEdit}
/>
{markdown}
</EuiPanel>
)}
</EuiFlexItem>
</>
);
};
}: UserActionItemProps) => (
<>
<EuiFlexItem data-test-subj={`user-action-${id}-avatar`} grow={false}>
<UserActionAvatar name={fullName ?? userName} />
</EuiFlexItem>
<EuiFlexItem data-test-subj={`user-action-${id}`}>
{isEditable && markdown}
{!isEditable && (
<EuiPanel className="userAction__panel" paddingSize="none">
<UserActionTitle
createdAt={createdAt}
id={id}
isLoading={isLoading}
labelAction={labelAction ?? ''}
labelTitle={labelTitle ?? ''}
userName={userName}
onEdit={onEdit}
/>
{markdown}
</EuiPanel>
)}
</EuiFlexItem>
</>
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiButton } from '@elastic/eui';
import React, { useCallback, useState, useEffect } from 'react';
import React, { useCallback, useState } from 'react';
import styled, { css } from 'styled-components';

import { MarkdownEditor } from '../../../../components/markdown_editor';
Expand Down

0 comments on commit b0635b3

Please sign in to comment.