From 8eb1eb2d7064cbabad14560211a6fff821e63bb3 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 24 May 2021 02:09:16 +0300 Subject: [PATCH] Drop redundant tests --- .gitignore | 1 + tests/assertions.ts | 186 --------------- tests/config.ts | 3 - tests/helpers.ts | 3 - tests/init.js | 61 ----- tests/initApp.tsx | 24 -- tests/messageLayout.test.tsx | 428 ----------------------------------- tests/staticFileMock.js | 2 - 8 files changed, 1 insertion(+), 707 deletions(-) delete mode 100644 tests/assertions.ts delete mode 100644 tests/config.ts delete mode 100644 tests/helpers.ts delete mode 100644 tests/init.js delete mode 100644 tests/initApp.tsx delete mode 100644 tests/messageLayout.test.tsx delete mode 100644 tests/staticFileMock.js diff --git a/.gitignore b/.gitignore index ebd791d3..a2dbced2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules .env src/lib/gramjs/build/ build-contest/ +tests/ .idea *.iml dev/perf/screenshot* diff --git a/tests/assertions.ts b/tests/assertions.ts deleted file mode 100644 index f9f31671..00000000 --- a/tests/assertions.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { ActionTypes } from '../src/global/types'; -import { addReducer, getGlobal } from '../src/lib/teact/teactn'; - -import { selectChat, selectUser } from '../src/modules/selectors'; -import { getChatTitle, getUserFullName } from '../src/modules/helpers'; - -export function expectIncoming(messageElement: HTMLDivElement) { - expect(messageElement).not.toHaveClass('own'); -} - -export function expectOutgoing(messageElement: HTMLDivElement) { - expect(messageElement).toHaveClass('own'); - expectNoAvatar(messageElement); -} - -export function expectAsForwarded(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.message-content')).toHaveClass('is-forwarded'); - expect(messageElement.querySelector('.message-title')).toHaveTextContent('Forwarded message'); -} - -export function expectNotAsForwarded(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.message-content')).not.toHaveClass('is-forwarded'); - - const messageTitle = messageElement.querySelector('.message-title'); - if (messageTitle) { - expect(messageTitle).not.toHaveTextContent('Forwarded message'); - } -} - -export function expectInteractiveSender(messageElement: HTMLDivElement, senderId: number) { - const senderName = messageElement.querySelector('.content-inner .message-title')!; - expect(senderName.firstChild).toHaveClass('interactive'); - - if (senderId > 0) { - const user = selectUser(getGlobal(), senderId)!; - expect(senderName.firstChild).toHaveTextContent(getUserFullName(user)!); - expectClickToCallAction(senderName.firstChild as Element, 'openUserInfo', { id: senderId }); - } else { - const chat = selectChat(getGlobal(), senderId)!; - expect(senderName.firstChild).toHaveTextContent(getChatTitle(chat)!); - expectClickToCallAction(senderName.firstChild as Element, 'openChat', { id: senderId }); - } -} - -export function expectHiddenSender(messageElement: HTMLDivElement, hiddenSenderName: string) { - const senderName = messageElement.querySelector('.content-inner .message-title')!; - expect(senderName.firstChild).not.toHaveClass('interactive'); - expect(senderName.firstChild).toHaveTextContent(hiddenSenderName); - expectClickNotToCallAction(senderName.firstChild as Element, 'openUserInfo'); - expectClickNotToCallAction(senderName.firstChild as Element, 'openChat'); -} - -export function expectNoSender(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.message-title')).toBeNull(); -} - -export function expectViaBot(messageElement: HTMLDivElement, botId: number) { - const botName = messageElement.querySelector('.content-inner .message-title')!; - const { children, children: { length } } = botName; - expect(children[length - 2]).toHaveClass('via'); - expect(children[length - 1]).toHaveClass('interactive'); - const bot = selectUser(getGlobal(), botId)!; - expect(children[length - 1]).toHaveTextContent(`@${bot.username}`); - expectClickToCallAction(children[length - 1], 'openUserInfo', { id: botId }); -} - -export function expectAvatar(messageElement: HTMLDivElement, senderId?: number, hiddenNameInitial?: string) { - const avatar = messageElement.querySelector(':scope > .Avatar')!; - - if (senderId) { - expect(avatar).toHaveAttribute('data-test-sender-id', String(senderId)); - expectClickToCallAction(avatar, senderId > 0 ? 'openUserInfo' : 'openChat', { id: senderId }); - } else { - expect(avatar).not.toHaveAttribute('data-test-sender-id'); - expect(avatar).toHaveTextContent(hiddenNameInitial!); - expectClickNotToCallAction(avatar, 'openUserInfo'); - expectClickNotToCallAction(avatar, 'openChat'); - } -} - -export function expectNoAvatar(messageElement: HTMLDivElement) { - expect(messageElement.querySelector(':scope > .Avatar')).toBeNull(); -} - -export function expectFocusButton(messageElement: HTMLDivElement, chatId: number, messageId: number) { - const button = messageElement.querySelector('.message-action-button')!; - expect(button).not.toBeNull(); - expect(button.querySelector('i')).toHaveClass('icon-arrow-right'); - expectClickToCallAction(button, 'focusMessage', { chatId, messageId }); -} - -export function expectForwardButton(messageElement: HTMLDivElement) { - const button = messageElement.querySelector('.message-action-button .icon-share-filled')!; - expect(button).not.toBeNull(); -} - -export function expectNoFocusButton(messageElement: HTMLDivElement) { - const button = messageElement.querySelector('.message-action-button')!; - expect(button).toBeNull(); -} - -export function expectAdminTitle(messageElement: HTMLDivElement, value: string) { - expect(messageElement.querySelector('.admin-title')).toHaveTextContent(value); -} - -export function expectNoAdminTitle(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.admin-title')).toBeNull(); -} - -export function expectSignature(messageElement: HTMLDivElement, value: string) { - expect(messageElement.querySelector('.message-signature')).toHaveTextContent(value); -} - -export function expectNoSignature(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.message-signature')).toBeNull(); -} - -export function expectSingleGroup(messageElement: HTMLDivElement) { - expect(messageElement).toHaveClass('first-in-group', 'last-in-group'); -} - -export function expectInGroup(messageElement: HTMLDivElement) { - expect(messageElement).not.toHaveClass('first-in-group', 'last-in-group'); -} - -export function expectCommentButton( - messageElement: HTMLDivElement, - commentsCount: number, - authorsCount: number, - messageId: number, - discussionChatId: number, -) { - const button = messageElement.querySelector('.CommentButton')!; - expect(button).not.toBeNull(); - - if (commentsCount) { - expect(button.querySelector('.label')).toHaveTextContent(`${commentsCount} Comments`); - expect(button.querySelectorAll('.Avatar')).toHaveLength(Math.min(authorsCount, 3)); - } else { - expect(button.querySelector('.label')).toHaveTextContent('Leave a comment'); - expect(button.querySelectorAll('.Avatar')).toHaveLength(0); - } - - expectClickToCallAction(button, 'openChat', { id: discussionChatId, threadId: messageId }); -} - -export function expectNoCommentButton(messageElement: HTMLDivElement) { - const button = messageElement.querySelector('.CommentButton')!; - expect(button).toBeNull(); -} - -export function expectReply(messageElement: HTMLDivElement, originSenderId: number) { - const senderName = messageElement.querySelector('.EmbeddedMessage .message-title')!; - expect(senderName).not.toHaveClass('interactive'); - - if (originSenderId > 0) { - const user = selectUser(getGlobal(), originSenderId)!; - expect(senderName).toHaveTextContent(getUserFullName(user)!); - } else { - const chat = selectChat(getGlobal(), originSenderId)!; - expect(senderName).toHaveTextContent(getChatTitle(chat)!); - } -} - -export function expectNoReply(messageElement: HTMLDivElement) { - expect(messageElement.querySelector('.EmbeddedMessage')).toBeNull(); -} - -export function expectThreadTop(messageElement: HTMLDivElement) { - expect(messageElement).toHaveClass('is-thread-top'); - expect(messageElement.nextElementSibling).toHaveTextContent('Discussion started'); -} - -export function expectClickToCallAction(element: Element, action: ActionTypes, args: any) { - const reducer = jest.fn(); - addReducer(action, reducer); - element.dispatchEvent(new Event('click', { bubbles: true })); - expect(reducer).toBeCalledWith(expect.anything(), expect.anything(), args); -} - -export function expectClickNotToCallAction(element: Element, action: ActionTypes) { - const reducer = jest.fn(); - addReducer(action, reducer); - element.dispatchEvent(new Event('click', { bubbles: true })); - expect(reducer).not.toBeCalled(); -} diff --git a/tests/config.ts b/tests/config.ts deleted file mode 100644 index 15564003..00000000 --- a/tests/config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const REQUEST_DELAY = 3000; -export const AFTER_ALL_DELAY = 500; -export const BEFORE_ALL_TIMEOUT = 5000; diff --git a/tests/helpers.ts b/tests/helpers.ts deleted file mode 100644 index de62d0bf..00000000 --- a/tests/helpers.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function getMessageElement(messageId: number) { - return document.getElementById(`message${messageId}`) as HTMLDivElement; -} diff --git a/tests/init.js b/tests/init.js deleted file mode 100644 index 4d1a483b..00000000 --- a/tests/init.js +++ /dev/null @@ -1,61 +0,0 @@ -import '@testing-library/jest-dom'; - -import { Buffer } from 'buffer/'; -import { Crypto } from '@peculiar/webcrypto'; - -require('dotenv') - .config(); - -localStorage.setItem('GramJs:sessionId', 'GramJs-session-TEST'); -localStorage.setItem('GramJs-session-TEST', process.env.TEST_SESSION); - -jest.mock('../src/api/gramjs/worker/provider'); -jest.mock('../src/util/oggToWav'); -jest.mock('../src/util/webpToPng'); -jest.mock('../src/util/voiceRecording'); -jest.mock('../src/lib/rlottie/RLottie'); - -Object.assign(global, { - Buffer, - crypto: new Crypto(), -}); - -Object.defineProperty(window, 'matchMedia', { - writable: true, - value: jest.fn() - .mockImplementation((query) => ({ - matches: false, - media: query, - onchange: null, - addListener: jest.fn(), // Deprecated - removeListener: jest.fn(), // Deprecated - addEventListener: jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent: jest.fn(), - })), -}); - -Object.defineProperty(global.Element.prototype, 'innerText', { - get() { - const el = this.cloneNode(true); // can skip if mutability isn't a concern - el.querySelectorAll('script,style') - .forEach((s) => s.remove()); - return el.textContent; - }, - configurable: true, // make it so that it doesn't blow chunks on re-running tests with things like --watch -}); - -Object.defineProperty(global, 'IntersectionObserver', { - writable: true, - configurable: true, - value: class { - observe() { - } - - unobserve() { - } - - disconnect() { - } - }, -}); diff --git a/tests/initApp.tsx b/tests/initApp.tsx deleted file mode 100644 index a460f38e..00000000 --- a/tests/initApp.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from '../src/lib/teact/teact'; -import TeactDOM from '../src/lib/teact/teact-dom'; -import { addReducer, getDispatch } from '../src/lib/teact/teactn'; -import '../src/global'; -import Main from '../src/components/main/Main'; - -export default () => { - return new Promise((resolve) => { - const root = document.createElement('div'); - document.body.appendChild(root); - - getDispatch().init(); - getDispatch().initApi(); - - TeactDOM.render( -
, - root, - ); - - addReducer('saveSession', () => { - resolve(); - }); - }); -}; diff --git a/tests/messageLayout.test.tsx b/tests/messageLayout.test.tsx deleted file mode 100644 index f72b2410..00000000 --- a/tests/messageLayout.test.tsx +++ /dev/null @@ -1,428 +0,0 @@ -import { getDispatch } from '../src/lib/teact/teactn'; - -import { AFTER_ALL_DELAY, BEFORE_ALL_TIMEOUT, REQUEST_DELAY } from './config'; -import initApp from './initApp'; -import { getMessageElement } from './helpers'; -import { - expectAvatar, - expectNoAvatar, - expectAdminTitle, - expectNoAdminTitle, - expectFocusButton, - expectNoFocusButton, - expectIncoming, - expectOutgoing, - expectInteractiveSender, - expectNoSender, - expectHiddenSender, - expectThreadTop, - expectReply, - expectNoReply, - expectSingleGroup, - expectInGroup, - expectAsForwarded, - expectNotAsForwarded, - expectViaBot, - expectForwardButton, - expectCommentButton, - expectNoCommentButton, - expectNoSignature, - expectSignature, -} from './assertions'; -import { pause } from '../src/util/schedulers'; -import { LoadMoreDirection } from '../src/types'; - -describe('Message layout', () => { - beforeAll(async () => { - await initApp(); - }, BEFORE_ALL_TIMEOUT); - - describe('Saved Messages', () => { - beforeAll(async () => { - getDispatch().openChat({ id: 628495532 }); - await pause(REQUEST_DELAY); - }, BEFORE_ALL_TIMEOUT); - - afterAll(async () => { - await pause(AFTER_ALL_DELAY); - }); - - test('Incoming forwarded simple (`isFirstInGroup`, not `isLastInGroup`)', () => { - const messageElement = getMessageElement(2955); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 314552265); - expectNoAvatar(messageElement); - expectFocusButton(messageElement, -178999811, 2950); - }); - - test('Incoming forwarded simple (`isLastInGroup`, not `isFirstInGroup`)', () => { - const messageElement = getMessageElement(2956); - expectIncoming(messageElement); - expectNoSender(messageElement); - expectAvatar(messageElement, 314552265); - expectFocusButton(messageElement, -178999811, 2951); - }); - - test('Outgoing simple (`isFirstInGroup`, `isLastInGroup`)', () => { - const messageElement = getMessageElement(2957); - expectOutgoing(messageElement); - expectNoSender(messageElement); - }); - - test('Incoming forwarded direct from hidden ', () => { - const messageElement = getMessageElement(2959); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectHiddenSender(messageElement, 'Mike Ravdonikas'); - expectAvatar(messageElement, undefined, 'MR'); - expectNoFocusButton(messageElement); - }); - - test('Incoming forwarded from group from hidden ', () => { - const messageElement = getMessageElement(2958); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectHiddenSender(messageElement, 'Антон'); - expectAvatar(messageElement, undefined, 'А'); - expectFocusButton(messageElement, -178999811, 2935); - }); - - test('Incoming forwarded via bot', () => { - const messageElement = getMessageElement(2960); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectInteractiveSender(messageElement, 408193052); - expectViaBot(messageElement, 140267078); - expectAvatar(messageElement, 408193052); - expectFocusButton(messageElement, -178999811, 2934); - }); - - test('Outgoing forwarded via bot', () => { - const messageElement = getMessageElement(2964); - expectOutgoing(messageElement); - expectNotAsForwarded(messageElement); - expect(messageElement.querySelector('.content-inner .message-title')!.childElementCount).toEqual(2); - expectViaBot(messageElement, 140267078); - }); - - test('Incoming forwarded channel post', () => { - const messageElement = getMessageElement(2965); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1038976893); - expectAvatar(messageElement, -1038976893); - expectFocusButton(messageElement, -1038976893, 192); - }); - }); - - describe('Group', () => { - beforeAll(async () => { - getDispatch().openChat({ id: -178999811 }); - await pause(REQUEST_DELAY); - - getDispatch().loadViewportMessages({ direction: LoadMoreDirection.Backwards }); - await pause(REQUEST_DELAY); - }, BEFORE_ALL_TIMEOUT * 2); - - afterAll(async () => { - await pause(AFTER_ALL_DELAY); - }); - - test('Incoming simple (`isFirstInGroup`, not `isLastInGroup`)', () => { - const messageElement = getMessageElement(2945); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 3718260); - expectNoAvatar(messageElement); - }); - - test('Incoming simple (`isLastInGroup`, not `isFirstInGroup`)', () => { - const messageElement = getMessageElement(2946); - expectIncoming(messageElement); - expectNoSender(messageElement); - expectAvatar(messageElement, 3718260); - }); - - test('Outgoing simple (`isFirstInGroup`, `isLastInGroup`)', () => { - const messageElement = getMessageElement(2943); - expectOutgoing(messageElement); - expectNoSender(messageElement); - }); - - test('Incoming forwarded (not `isLastInGroup`)', () => { - const messageElement = getMessageElement(2950); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, 314552265); - expectNoAvatar(messageElement); - }); - - test('Incoming forwarded (`isLastInGroup`)', () => { - const messageElement = getMessageElement(2951); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, 314552265); - expectAvatar(messageElement, 3718260); - }); - - test('Outgoing forwarded', () => { - const messageElement = getMessageElement(2954); - expectOutgoing(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, 3718260); - }); - - test('Incoming forwarded from hidden', () => { - const messageElement = getMessageElement(2935); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectHiddenSender(messageElement, 'Антон'); - expectAvatar(messageElement, 3718260); - }); - - test('Outgoing forwarded from hidden', () => { - const messageElement = getMessageElement(2936); - expectOutgoing(messageElement); - expectAsForwarded(messageElement); - expectHiddenSender(messageElement, 'Антон'); - }); - - test('Incoming forwarded via bot', () => { - const messageElement = getMessageElement(2934); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, 408193052); - expectViaBot(messageElement, 140267078); - expectAvatar(messageElement, 3718260); - }); - - test('Outgoing forwarded via bot', () => { - const messageElement = getMessageElement(2732); - expectOutgoing(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, 408193052); - expectViaBot(messageElement, 140267078); - }); - - test('Incoming forwarded channel post', () => { - const messageElement = getMessageElement(2952); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1038976893); - expectAvatar(messageElement, 3718260); - expectFocusButton(messageElement, -1038976893, 192); - }); - - test('Outgoing forwarded channel post', () => { - const messageElement = getMessageElement(2953); - expectOutgoing(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1038976893); - expectFocusButton(messageElement, -1038976893, 192); - }); - }); - - describe('Channel', () => { - beforeAll(async () => { - getDispatch().openChat({ id: -1386471086 }); - await pause(REQUEST_DELAY); - }, BEFORE_ALL_TIMEOUT); - - afterAll(async () => { - await pause(AFTER_ALL_DELAY); - }); - - test('Single post with comments', () => { - const messageElement = getMessageElement(2); - expectIncoming(messageElement); - expectNoSender(messageElement); - expectNoAvatar(messageElement); - expectForwardButton(messageElement); - expectNoAdminTitle(messageElement); - expectSingleGroup(messageElement); - expectCommentButton(messageElement, 4, 2, 2, -1403448678); - expectNoSignature(messageElement); - }); - - test('Post in group (first)', () => { - const messageElement = getMessageElement(3); - expectIncoming(messageElement); - expectNoSender(messageElement); - expectNoAvatar(messageElement); - expectForwardButton(messageElement); - expectNoAdminTitle(messageElement); - expectInGroup(messageElement); - expectCommentButton(messageElement, 0, 0, 3, -1403448678); - }); - - test('Post in group (last)', () => { - const messageElement = getMessageElement(4); - expectIncoming(messageElement); - expectNoSender(messageElement); - expectNoAvatar(messageElement); - expectForwardButton(messageElement); - expectNoAdminTitle(messageElement); - expectInGroup(messageElement); - expectCommentButton(messageElement, 0, 0, 4, -1403448678); - }); - - test('Signed post', () => { - const messageElement = getMessageElement(10); - expectSignature(messageElement, 'Sasha Alejandro'); - expectNoSender(messageElement); - expectNoAdminTitle(messageElement); - }); - - test('Post which was removed from discussion', () => { - const messageElement = getMessageElement(15); - expectNoCommentButton(messageElement); - }); - }); - - describe('Discussion', () => { - beforeAll(async () => { - getDispatch().openChat({ id: -1403448678 }); - await pause(REQUEST_DELAY); - }, BEFORE_ALL_TIMEOUT); - - afterAll(async () => { - await pause(AFTER_ALL_DELAY); - }); - - test('Linked channel post', () => { - const messageElement = getMessageElement(14); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1386471086); - expectNoAvatar(messageElement); - expectFocusButton(messageElement, -1386471086, 3); - expectAdminTitle(messageElement, 'channel'); - expectInGroup(messageElement); - }); - - test('Linked channel post (following previous)', () => { - const messageElement = getMessageElement(15); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectNoSender(messageElement); - expectAvatar(messageElement, -1386471086); - expectFocusButton(messageElement, -1386471086, 4); - expectNoAdminTitle(messageElement); - expectInGroup(messageElement); - }); - - test('Incoming forwarded not linked channel post', () => { - const messageElement = getMessageElement(6); - expectIncoming(messageElement); - expectAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1038976893); - expectAvatar(messageElement, 3718260); - expectFocusButton(messageElement, -1038976893, 192); - expectNoAdminTitle(messageElement); - }); - - test('Incoming simple (`isFirstInGroup`, `isLastInGroup`)', () => { - const messageElement = getMessageElement(4); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 3718260); - expectAvatar(messageElement, 3718260); - }); - - test('Outgoing as anonymous (`isFirstInGroup`)', () => { - const messageElement = getMessageElement(11); - expectOutgoing(messageElement); - expectInteractiveSender(messageElement, -1403448678); - }); - - test('Incoming reply to linked post', () => { - const messageElement = getMessageElement(7); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 3718260); - expectAvatar(messageElement, 3718260); - expectReply(messageElement, -1386471086); - }); - - test('Outgoing reply to anonymous post', () => { - const messageElement = getMessageElement(13); - expectOutgoing(messageElement); - expectInteractiveSender(messageElement, -1403448678); - expectReply(messageElement, -1403448678); - }); - - test('Outgoing reply to linked post (with admin title)', () => { - const messageElement = getMessageElement(42); - expectOutgoing(messageElement); - expectInteractiveSender(messageElement, -1403448678); - expectReply(messageElement, -1386471086); - expectAdminTitle(messageElement, 'Super Name'); - expectNoSignature(messageElement); - }); - - test('Incoming linked channel post (signed)', () => { - const messageElement = getMessageElement(111); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1386471086); - expectFocusButton(messageElement, -1386471086, 10); - expectAdminTitle(messageElement, 'channel'); - expectSignature(messageElement, 'Sasha Alejandro'); - }); - }); - - describe('Comment Thread', () => { - beforeAll(async () => { - getDispatch().openChat({ id: -1386471086 }); - await pause(REQUEST_DELAY); - - getDispatch().openChat({ id: -1403448678, threadId: 2 }); - await pause(REQUEST_DELAY); - }, BEFORE_ALL_TIMEOUT * 2); - - afterAll(async () => { - await pause(AFTER_ALL_DELAY); - }); - - test('Original channel post', () => { - const messageElement = getMessageElement(2); - expectIncoming(messageElement); - expectNotAsForwarded(messageElement); - expectInteractiveSender(messageElement, -1386471086); - expectNoAvatar(messageElement); - expectFocusButton(messageElement, -1386471086, 2); - expectAdminTitle(messageElement, 'channel'); - expectSingleGroup(messageElement); - expectThreadTop(messageElement); - }); - - test('Incoming reply to original post', () => { - const messageElement = getMessageElement(7); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 3718260); - expectAvatar(messageElement, 3718260); - expectNoReply(messageElement); - }); - - test('Outgoing reply', () => { - const messageElement = getMessageElement(39); - expectOutgoing(messageElement); - expectInteractiveSender(messageElement, -1403448678); - expectNoReply(messageElement); - }); - - test('Incoming reply to another comment', () => { - const messageElement = getMessageElement(41); - expectIncoming(messageElement); - expectInteractiveSender(messageElement, 3718260); - expectAvatar(messageElement, 3718260); - expectReply(messageElement, -1403448678); - }); - - test('Outgoing reply (with admin title)', () => { - const messageElement = getMessageElement(42); - expectOutgoing(messageElement); - expectInteractiveSender(messageElement, -1403448678); - expectNoReply(messageElement); - expectAdminTitle(messageElement, 'Super Name'); - expectNoSignature(messageElement); - }); - }); -}); diff --git a/tests/staticFileMock.js b/tests/staticFileMock.js deleted file mode 100644 index b2b70519..00000000 --- a/tests/staticFileMock.js +++ /dev/null @@ -1,2 +0,0 @@ -// This fixed an error related to the CSS and loading gif breaking my Jest test -module.exports = 'test-file-stub';