2018-06-13 01:33:00 +00:00
|
|
|
const {
|
|
|
|
device, expect, element, by, waitFor
|
|
|
|
} = require('detox');
|
2020-03-03 20:27:38 +00:00
|
|
|
const { logout, navigateToLogin, login, sleep } = require('./helpers/app');
|
2018-06-13 01:33:00 +00:00
|
|
|
const data = require('./data');
|
|
|
|
|
|
|
|
const scrollDown = 200;
|
|
|
|
|
2020-03-03 20:27:38 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
describe('Profile screen', () => {
|
|
|
|
before(async() => {
|
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2019-01-31 16:08:38 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
2018-06-13 01:33:00 +00:00
|
|
|
await waitFor(element(by.id('sidebar-profile'))).toBeVisible().withTimeout(2000);
|
2018-07-10 13:40:32 +00:00
|
|
|
// await expect(element(by.id('sidebar-profile'))).toBeVisible();
|
2018-06-13 01:33:00 +00:00
|
|
|
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() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('profile-view-avatar')).atIndex(0)).toExist();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2020-03-30 20:19:01 +00:00
|
|
|
it('should have custom status', async() => {
|
|
|
|
await expect(element(by.id('profile-view-custom-status'))).toExist();
|
|
|
|
});
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
it('should have name', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('profile-view-name'))).toExist();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have username', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('profile-view-username'))).toExist();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have email', async() => {
|
|
|
|
await expect(element(by.id('profile-view-email'))).toExist();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have new password', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('profile-view-new-password'))).toExist();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have avatar url', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('profile-view-avatar-url'))).toExist();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have reset avatar button', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
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();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have upload avatar button', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
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();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have avatar url button', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
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();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have submit button', async() => {
|
2018-11-14 21:42:03 +00:00
|
|
|
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();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Usage', async() => {
|
2020-03-30 20:19:01 +00:00
|
|
|
it('should change custom status', async() => {
|
|
|
|
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
|
|
|
|
await element(by.id('profile-view-custom-status')).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();
|
|
|
|
});
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
it('should change name and username', async() => {
|
2020-03-03 20:27:38 +00:00
|
|
|
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-name')).replaceText(`${ data.user }new`);
|
|
|
|
await element(by.id('profile-view-username')).replaceText(`${ data.user }new`);
|
2020-03-03 20:27:38 +00:00
|
|
|
await sleep(1000);
|
|
|
|
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
|
|
|
|
await sleep(1000);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-submit')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should change email and password', async() => {
|
2018-08-10 17:26:36 +00:00
|
|
|
await element(by.id('profile-view-email')).replaceText(`diego.mello+e2e${ data.random }test@rocket.chat`);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-new-password')).replaceText(`${ data.password }new`);
|
|
|
|
await element(by.id('profile-view-submit')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
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();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should reset avatar', async() => {
|
2020-03-03 20:27:38 +00:00
|
|
|
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
|
|
|
|
await sleep(1000);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-reset-avatar')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|