Onboarding tests passing

This commit is contained in:
Diego Mello 2020-05-20 11:34:31 -03:00
parent 0152f16053
commit 470145e75c
14 changed files with 21 additions and 450 deletions

View File

@ -55,6 +55,7 @@ const Header = React.memo(({
placeholder='Search'
onChangeText={onSearchChangeText}
theme={theme}
testID='rooms-list-view-search-input'
/>
</View>
);

View File

@ -12,7 +12,7 @@ const SearchBar = React.memo(({
return (
<SearchBox
onChangeText={onChangeSearchText}
testID='rooms-list-view-search'
testID='rooms-list-view-search-input'
inputRef={inputRef}
theme={theme}
hasCancel={searching}

View File

@ -132,6 +132,7 @@ class RoomsListView extends React.Component {
title='search'
iconName='magnifier'
onPress={initSearching}
testID='rooms-list-view-search-button'
/>
) : null}
<Item

View File

@ -42,7 +42,11 @@ async function logout() {
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
await element(by.id('sidebar-settings')).tap();
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
await element(by.type('UIScrollView')).atIndex(1).scrollTo('bottom');
if (device.getPlatform() === 'ios') {
await element(by.type('UIScrollView')).atIndex(1).scrollTo('bottom');
} else {
await element(by.id('settings-view-list')).scrollTo('bottom');
}
await element(by.id('settings-logout')).tap();
const logoutAlertMessage = 'You will be logged out of this application.';
await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000);

View File

@ -1,59 +0,0 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../data');
const { sleep, logout } = require('../helpers/app');
describe('Change server', () => {
before(async() => {
await device.launchApp({ newInstance: true });
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
});
it('should add server and create new user', async() => {
await sleep(5000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await expect(element(by.id('rooms-list-header-server-dropdown'))).toExist();
await sleep(1000);
await element(by.id('rooms-list-header-server-add')).tap();
// TODO: refactor
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).replaceText(data.alternateServer);
await element(by.id('new-server-view-button')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('workspace-view'))).toBeVisible();
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('register-view'))).toBeVisible();
// Register new user
await element(by.id('register-view-name')).replaceText(data.user);
await element(by.id('register-view-username')).replaceText(data.user);
await element(by.id('register-view-email')).replaceText(data.email);
await element(by.id('register-view-password')).replaceText(data.password);
await sleep(1000);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
// For a sanity test, to make sure roomslist is showing correct rooms
// app CANNOT show public room created on previous tests
await waitFor(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeNotVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeNotVisible();
});
it('should change server', async() => {
await sleep(5000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await expect(element(by.id('rooms-list-header-server-dropdown'))).toExist();
await sleep(1000);
await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
// For a sanity test, to make sure roomslist is showing correct rooms
// app MUST show public room created on previous tests
await waitFor(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeVisible();
});
});

View File

@ -1,109 +0,0 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { logout, navigateToLogin, login, sleep } = require('../helpers/app');
const data = require('../data');
const scrollDown = 200;
async function waitForToast() {
// await waitFor(element(by.id('toast'))).toBeVisible().withTimeout(10000);
// await expect(element(by.id('toast'))).toBeVisible();
// await waitFor(element(by.id('toast'))).toBeNotVisible().withTimeout(10000);
// await expect(element(by.id('toast'))).toBeNotVisible();
await sleep(5000);
}
describe('Profile screen', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login();
await element(by.id('rooms-list-view-sidebar')).tap();
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.id('sidebar-profile'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('sidebar-profile'))).toBeVisible();
await element(by.id('sidebar-profile')).tap();
await waitFor(element(by.id('profile-view'))).toBeVisible().withTimeout(2000);
});
describe('Render', async() => {
it('should have profile view', async() => {
await expect(element(by.id('profile-view'))).toBeVisible();
});
it('should have avatar', async() => {
await expect(element(by.id('profile-view-avatar')).atIndex(0)).toExist();
});
it('should have name', async() => {
await expect(element(by.id('profile-view-name'))).toExist();
});
it('should have username', async() => {
await expect(element(by.id('profile-view-username'))).toExist();
});
it('should have email', async() => {
await expect(element(by.id('profile-view-email'))).toExist();
});
it('should have new password', async() => {
await expect(element(by.id('profile-view-new-password'))).toExist();
});
it('should have avatar url', async() => {
await expect(element(by.id('profile-view-avatar-url'))).toExist();
});
it('should have reset avatar button', async() => {
await waitFor(element(by.id('profile-view-reset-avatar'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
await expect(element(by.id('profile-view-reset-avatar'))).toExist();
});
it('should have upload avatar button', async() => {
await waitFor(element(by.id('profile-view-upload-avatar'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
await expect(element(by.id('profile-view-upload-avatar'))).toExist();
});
it('should have avatar url button', async() => {
await waitFor(element(by.id('profile-view-avatar-url-button'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
await expect(element(by.id('profile-view-avatar-url-button'))).toExist();
});
it('should have submit button', async() => {
await waitFor(element(by.id('profile-view-submit'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
await expect(element(by.id('profile-view-submit'))).toExist();
});
});
describe('Usage', async() => {
it('should change name and username', async() => {
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
await element(by.id('profile-view-name')).replaceText(`${ data.user }new`);
await element(by.id('profile-view-username')).replaceText(`${ data.user }new`);
await sleep(1000);
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
await sleep(1000);
await element(by.id('profile-view-submit')).tap();
await waitForToast();
});
it('should change email and password', async() => {
await element(by.id('profile-view-email')).replaceText(`diego.mello+e2e${ data.random }test@rocket.chat`);
await element(by.id('profile-view-new-password')).replaceText(`${ data.password }new`);
await element(by.id('profile-view-submit')).tap();
await element(by.type('_UIAlertControllerTextField')).replaceText(`${ data.password }`)
// For some reason, replaceText does some type of submit, which submits the alert for us
// await element(by.label('Save').and(by.type('_UIAlertControllerActionView'))).tap();
await waitForToast();
});
it('should reset avatar', async() => {
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
await sleep(1000);
await element(by.id('profile-view-reset-avatar')).tap();
await waitForToast();
});
});
});

View File

@ -1,82 +0,0 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { logout, navigateToLogin, login } = require('../helpers/app');
describe('Settings screen', () => {
before(async() => {
await device.launchApp({ newInstance: true });
await expect(element(by.id('rooms-list-view'))).toBeVisible();
await element(by.id('rooms-list-view-sidebar')).tap();
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
await element(by.id('sidebar-settings')).tap();
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
});
describe('Render', async() => {
it('should have settings view', async() => {
await expect(element(by.id('settings-view'))).toBeVisible();
});
it('should have language', async() => {
await expect(element(by.id('settings-view-language'))).toExist();
});
it('should have theme', async() => {
await expect(element(by.id('settings-view-theme'))).toExist();
});
it('should have share app', async() => {
await expect(element(by.id('settings-view-share-app'))).toExist();
});
it('should have licence', async() => {
await expect(element(by.id('settings-view-license'))).toExist();
});
it('should have version no', async() => {
await expect(element(by.id('settings-view-version'))).toExist();
});
it('should have server version', async() => {
await expect(element(by.id('settings-view-server-version'))).toExist();
});
});
describe('Language', async() => {
it('should navigate to language view', async() => {
await element(by.id('settings-view-language')).tap();
await waitFor(element(by.id('language-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('language-view-zh-CN'))).toExist();
await expect(element(by.id('language-view-de'))).toExist();
await expect(element(by.id('language-view-en'))).toExist();
await expect(element(by.id('language-view-fr'))).toExist();
await expect(element(by.id('language-view-pt-BR'))).toExist();
await expect(element(by.id('language-view-pt-PT'))).toExist();
await expect(element(by.id('language-view-ru'))).toExist();
});
// it('should navigate to change language', async() => {
// await expect(element(by.id('language-view-zh-CN'))).toExist();
// await element(by.id('language-view-zh-CN')).tap()
// await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
// await expect(element(by.id('rooms-list-view'))).toBeVisible();
// await element(by.id('rooms-list-view-sidebar')).tap();
// await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
// await waitFor(element(by.text('设置'))).toBeVisible().withTimeout(2000);
// await element(by.text('设置')).tap();
// await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
// await element(by.id('settings-view-language')).tap();
// await element(by.id('language-view-en')).tap();
// await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
// await expect(element(by.id('rooms-list-view'))).toBeVisible();
// await element(by.id('rooms-list-view-sidebar')).tap();
// await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
// await expect(element(by.text('Settings'))).toBeVisible();
// await element(by.text('Settings')).tap();
// await expect(element(by.id('settings-view'))).toBeVisible();
// });
});
});

View File

@ -1,187 +0,0 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../data');
const { tapBack, sleep } = require('../helpers/app');
const room = 'detox-public';
async function mockMessage(message) {
await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText(`${ data.random }${ message }`);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.label(`${ data.random }${ message }`)).atIndex(0)).toExist().withTimeout(60000);
await sleep(1000);
};
async function navigateToRoom() {
await sleep(2000);
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await element(by.id('rooms-list-view-search')).typeText(room);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toBeVisible().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
}
async function navigateToRoomActions() {
await sleep(2000);
await element(by.id('room-view-header-actions')).tap();
await sleep(2000);
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
}
describe('Join public room', () => {
before(async() => {
await device.launchApp({ newInstance: true });
await navigateToRoom();
});
describe('Render', async() => {
it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toBeVisible();
});
// it('should have messages list', async() => {
// await expect(element(by.id('room-view-messages'))).toBeVisible();
// });
// Render - Header
describe('Header', async() => {
it('should have actions button ', async() => {
await expect(element(by.id('room-view-header-actions'))).toBeVisible();
});
});
// Render - Join
describe('Join', async() => {
it('should have join', async() => {
await expect(element(by.id('room-view-join'))).toBeVisible();
});
it('should have join text', async() => {
await expect(element(by.label('You are in preview mode'))).toBeVisible();
});
it('should have join button', async() => {
await expect(element(by.id('room-view-join-button'))).toBeVisible();
});
it('should not have messagebox', async() => {
await expect(element(by.id('messagebox'))).toBeNotVisible();
});
});
describe('Room Actions', async() => {
before(async() => {
await navigateToRoomActions('c');
});
it('should have room actions screen', async() => {
await expect(element(by.id('room-actions-view'))).toBeVisible();
});
it('should have info', async() => {
await expect(element(by.id('room-actions-info'))).toBeVisible();
});
// it('should have voice', async() => {
// await expect(element(by.id('room-actions-voice'))).toBeVisible();
// });
// it('should have video', async() => {
// await expect(element(by.id('room-actions-video'))).toBeVisible();
// });
it('should have members', async() => {
await expect(element(by.id('room-actions-members'))).toBeVisible();
});
it('should have files', async() => {
await expect(element(by.id('room-actions-files'))).toBeVisible();
});
it('should have mentions', async() => {
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
});
it('should have starred', async() => {
await expect(element(by.id('room-actions-starred'))).toBeVisible();
});
it('should have search', async() => {
await expect(element(by.id('room-actions-search'))).toBeVisible();
});
it('should have share', async() => {
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
await expect(element(by.id('room-actions-share'))).toBeVisible();
});
it('should have pinned', async() => {
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
});
it('should not have notifications', async() => {
await expect(element(by.id('room-actions-notifications'))).toBeNotVisible();
});
it('should not have leave channel', async() => {
await expect(element(by.id('room-actions-leave-channel'))).toBeNotVisible();
});
after(async() => {
await tapBack();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(2000);
})
});
});
describe('Usage', async() => {
it('should join room', async() => {
await element(by.id('room-view-join-button')).tap();
await tapBack();
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
await waitFor(element(by.id('messagebox'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('messagebox'))).toBeVisible();
await expect(element(by.id('room-view-join'))).toBeNotVisible();
});
it('should send message', async() => {
await mockMessage('message');
await expect(element(by.label(`${ data.random }message`)).atIndex(0)).toExist();
await element(by.label(`${ data.random }message`)).atIndex(0).tap();
});
it('should have disable notifications and leave channel', async() => {
await navigateToRoomActions('c');
await expect(element(by.id('room-actions-view'))).toBeVisible();
await expect(element(by.id('room-actions-info'))).toBeVisible();
// await expect(element(by.id('room-actions-voice'))).toBeVisible();
// await expect(element(by.id('room-actions-video'))).toBeVisible();
await expect(element(by.id('room-actions-members'))).toBeVisible();
await expect(element(by.id('room-actions-files'))).toBeVisible();
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
await expect(element(by.id('room-actions-starred'))).toBeVisible();
await expect(element(by.id('room-actions-search'))).toBeVisible();
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
await expect(element(by.id('room-actions-share'))).toBeVisible();
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
await expect(element(by.id('room-actions-notifications'))).toBeVisible();
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
});
it('should leave room', async() => {
await element(by.id('room-actions-leave-channel')).tap();
await waitFor(element(by.text('Yes, leave it!'))).toBeVisible().withTimeout(5000);
await expect(element(by.text('Yes, leave it!'))).toBeVisible();
await element(by.text('Yes, leave it!')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
// await element(by.id('rooms-list-view-search')).typeText('');
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible();
});
});
});

View File

@ -72,7 +72,7 @@ describe('Broadcast room', () => {
await element(by.id('two-factor-send')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await element(by.id('rooms-list-view-search')).typeText(`broadcast${ data.random }`);
await element(by.id('rooms-list-view-search-input')).typeText(`broadcast${ data.random }`);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-broadcast${ data.random }`))).toExist().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-broadcast${ data.random }`))).toExist();

View File

@ -17,7 +17,7 @@ async function mockMessage(message) {
async function navigateToRoom() {
await sleep(2000);
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await element(by.id('rooms-list-view-search')).typeText(room);
await element(by.id('rooms-list-view-search-input')).typeText(room);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toBeVisible().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
@ -178,7 +178,6 @@ describe('Join public room', () => {
await expect(element(by.text('Yes, leave it!'))).toBeVisible();
await element(by.text('Yes, leave it!')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
// await element(by.id('rooms-list-view-search')).typeText('');
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible();

View File

@ -27,9 +27,14 @@ describe('Rooms list screen', () => {
describe('Usage', () => {
it('should search room and navigate', async() => {
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await waitFor(element(by.id('rooms-list-view-search'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-search')).typeText('rocket.cat');
if (device.getPlatform() === 'ios') {
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
} else {
await waitFor(element(by.id('rooms-list-view-search-button'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-search-button')).tap();
}
await waitFor(element(by.id('rooms-list-view-search-input'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-search-input')).typeText('rocket.cat');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible();
@ -41,7 +46,6 @@ describe('Rooms list screen', () => {
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
// await element(by.id('rooms-list-view-search')).typeText('');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toExist().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toExist();

View File

@ -14,7 +14,7 @@ async function mockMessage(message) {
async function navigateToRoom() {
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await element(by.id('rooms-list-view-search')).typeText(`private${ data.random }`);
await element(by.id('rooms-list-view-search-input')).typeText(`private${ data.random }`);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-private${ data.random }`))).toBeVisible().withTimeout(60000);
await element(by.id(`rooms-list-view-item-private${ data.random }`)).tap();

View File

@ -15,7 +15,7 @@ async function navigateToRoomActions(type) {
}
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await element(by.type('UIScrollView')).atIndex(1).scrollTo('top');
await element(by.id('rooms-list-view-search')).typeText(room);
await element(by.id('rooms-list-view-search-input')).typeText(room);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ room }`)).tap();

View File

@ -13,7 +13,7 @@ async function navigateToRoomInfo(type) {
}
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
await element(by.id('rooms-list-view-search')).typeText(room);
await element(by.id('rooms-list-view-search-input')).typeText(room);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
@ -311,7 +311,6 @@ describe('Room info screen', () => {
await expect(element(by.text('Yes, delete it!'))).toBeVisible();
await element(by.text('Yes, delete it!')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
// await element(by.id('rooms-list-view-search')).typeText('');
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible();