mockRandomMessage -> mockMessage

This commit is contained in:
Diego Mello 2023-03-01 16:39:32 -03:00
parent 7ba9150255
commit 91a4eeb9b9
9 changed files with 24 additions and 32 deletions

View File

@ -94,7 +94,7 @@ async function logout() {
await expect(element(by.id('new-server-view'))).toBeVisible();
}
async function mockRandomMessage(message: string, isThread = false) {
async function mockMessage(message: string, isThread = false) {
const deviceType = device.getPlatform();
const { textMatcher } = platformTypes[deviceType];
const input = isThread ? 'messagebox-input-thread' : 'messagebox-input';
@ -234,7 +234,7 @@ export {
navigateToRegister,
login,
logout,
mockRandomMessage,
mockMessage,
tapBack,
sleep,
searchRoom,

View File

@ -11,7 +11,7 @@ import {
TTextMatcher,
tapAndWaitFor,
expectValidRegisterOrRetry,
mockRandomMessage
mockMessage
} from '../../helpers/app';
import data from '../../data';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
@ -159,7 +159,7 @@ describe('E2E Encryption', () => {
});
it('should send message and be able to read it', async () => {
mockedMessageText = await mockRandomMessage('message');
mockedMessageText = await mockMessage('message');
await tapBack();
});
});

View File

@ -11,7 +11,7 @@ import {
TTextMatcher,
sleep,
checkRoomTitle,
mockRandomMessage
mockMessage
} from '../../helpers/app';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
@ -87,7 +87,7 @@ describe('Broadcast room', () => {
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
message = await mockRandomMessage('message');
message = await mockMessage('message');
await tapBack();
});

View File

@ -1,15 +1,7 @@
import { device, waitFor, element, by, expect } from 'detox';
import data from '../../data';
import {
navigateToLogin,
login,
tapBack,
platformTypes,
TTextMatcher,
mockRandomMessage,
navigateToRoom
} from '../../helpers/app';
import { navigateToLogin, login, tapBack, platformTypes, TTextMatcher, mockMessage, navigateToRoom } from '../../helpers/app';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
@ -139,7 +131,7 @@ describe('Join public room', () => {
});
it('should send message', async () => {
await mockRandomMessage(`${random()}message`);
await mockMessage(`${random()}message`);
});
it('should have notifications and leave channel', async () => {

View File

@ -1,7 +1,7 @@
import { device, waitFor, element, by, expect } from 'detox';
import data from '../../data';
import { navigateToLogin, login, searchRoom, mockRandomMessage } from '../../helpers/app';
import { navigateToLogin, login, searchRoom, mockMessage } from '../../helpers/app';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
@ -72,7 +72,7 @@ describe('Join protected room', () => {
});
it('should send message', async () => {
await mockRandomMessage(`${random()}message`);
await mockMessage(`${random()}message`);
});
});
});

View File

@ -9,7 +9,7 @@ import {
tryTapping,
platformTypes,
TTextMatcher,
mockRandomMessage
mockMessage
} from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
@ -84,7 +84,7 @@ describe('Room screen', () => {
describe('Usage', () => {
describe('Messagebox', () => {
it('should send message', async () => {
randomMessage = await mockRandomMessage('message');
randomMessage = await mockMessage('message');
});
// describe('Emoji Keyboard', () => {
@ -423,7 +423,7 @@ describe('Room screen', () => {
});
it('should edit message', async () => {
const editMessage = await mockRandomMessage('edit');
const editMessage = await mockMessage('edit');
const editedMessage = `${editMessage}ed`;
await tryTapping(element(by[textMatcher](editMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
@ -439,7 +439,7 @@ describe('Room screen', () => {
.withTimeout(60000);
});
it('should quote message', async () => {
const quoteMessage = await mockRandomMessage('quote');
const quoteMessage = await mockMessage('quote');
const quotedMessage = `${quoteMessage}d`;
await tryTapping(element(by[textMatcher](quoteMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
@ -457,7 +457,7 @@ describe('Room screen', () => {
});
it('should delete message', async () => {
const deleteMessage = await mockRandomMessage('delete');
const deleteMessage = await mockMessage('delete');
await tryTapping(element(by[textMatcher](deleteMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()

View File

@ -10,7 +10,7 @@ import {
TTextMatcher,
tapAndWaitFor,
tryTapping,
mockRandomMessage
mockMessage
} from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser, post } from '../../helpers/data_setup';
import random from '../../helpers/random';
@ -152,7 +152,7 @@ describe('Room actions screen', () => {
it('should show starred message and unstar it', async () => {
// Go back to room and send a message
await tapBack();
const messageToStar = await mockRandomMessage('messageToStar');
const messageToStar = await mockMessage('messageToStar');
// Star the message
await starMessage(messageToStar);
@ -189,7 +189,7 @@ describe('Room actions screen', () => {
it('should show pinned message and unpin it', async () => {
// Go back to room and send a message
await tapBack();
const messageToPin = await mockRandomMessage('messageToPin');
const messageToPin = await mockMessage('messageToPin');
// Pin the message
await pinMessage(messageToPin);

View File

@ -7,7 +7,7 @@ import {
tapBack,
navigateToRoom,
platformTypes,
mockRandomMessage,
mockMessage,
sleep
} from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
@ -97,7 +97,7 @@ describe('Discussion', () => {
await waitFor(element(by.id('messagebox')))
.toBeVisible()
.withTimeout(60000);
discussionFromActionSheet = await mockRandomMessage('message');
discussionFromActionSheet = await mockMessage('message');
});
it('should create discussion', async () => {

View File

@ -9,7 +9,7 @@ import {
TTextMatcher,
tapAndWaitFor,
navigateToRoom,
mockRandomMessage
mockMessage
} from '../../helpers/app';
import { createRandomRoom, createRandomUser } from '../../helpers/data_setup';
@ -73,7 +73,7 @@ describe('Threads', () => {
describe('Thread', () => {
let thread: string;
it('should create thread', async () => {
thread = await mockRandomMessage('thread');
thread = await mockMessage('thread');
await element(by[textMatcher](thread)).atIndex(0).tap();
await element(by[textMatcher](thread)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
@ -118,7 +118,7 @@ describe('Threads', () => {
});
it('should send message in thread only', async () => {
const messageText = await mockRandomMessage('threadonly', true);
const messageText = await mockMessage('threadonly', true);
await tapBack();
await waitFor(element(by.id(`room-view-title-${thread}`)))
.not.toExist()
@ -154,7 +154,7 @@ describe('Threads', () => {
it('should navigate to thread from thread name', async () => {
const messageText = 'navthreadname';
await mockRandomMessage('dummymessagebetweenthethread');
await mockMessage('dummymessagebetweenthethread');
await element(by.id(`message-thread-button-${thread}`)).tap();
await waitFor(element(by.id('messagebox-input-thread')))
.toExist()