2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
2021-06-22 19:41:55 +00:00
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
import data from '../../data';
|
2023-11-30 15:03:03 +00:00
|
|
|
import {
|
|
|
|
navigateToLogin,
|
|
|
|
tapBack,
|
|
|
|
login,
|
|
|
|
sleep,
|
|
|
|
platformTypes,
|
|
|
|
TTextMatcher,
|
|
|
|
navigateToRoom,
|
|
|
|
jumpToQuotedMessage
|
|
|
|
} from '../../helpers/app';
|
2021-06-22 19:41:55 +00:00
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
let textMatcher: TTextMatcher;
|
|
|
|
let alertButtonType: string;
|
2021-12-02 13:19:15 +00:00
|
|
|
|
2021-06-22 19:41:55 +00:00
|
|
|
async function clearCache() {
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2023-05-18 21:09:33 +00:00
|
|
|
await sleep(300); // wait animation
|
|
|
|
await waitFor(element(by.id('sidebar-settings')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('sidebar-settings')).tap();
|
2023-05-18 21:09:33 +00:00
|
|
|
await sleep(300); // wait animation
|
|
|
|
await waitFor(element(by.id('settings-view-clear-cache')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('settings-view-clear-cache')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('This will clear all your offline data.')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Clear').and(by.type(alertButtonType))).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by.id('rooms-list-view-item-jumping')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-06-22 19:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function waitForLoading() {
|
2023-03-07 12:28:51 +00:00
|
|
|
// if (device.getPlatform() === 'android') {
|
|
|
|
await sleep(10000);
|
|
|
|
// return; // FIXME: Loading indicator doesn't animate properly on android
|
|
|
|
// }
|
|
|
|
// await waitFor(element(by.id('loading-image')))
|
|
|
|
// .toBeVisible()
|
|
|
|
// .withTimeout(5000);
|
|
|
|
// await waitFor(element(by.id('loading-image')))
|
|
|
|
// .toBeNotVisible()
|
|
|
|
// .withTimeout(10000);
|
2021-06-22 19:41:55 +00:00
|
|
|
}
|
|
|
|
|
2023-05-08 13:45:46 +00:00
|
|
|
function getIndex() {
|
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-22 19:41:55 +00:00
|
|
|
describe('Room', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
2021-06-22 19:41:55 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
2021-06-22 19:41:55 +00:00
|
|
|
await navigateToLogin();
|
|
|
|
await login(data.adminUser, data.adminPassword);
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should jump to an old message and load its surroundings', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-22 19:41:55 +00:00
|
|
|
await navigateToRoom('jumping');
|
2022-08-19 21:14:37 +00:00
|
|
|
await waitFor(element(by[textMatcher]('295')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2022-08-19 21:14:37 +00:00
|
|
|
await sleep(2000);
|
2023-11-30 15:03:03 +00:00
|
|
|
await jumpToQuotedMessage(element(by[textMatcher]('1')).atIndex(0));
|
2021-06-22 19:41:55 +00:00
|
|
|
await waitForLoading();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('1')).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2023-03-07 12:28:51 +00:00
|
|
|
.withTimeout(30000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('2'))).toExist();
|
2021-06-22 19:41:55 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should tap FAB and scroll to bottom', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('nav-jump-to-bottom')))
|
|
|
|
.toExist()
|
2022-05-26 17:10:24 +00:00
|
|
|
.withTimeout(15000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('nav-jump-to-bottom')).tap();
|
2022-08-19 21:14:37 +00:00
|
|
|
await waitFor(element(by[textMatcher]("Go to jumping-thread's thread")))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2022-05-26 17:10:24 +00:00
|
|
|
.withTimeout(15000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await clearCache();
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-06-22 19:41:55 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should load messages on scroll', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-22 19:41:55 +00:00
|
|
|
await navigateToRoom('jumping');
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view-messages')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('300')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2023-03-07 12:28:51 +00:00
|
|
|
.withTimeout(30000);
|
2021-06-22 19:41:55 +00:00
|
|
|
let found = false;
|
|
|
|
while (!found) {
|
|
|
|
try {
|
2021-12-02 13:19:15 +00:00
|
|
|
const direction = device.getPlatform() === 'android' ? 'down' : 'up';
|
|
|
|
await element(by.id('room-view-messages')).scroll(500, direction);
|
|
|
|
await expect(element(by[textMatcher]('249'))).toExist();
|
2021-06-22 19:41:55 +00:00
|
|
|
found = true;
|
|
|
|
} catch {
|
2021-07-02 17:39:39 +00:00
|
|
|
//
|
2021-06-22 19:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
await clearCache();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should search for old message and load its surroundings', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-22 19:41:55 +00:00
|
|
|
await navigateToRoom('jumping');
|
2021-12-02 13:19:15 +00:00
|
|
|
await sleep(1000); // wait for proper load the room
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('room-view-search')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('search-messages-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('search-message-view-input')).replaceText('30');
|
2023-05-08 13:45:46 +00:00
|
|
|
await waitFor(element(by[textMatcher]('30')).atIndex(getIndex()))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2021-12-02 13:19:15 +00:00
|
|
|
.withTimeout(30000);
|
2022-09-12 14:51:33 +00:00
|
|
|
await sleep(1000);
|
2023-05-08 13:45:46 +00:00
|
|
|
await element(by[textMatcher]('30')).atIndex(getIndex()).tap();
|
2021-06-22 19:41:55 +00:00
|
|
|
await waitForLoading();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('30')).atIndex(0))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(30000);
|
|
|
|
await expect(element(by[textMatcher]('31'))).toExist();
|
|
|
|
await expect(element(by[textMatcher]('32'))).toExist();
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-06-22 19:41:55 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should load newer and older messages', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let found = false;
|
|
|
|
while (!found) {
|
|
|
|
try {
|
|
|
|
// it doesn't recognize this list
|
|
|
|
await element(by.id('room-view-messages')).scroll(500, 'up');
|
2023-06-26 19:28:11 +00:00
|
|
|
await expect(element(by[textMatcher]('Load older'))).toBeVisible();
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('5'))).toExist();
|
|
|
|
found = true;
|
|
|
|
} catch {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Load older')).atIndex(0).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('4')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.5);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('1')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('25')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('50')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'slow', 0.3);
|
2023-06-26 19:28:11 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Load newer')).atIndex(0).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('104')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Load newer')).atIndex(0).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('154')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Load newer')).atIndex(0).tap();
|
2023-05-18 21:09:33 +00:00
|
|
|
await waitFor(element(by[textMatcher]('202')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toNotExist()
|
|
|
|
.withTimeout(5000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await expect(element(by[textMatcher]('Load more'))).toNotExist();
|
2021-06-22 19:41:55 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
const expectThreadMessages = async (message: string) => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view-title-thread 1')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2022-11-25 13:21:56 +00:00
|
|
|
.withTimeout(10000);
|
2022-08-19 21:14:37 +00:00
|
|
|
await waitFor(element(by[textMatcher](message)).atIndex(0))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher](message)).atIndex(0).tap();
|
2021-07-02 17:39:39 +00:00
|
|
|
};
|
2021-06-22 19:41:55 +00:00
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Threads', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true });
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to a thread from another room', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-22 19:41:55 +00:00
|
|
|
await navigateToRoom('jumping');
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]("Go to jumping-thread's thread")).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-11-30 15:03:03 +00:00
|
|
|
await jumpToQuotedMessage(element(by[textMatcher]("Go to jumping-thread's thread")).atIndex(0));
|
2021-09-13 20:41:05 +00:00
|
|
|
await expectThreadMessages("Go to jumping-thread's thread");
|
2021-06-22 19:41:55 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should tap on thread message from main room', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view-title-jumping-thread')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('thread message sent to main room')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await element(by[textMatcher]('thread message sent to main room')).atIndex(0).tap();
|
2021-06-22 19:41:55 +00:00
|
|
|
await expectThreadMessages('thread message sent to main room');
|
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should tap on quote', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view-title-jumping-thread')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('quoted')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-11-30 15:03:03 +00:00
|
|
|
await jumpToQuotedMessage(element(by[textMatcher]('quoted')).atIndex(0));
|
2021-06-22 19:41:55 +00:00
|
|
|
await expectThreadMessages('quoted');
|
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should jump from search message', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view-title-jumping-thread')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('room-view-search')).atIndex(0).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('search-messages-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('search-message-view-input')).replaceText('to be searched');
|
2023-05-08 13:45:46 +00:00
|
|
|
await waitFor(element(by[textMatcher]('to be searched')).atIndex(getIndex()))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2021-12-02 13:19:15 +00:00
|
|
|
.withTimeout(30000);
|
2023-05-08 13:45:46 +00:00
|
|
|
await element(by[textMatcher]('to be searched')).atIndex(getIndex()).tap();
|
2021-06-22 19:41:55 +00:00
|
|
|
await expectThreadMessages('to be searched');
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
// TODO: Threads pagination
|
|
|
|
});
|