From 8f699f8e170ae153e52e2d858983a16ac6a05ffd Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 21 Jun 2024 14:32:27 +0200 Subject: [PATCH] test: remove MessageStatus tests for legacy styles --- .../Message/__tests__/MessageStatus.test.js | 314 +++++++++--------- .../__snapshots__/MessageStatus.test.js.snap | 167 +--------- 2 files changed, 161 insertions(+), 320 deletions(-) diff --git a/src/components/Message/__tests__/MessageStatus.test.js b/src/components/Message/__tests__/MessageStatus.test.js index e5ef071d0..b9f5c1cd0 100644 --- a/src/components/Message/__tests__/MessageStatus.test.js +++ b/src/components/Message/__tests__/MessageStatus.test.js @@ -56,184 +56,182 @@ const renderComponent = ({ chatCtx, componentCtx, messageCtx, props } = {}) => ); describe('MessageStatus', () => { - describe.each(['1', '2'])('theme v%s', (themeVersion) => { - it('renders nothing for not own messages', async () => { - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { isMyMessage: () => false, message: foreignMsg }, - }); - expect(container).toBeEmptyDOMElement(); + it('renders nothing for not own messages', async () => { + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { isMyMessage: () => false, message: foreignMsg }, }); - it('renders nothing for error messages', async () => { - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: errorMsg }, - }); - expect(container).toBeEmptyDOMElement(); + expect(container).toBeEmptyDOMElement(); + }); + it('renders nothing for error messages', async () => { + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: errorMsg }, }); + expect(container).toBeEmptyDOMElement(); + }); - it('renders default sending UI for the last message', async () => { - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg }, - }); - expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot(); + it('renders default sending UI for the last message', async () => { + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg }, }); + expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot(); + }); - it('renders custom sending UI for the last message', async () => { - const text = 'CustomMessageSendingStatus'; - const MessageSendingStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg }, - props: { MessageSendingStatus }, - }); - expect(screen.getByText(text)).toBeInTheDocument(); + it('renders custom sending UI for the last message', async () => { + const text = 'CustomMessageSendingStatus'; + const MessageSendingStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg }, + props: { MessageSendingStatus }, }); + expect(screen.getByText(text)).toBeInTheDocument(); + }); - it('renders default sending UI for not the last message', async () => { - const client = await getTestClientWithUser(user); - renderComponent({ chatCtx: { client, themeVersion }, messageCtx: { message: sendingMsg } }); - expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot(); - }); + it('renders default sending UI for not the last message', async () => { + const client = await getTestClientWithUser(user); + renderComponent({ chatCtx: { client }, messageCtx: { message: sendingMsg } }); + expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot(); + }); - it('renders custom sending UI for not the last message', async () => { - const text = 'CustomMessageSendingStatus'; - const MessageSendingStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: sendingMsg }, - props: { MessageSendingStatus }, - }); - expect(screen.getByText(text)).toBeInTheDocument(); + it('renders custom sending UI for not the last message', async () => { + const text = 'CustomMessageSendingStatus'; + const MessageSendingStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { message: sendingMsg }, + props: { MessageSendingStatus }, }); + expect(screen.getByText(text)).toBeInTheDocument(); + }); - // here - it('renders default delivered UI for the last message', async () => { - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg }, - }); - expect(screen.getByTestId(MESSAGE_STATUS_DELIVERED_TEST_ID)).toMatchSnapshot(); + // here + it('renders default delivered UI for the last message', async () => { + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg }, }); + expect(screen.getByTestId(MESSAGE_STATUS_DELIVERED_TEST_ID)).toMatchSnapshot(); + }); - it('renders custom delivered UI for the last message', async () => { - const text = 'CustomMessageDeliveredStatus'; - const MessageDeliveredStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg }, - props: { MessageDeliveredStatus }, - }); - expect(screen.getByText(text)).toBeInTheDocument(); + it('renders custom delivered UI for the last message', async () => { + const text = 'CustomMessageDeliveredStatus'; + const MessageDeliveredStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg }, + props: { MessageDeliveredStatus }, }); + expect(screen.getByText(text)).toBeInTheDocument(); + }); - it('renders empty container without default delivered UI for not the last message', async () => { - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: deliveredMsg }, - }); - expect(container.children[0]).toHaveClass(rootClassName); - expect(container.children[0]).toBeEmptyDOMElement(); + it('renders empty container without default delivered UI for not the last message', async () => { + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: deliveredMsg }, }); + expect(container.children[0]).toHaveClass(rootClassName); + expect(container.children[0]).toBeEmptyDOMElement(); + }); - it('renders empty container without custom delivered UI for not the last message', async () => { - const text = 'CustomMessageDeliveredStatus'; - const MessageDeliveredStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: deliveredMsg }, - props: { MessageDeliveredStatus }, - }); - expect(container.children[0]).toHaveClass(rootClassName); - expect(container.children[0]).toBeEmptyDOMElement(); - }); + it('renders empty container without custom delivered UI for not the last message', async () => { + const text = 'CustomMessageDeliveredStatus'; + const MessageDeliveredStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: deliveredMsg }, + props: { MessageDeliveredStatus }, + }); + expect(container.children[0]).toHaveClass(rootClassName); + expect(container.children[0]).toBeEmptyDOMElement(); + }); - it('renders default read UI for the last message', async () => { - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { - lastReceivedId: deliveredMsg.id, - message: deliveredMsg, - readBy: readByOthers, - }, - }); - expect(screen.getByTestId(MESSAGE_STATUS_READ_TEST_ID)).toMatchSnapshot(); - }); - it('renders custom read UI for the last message', async () => { - const text = 'CustomMessageReadStatus'; - const MessageReadStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { - lastReceivedId: deliveredMsg.id, - message: deliveredMsg, - readBy: readByOthers, - }, - props: { MessageReadStatus }, - }); - expect(screen.getByText(text)).toBeInTheDocument(); - }); - it('renders empty container without default read UI for not the last message', async () => { - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: deliveredMsg }, - }); - expect(container.children[0]).toHaveClass(rootClassName); - expect(container.children[0]).toBeEmptyDOMElement(); - }); + it('renders default read UI for the last message', async () => { + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { + lastReceivedId: deliveredMsg.id, + message: deliveredMsg, + readBy: readByOthers, + }, + }); + expect(screen.getByTestId(MESSAGE_STATUS_READ_TEST_ID)).toMatchSnapshot(); + }); + it('renders custom read UI for the last message', async () => { + const text = 'CustomMessageReadStatus'; + const MessageReadStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { + lastReceivedId: deliveredMsg.id, + message: deliveredMsg, + readBy: readByOthers, + }, + props: { MessageReadStatus }, + }); + expect(screen.getByText(text)).toBeInTheDocument(); + }); + it('renders empty container without default read UI for not the last message', async () => { + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: deliveredMsg }, + }); + expect(container.children[0]).toHaveClass(rootClassName); + expect(container.children[0]).toBeEmptyDOMElement(); + }); - it('renders empty container without custom read UI for not the last message', async () => { - const text = 'CustomMessageReadStatus'; - const MessageReadStatus = () =>
{text}
; - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: deliveredMsg }, - props: { MessageReadStatus }, - }); - expect(container.children[0]).toHaveClass(rootClassName); - expect(container.children[0]).toBeEmptyDOMElement(); - }); + it('renders empty container without custom read UI for not the last message', async () => { + const text = 'CustomMessageReadStatus'; + const MessageReadStatus = () =>
{text}
; + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: deliveredMsg }, + props: { MessageReadStatus }, + }); + expect(container.children[0]).toHaveClass(rootClassName); + expect(container.children[0]).toBeEmptyDOMElement(); + }); - it('renders custom Avatar in default read status', async () => { - const text = 'CustomAvatar'; - const Avatar = () =>
{text}
; - const client = await getTestClientWithUser(user); - renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { - lastReceivedId: deliveredMsg.id, - message: deliveredMsg, - readBy: readByOthers, - }, - props: { Avatar }, - }); - expect(screen.getByText(text)).toBeInTheDocument(); - expect(screen.queryByTestId('avatar')).not.toBeInTheDocument(); - }); + it('renders custom Avatar in default read status', async () => { + const text = 'CustomAvatar'; + const Avatar = () =>
{text}
; + const client = await getTestClientWithUser(user); + renderComponent({ + chatCtx: { client }, + messageCtx: { + lastReceivedId: deliveredMsg.id, + message: deliveredMsg, + readBy: readByOthers, + }, + props: { Avatar }, + }); + expect(screen.getByText(text)).toBeInTheDocument(); + expect(screen.queryByTestId('avatar')).not.toBeInTheDocument(); + }); - it('reflects messageType prop in root class', async () => { - const client = await getTestClientWithUser(user); - const { container } = renderComponent({ - chatCtx: { client, themeVersion }, - messageCtx: { message: deliveredMsg }, - props: { messageType: 'XXX' }, - }); - expect(container.children[0]).not.toHaveClass('str-chat__message-simple-status'); - expect(container.children[0]).toHaveClass('str-chat__message-XXX-status'); + it('reflects messageType prop in root class', async () => { + const client = await getTestClientWithUser(user); + const { container } = renderComponent({ + chatCtx: { client }, + messageCtx: { message: deliveredMsg }, + props: { messageType: 'XXX' }, }); + expect(container.children[0]).not.toHaveClass('str-chat__message-simple-status'); + expect(container.children[0]).toHaveClass('str-chat__message-XXX-status'); }); }); diff --git a/src/components/Message/__tests__/__snapshots__/MessageStatus.test.js.snap b/src/components/Message/__tests__/__snapshots__/MessageStatus.test.js.snap index 3eb0c1c60..abac79d65 100644 --- a/src/components/Message/__tests__/__snapshots__/MessageStatus.test.js.snap +++ b/src/components/Message/__tests__/__snapshots__/MessageStatus.test.js.snap @@ -1,162 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`MessageStatus theme v1 renders default delivered UI for the last message 1`] = ` - -
- Delivered -
- - - -
-`; - -exports[`MessageStatus theme v1 renders default read UI for the last message 1`] = ` - -
- other-user -
-
-
- o -
-
-
-`; - -exports[`MessageStatus theme v1 renders default sending UI for not the last message 1`] = ` - -
- Sending... -
-
- - - - - - - - - -
-
-`; - -exports[`MessageStatus theme v1 renders default sending UI for the last message 1`] = ` - -
- Sending... -
-
- - - - - - - - - -
-
-`; - -exports[`MessageStatus theme v2 renders default delivered UI for the last message 1`] = ` +exports[`MessageStatus renders default delivered UI for the last message 1`] = ` `; -exports[`MessageStatus theme v2 renders default read UI for the last message 1`] = ` +exports[`MessageStatus renders default read UI for the last message 1`] = `
`; -exports[`MessageStatus theme v2 renders default sending UI for not the last message 1`] = ` +exports[`MessageStatus renders default sending UI for not the last message 1`] = ` `; -exports[`MessageStatus theme v2 renders default sending UI for the last message 1`] = ` +exports[`MessageStatus renders default sending UI for the last message 1`] = `