2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
2022-09-12 14:51:33 +00:00
|
|
|
|
|
|
|
import { navigateToLogin, login, sleep, platformTypes, TTextMatcher } from '../../helpers/app';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
|
|
|
import random from '../../helpers/random';
|
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() {
|
2022-08-26 19:16:45 +00:00
|
|
|
await sleep(600);
|
2020-03-03 20:27:38 +00:00
|
|
|
}
|
|
|
|
|
2023-08-01 17:34:05 +00:00
|
|
|
async function dismissKeyboardAndScrollUp() {
|
|
|
|
await element(by.id('profile-view-list')).swipe('down');
|
|
|
|
await sleep(300);
|
|
|
|
await element(by.id('profile-view-list')).swipe('up');
|
|
|
|
}
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
describe('Profile screen', () => {
|
2022-09-12 14:51:33 +00:00
|
|
|
let textMatcher: TTextMatcher;
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
2021-12-02 13:19:15 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
2020-05-20 16:33:40 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2023-04-10 14:59:00 +00:00
|
|
|
({ textMatcher } = platformTypes[device.getPlatform()]);
|
2020-05-20 16:33:40 +00:00
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.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
|
|
|
});
|
|
|
|
|
2023-04-10 14:59:00 +00:00
|
|
|
it('should have avatar edit button', async () => {
|
|
|
|
await expect(element(by.id('avatar-edit-button'))).toExist();
|
|
|
|
});
|
|
|
|
|
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 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 () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('profile-view-name')).replaceText(`${user.username}new`);
|
|
|
|
await element(by.id('profile-view-username')).replaceText(`${user.username}new`);
|
2023-08-01 17:34:05 +00:00
|
|
|
await dismissKeyboardAndScrollUp();
|
|
|
|
await element(by.id('profile-view-submit')).tap();
|
|
|
|
await waitForToast();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should change nickname and bio', async () => {
|
|
|
|
await element(by.id('profile-view-nickname')).replaceText(`nickname-${user.username}`);
|
|
|
|
await element(by.id('profile-view-bio')).replaceText(`bio-${user.username}`);
|
|
|
|
await dismissKeyboardAndScrollUp();
|
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 () => {
|
2023-08-01 17:34:05 +00:00
|
|
|
await element(by.id('profile-view-list')).swipe('down');
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id('profile-view-email')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${random()}@rocket.chat`);
|
2023-08-01 17:34:05 +00:00
|
|
|
await dismissKeyboardAndScrollUp();
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('profile-view-new-password')).replaceText(`${user.password}new`);
|
2022-10-21 18:27:55 +00:00
|
|
|
await waitFor(element(by.id('profile-view-submit')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-06-13 01:33:00 +00:00
|
|
|
await element(by.id('profile-view-submit')).tap();
|
2022-07-06 13:23:02 +00:00
|
|
|
await waitFor(element(by.id('profile-view-enter-password-sheet')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('profile-view-enter-password-sheet')).replaceText(`${user.password}`);
|
2022-07-06 13:23:02 +00:00
|
|
|
await element(by[textMatcher]('Save').withAncestor(by.id('action-sheet-content-with-input-and-submit')))
|
|
|
|
.atIndex(0)
|
|
|
|
.tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-06-13 01:33:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|