Rocket.Chat.ReactNative/e2e/tests/assorted/03-profile.spec.ts

119 lines
4.0 KiB
TypeScript
Raw Normal View History

2023-03-07 12:28:51 +00:00
import { device, waitFor, element, by, expect } from 'detox';
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';
const scrollDown = 200;
2020-03-03 20:27:38 +00:00
async function waitForToast() {
await sleep(600);
2020-03-03 20:27:38 +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');
}
describe('Profile screen', () => {
let textMatcher: TTextMatcher;
2023-03-07 12:28:51 +00:00
let user: ITestUser;
2023-03-07 12:28:51 +00:00
beforeAll(async () => {
user = await createRandomUser();
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
feat: Change Avatar View (#4746) * [NEW] Change Avatar View * change avatar view and avatar suggestion * avatar Url * change avatar for profile it's done, missing fix revalidate the avatar in profile and drawer * pick image * clean profile view * Finished the profile and fixed the avatar when change the user profile * fix the profile update through all the app * refactor avatar suggestion * fix the delete from rooms and finished RoomInfoView, missing RoomInfoEditView * room info edit view * ipad navigation * refactor the submit function * refactor the e2e test * minor tweak with themes and buttons * minor tweak in edit button * minor tweaks * tweak IAvatarContainer * fixing pt-br * removed the avatarETagUser and search by username and text * created the useHooke useAvatarETag * fix lint * refactor image.ts and test * refactor avatar component * fix the edit button * refactor useAvatarETag * fix the pt-br translation * minor tweak tests * back handleError to views and refactor the submit * avatar suggestion item * types for change avatar view context * fix avatar on header for tablets * minor tweak changeavatarview * refactor avatar url to use hook form * tweak on yup validation * minor tweak with handle error * minor tweak * minor tweak * interface avatar container * minor tweak * Refactor all the changeAvatarView and fix how to test the image url * fixed the layout * minor refactor * minor tweaks * fix the visual bug when the user change the avatar to new then clear cache * fix the flicker when upload an image * update package.json * test the reset, discard alert, cancel and discard * separate the avatar test from profile and create new tests for change avatar * mock imagepicker * minor tweak, adding console and add echo to config.yml * use RUNNING_E2E_TESTS as env to other files * exprt env at android build * change the to way to set the running e2e test env * update test * delete the .env and update the e2e/readme and the file review * minor tweak * minor tweak * update the test, fixing how to dismiss the keyboard --------- Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
2023-04-10 14:59:00 +00:00
({ textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
2023-03-07 12:28:51 +00:00
await login(user.username, user.password);
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 element(by.id('sidebar-profile')).tap();
await waitFor(element(by.id('profile-view')))
.toBeVisible()
.withTimeout(2000);
});
describe('Render', () => {
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();
});
feat: Change Avatar View (#4746) * [NEW] Change Avatar View * change avatar view and avatar suggestion * avatar Url * change avatar for profile it's done, missing fix revalidate the avatar in profile and drawer * pick image * clean profile view * Finished the profile and fixed the avatar when change the user profile * fix the profile update through all the app * refactor avatar suggestion * fix the delete from rooms and finished RoomInfoView, missing RoomInfoEditView * room info edit view * ipad navigation * refactor the submit function * refactor the e2e test * minor tweak with themes and buttons * minor tweak in edit button * minor tweaks * tweak IAvatarContainer * fixing pt-br * removed the avatarETagUser and search by username and text * created the useHooke useAvatarETag * fix lint * refactor image.ts and test * refactor avatar component * fix the edit button * refactor useAvatarETag * fix the pt-br translation * minor tweak tests * back handleError to views and refactor the submit * avatar suggestion item * types for change avatar view context * fix avatar on header for tablets * minor tweak changeavatarview * refactor avatar url to use hook form * tweak on yup validation * minor tweak with handle error * minor tweak * minor tweak * interface avatar container * minor tweak * Refactor all the changeAvatarView and fix how to test the image url * fixed the layout * minor refactor * minor tweaks * fix the visual bug when the user change the avatar to new then clear cache * fix the flicker when upload an image * update package.json * test the reset, discard alert, cancel and discard * separate the avatar test from profile and create new tests for change avatar * mock imagepicker * minor tweak, adding console and add echo to config.yml * use RUNNING_E2E_TESTS as env to other files * exprt env at android build * change the to way to set the running e2e test env * update test * delete the .env and update the e2e/readme and the file review * minor tweak * minor tweak * update the test, fixing how to dismiss the keyboard --------- Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
2023-04-10 14:59:00 +00:00
it('should have avatar edit button', async () => {
await expect(element(by.id('avatar-edit-button'))).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 submit button', async () => {
await waitFor(element(by.id('profile-view-submit')))
.toExist()
.whileElement(by.id('profile-view-list'))
.scroll(scrollDown, 'down');
});
});
describe('Usage', () => {
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`);
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();
await element(by.id('profile-view-submit')).tap();
2020-03-03 20:27:38 +00:00
await waitForToast();
});
it('should change email and password', async () => {
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`);
await dismissKeyboardAndScrollUp();
2023-03-07 12:28:51 +00:00
await element(by.id('profile-view-new-password')).replaceText(`${user.password}new`);
await waitFor(element(by.id('profile-view-submit')))
.toExist()
.withTimeout(2000);
await element(by.id('profile-view-submit')).tap();
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}`);
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();
});
});
});