2021-06-22 19:41:55 +00:00
|
|
|
const data = require('../../data');
|
2021-12-02 13:19:15 +00:00
|
|
|
const { navigateToLogin, tapBack, login, searchRoom, sleep, platformTypes } = require('../../helpers/app');
|
2021-06-22 19:41:55 +00:00
|
|
|
|
|
|
|
async function navigateToRoom(roomName) {
|
2021-09-13 20:41:05 +00:00
|
|
|
await searchRoom(`${roomName}`);
|
|
|
|
await element(by.id(`rooms-list-view-item-${roomName}`)).tap();
|
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${roomName}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-06-22 19:41:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 13:19:15 +00:00
|
|
|
let textMatcher;
|
|
|
|
let alertButtonType;
|
|
|
|
|
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();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-06-22 19:41:55 +00:00
|
|
|
await element(by.id('sidebar-settings')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('settings-view')))
|
|
|
|
.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() {
|
2021-12-02 13:19:15 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
await sleep(10000);
|
|
|
|
return; // FIXME: Loading indicator doesn't animate properly on android
|
|
|
|
}
|
2022-08-19 21:14:37 +00:00
|
|
|
await waitFor(element(by.id('loading-image')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2022-08-19 21:14:37 +00:00
|
|
|
await waitFor(element(by.id('loading-image')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeNotVisible()
|
|
|
|
.withTimeout(10000);
|
2021-06-22 19:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('Room', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
before(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 () => {
|
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);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('1')).atIndex(0).tap();
|
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()
|
|
|
|
.withTimeout(10000);
|
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 () => {
|
|
|
|
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 () => {
|
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()
|
|
|
|
.withTimeout(5000);
|
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 () => {
|
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');
|
|
|
|
await waitFor(element(by[textMatcher]('30')).atIndex(1))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2021-12-02 13:19:15 +00:00
|
|
|
.withTimeout(30000);
|
|
|
|
await element(by[textMatcher]('30')).atIndex(1).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
|
|
|
// TODO: couldn't make it work on Android :(
|
|
|
|
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');
|
|
|
|
await expect(element(by[textMatcher]('Load Older'))).toBeVisible();
|
|
|
|
await expect(element(by[textMatcher]('5'))).toExist();
|
|
|
|
found = true;
|
|
|
|
} catch {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await element(by[textMatcher]('Load Older')).atIndex(0).tap();
|
|
|
|
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);
|
2022-08-19 21:14:37 +00:00
|
|
|
await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'slow', 0.4);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load Newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Load Newer')).atIndex(0).tap();
|
|
|
|
await waitFor(element(by[textMatcher]('104')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load Newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Load Newer')).atIndex(0).tap();
|
|
|
|
await waitFor(element(by[textMatcher]('154')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Load Newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Load Newer')).atIndex(0).tap();
|
|
|
|
await waitFor(element(by[textMatcher]('Load Newer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toNotExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('Load More'))).toNotExist();
|
|
|
|
await expect(element(by[textMatcher]('201'))).toExist();
|
|
|
|
await expect(element(by[textMatcher]('202'))).toExist();
|
2021-06-22 19:41:55 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const expectThreadMessages = async message => {
|
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()
|
|
|
|
.withTimeout(5000);
|
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', () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
before(async () => {
|
|
|
|
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 () => {
|
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);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]("Go to jumping-thread's thread")).atIndex(0).tap();
|
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 () => {
|
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 () => {
|
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);
|
|
|
|
await element(by[textMatcher]('quoted')).atIndex(0).tap();
|
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 () => {
|
|
|
|
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');
|
|
|
|
await waitFor(element(by[textMatcher]('to be searched')).atIndex(1))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
2021-12-02 13:19:15 +00:00
|
|
|
.withTimeout(30000);
|
|
|
|
await element(by[textMatcher]('to be searched')).atIndex(1).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
|
|
|
|
});
|