Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no spaces between emoji aliases #33278

Merged
merged 5 commits into from
Nov 15, 2024
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
5 changes: 5 additions & 0 deletions .changeset/spotty-ads-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes display of emoji aliases in custom emoji list by adding commas between aliases
79 changes: 79 additions & 0 deletions apps/meteor/client/views/admin/customEmoji/CustomEmoji.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { mockAppRoot } from '@rocket.chat/mock-providers';
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';

import '@testing-library/jest-dom';

import CustomEmoji from './CustomEmoji';

const appRoot = mockAppRoot().withEndpoint('GET', '/v1/emoji-custom.all', () => ({
count: 1,
offset: 0,
total: 1,
success: true,
emojis: [
{
_id: '1',
name: 'smile',
aliases: ['happy', 'joy'],
extension: 'webp',
_updatedAt: new Date().toISOString(),
etag: 'abcdef',
},
],
}));

describe('CustomEmoji Component', () => {
abhinavkrin marked this conversation as resolved.
Show resolved Hide resolved
const mockRef = { current: jest.fn() };
const mockOnClick = jest.fn();

it('renders emoji list', async () => {
render(<CustomEmoji onClick={mockOnClick} reload={mockRef} />, {
legacyRoot: true,
wrapper: appRoot.build(),
});

await waitFor(() => {
expect(screen.getByText('smile')).toBeInTheDocument();
});
});

it("renders emoji's aliases as comma-separated values when aliases is an array", async () => {
render(<CustomEmoji onClick={mockOnClick} reload={mockRef} />, {
legacyRoot: true,
wrapper: appRoot.build(),
});

await waitFor(() => {
expect(screen.getByText('happy, joy')).toBeInTheDocument();
});
});

it("renders emoji's aliases values when aliases is a string", async () => {
render(<CustomEmoji onClick={mockOnClick} reload={mockRef} />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withEndpoint('GET', '/v1/emoji-custom.all', () => ({
count: 1,
offset: 0,
total: 1,
success: true,
emojis: [
{
_id: '1',
name: 'smile',
aliases: 'happy' as any,
extension: 'webp',
_updatedAt: new Date().toISOString(),
etag: 'abcdef',
},
],
}))
.build(),
});

await waitFor(() => {
expect(screen.getByText('happy')).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => {
<Box withTruncatedText>{emojis.name}</Box>
</GenericTableCell>
<GenericTableCell color='default'>
<Box withTruncatedText>{emojis.aliases.join(', ')}</Box>
<Box withTruncatedText>{Array.isArray(emojis.aliases) ? emojis.aliases.join(', ') : emojis.aliases}</Box>
</GenericTableCell>
</GenericTableRow>
))}
Expand Down
Loading