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(); 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 deviceType = device.getPlatform();
const { textMatcher } = platformTypes[deviceType]; const { textMatcher } = platformTypes[deviceType];
const input = isThread ? 'messagebox-input-thread' : 'messagebox-input'; const input = isThread ? 'messagebox-input-thread' : 'messagebox-input';
@ -234,7 +234,7 @@ export {
navigateToRegister, navigateToRegister,
login, login,
logout, logout,
mockRandomMessage, mockMessage,
tapBack, tapBack,
sleep, sleep,
searchRoom, searchRoom,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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