Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/apps/opportunities/src/components/ChallengeForum.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,40 @@ describe('ChallengeForum', () => {
.toBeUndefined()
})

it('shows an edit timestamp for changed starter posts and replies only', async () => {
const editedAt = '2026-06-08T12:30:00.000Z'
topicDetail = {
posts: [{
...starterPost,
replies: [{ ...starterPost.replies[0], updatedAt: editedAt }],
updatedAt: editedAt,
}],
topic: announcement,
}
const { container }: RenderResult = render(
<ChallengeForum challenge={{ id: 'challenge-id', name: 'Challenge' }} memberId='10' />,
)
await act(async () => fireEvent.click(container.querySelector('.topicOverlay') as HTMLButtonElement))
expect(screen.getAllByText(/^Edited:/))
.toHaveLength(2)
screen.getAllByText(/^Edited:/)
.forEach(timestamp => {
expect(timestamp)
.toHaveAttribute('datetime', editedAt)
expect(timestamp)
.toHaveTextContent(formatForumDate(editedAt))
})
})

it('does not mark unchanged posts as edited', async () => {
const { container }: RenderResult = render(
<ChallengeForum challenge={{ id: 'challenge-id', name: 'Challenge' }} memberId='10' />,
)
await act(async () => fireEvent.click(container.querySelector('.topicOverlay') as HTMLButtonElement))
expect(screen.queryByText(/^Edited:/))
.not.toBeInTheDocument()
})

it('opens the topic when the upper card is clicked, keeping the footer for actions', async () => {
const { container }: RenderResult = render(
<ChallengeForum challenge={{ id: 'challenge-id', name: 'Challenge' }} memberId='10' />,
Expand Down
7 changes: 7 additions & 0 deletions src/apps/opportunities/src/components/ChallengeForum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,13 @@ const ForumPostCard: FC<{
{' '}
{formatForumDate(post.createdAt)}
</time>
{!post.deleted && Date.parse(post.updatedAt) > Date.parse(post.createdAt) && (
<time dateTime={post.updatedAt}>
Edited:
{' '}
{formatForumDate(post.updatedAt)}
</time>
)}
{props.parent && (
<span>
Replying to
Expand Down
Loading