2021-12-02 13:19:15 +00:00
|
|
|
const { navigateToLogin, login, sleep, platformTypes } = require('../../helpers/app');
|
2020-05-20 16:33:40 +00:00
|
|
|
const data = require('../../data');
|
2018-06-13 01:33:00 +00:00
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
const profileChangeUser = data.users.profileChanges;
|
2020-07-15 16:28:34 +00:00
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
const scrollDown = 200;
|
|
|
|
|
2020-03-03 20:27:38 +00:00
|
|
|
async function waitForToast() {
|
2021-04-19 14:31:43 +00:00
|
|
|
// await waitFor(element(by.id('toast'))).toBeVisible().withTimeout(1000);
|
2020-03-03 20:27:38 +00:00
|
|
|
// await expect(element(by.id('toast'))).toBeVisible();
|
2021-04-19 14:31:43 +00:00
|
|
|
// await waitFor(element(by.id('toast'))).not.toBeNotVisible().withTimeout(1000);
|
|
|
|
// await expect(element(by.id('toast'))).not.toBeVisible();
|
2020-09-11 14:31:38 +00:00
|
|
|
await sleep(300);
|
2020-03-03 20:27:38 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
describe('Profile screen', () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
let textInputType;
|
|
|
|
let scrollViewType;
|
|
|
|
let alertButtonType;
|
|
|
|
let textMatcher;
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
before(async () => {
|
2020-05-20 16:33:40 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ textInputType, scrollViewType, alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
2020-05-20 16:33:40 +00:00
|
|
|
await navigateToLogin();
|
2020-07-15 16:28:34 +00:00
|
|
|
await login(profileChangeUser.username, profileChangeUser.password);
|
2018-06-13 01:33:00 +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);
|
|
|
|
await waitFor(element(by.id('sidebar-profile')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('sidebar-profile')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('profile-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Render', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have profile view', async () => {
|
2018-06-13 01:33:00 +00:00
|
|
|
await expect(element(by.id('profile-view'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +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
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +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
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have email', async () => {
|
2018-06-13 01:33:00 +00:00
|
|
|
await expect(element(by.id('profile-view-email'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +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
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
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');
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
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');
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
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');
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have submit button', async () => {
|
|
|
|
await waitFor(element(by.id('profile-view-submit')))
|
|
|
|
.toExist()
|
|
|
|
.whileElement(by.id('profile-view-list'))
|
|
|
|
.scroll(scrollDown, 'down');
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should change name and username', async () => {
|
|
|
|
await element(by.id('profile-view-name')).replaceText(`${profileChangeUser.username}new`);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('profile-view-username')).replaceText(`${profileChangeUser.username}new`);
|
|
|
|
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
|
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
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should change email and password', async () => {
|
|
|
|
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${data.random}@rocket.chat`);
|
|
|
|
await element(by.id('profile-view-new-password')).replaceText(`${profileChangeUser.password}new`);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-submit')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.type(textInputType)).replaceText(`${profileChangeUser.password}`);
|
|
|
|
await element(by[textMatcher]('Save').and(by.type(alertButtonType))).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should reset avatar', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|