Rocket.Chat.ReactNative/e2e/tests/onboarding/03-forgotpassword.spec.ts

49 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-03-07 12:28:51 +00:00
import { device, waitFor, element, by, expect } from 'detox';
import { navigateToLogin, platformTypes, TTextMatcher } from '../../helpers/app';
2023-03-07 12:28:51 +00:00
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
2018-05-23 13:39:18 +00:00
describe('Forgot password screen', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
2023-03-07 12:28:51 +00:00
let user: ITestUser;
beforeAll(async () => {
user = await createRandomUser();
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
2018-05-23 13:39:18 +00:00
await element(by.id('login-view-forgot-password')).tap();
await waitFor(element(by.id('forgot-password-view')))
.toExist()
.withTimeout(2000);
2018-05-23 13:39:18 +00:00
});
describe('Render', () => {
it('should have forgot password screen', async () => {
await expect(element(by.id('forgot-password-view'))).toExist();
2018-05-23 13:39:18 +00:00
});
it('should have email input', async () => {
2018-05-23 13:39:18 +00:00
await expect(element(by.id('forgot-password-view-email'))).toBeVisible();
});
it('should have submit button', async () => {
2018-05-23 13:39:18 +00:00
await expect(element(by.id('forgot-password-view-submit'))).toBeVisible();
});
});
describe('Usage', () => {
it('should reset password and navigate to login', async () => {
2023-03-07 12:28:51 +00:00
await element(by.id('forgot-password-view-email')).replaceText(user.email);
2018-05-23 13:39:18 +00:00
await element(by.id('forgot-password-view-submit')).tap();
await waitFor(element(by[textMatcher]('OK')))
.toExist()
.withTimeout(10000);
await element(by[textMatcher]('OK').and(by.type(alertButtonType))).tap();
await waitFor(element(by.id('login-view')))
.toBeVisible()
.withTimeout(60000);
2018-05-23 13:39:18 +00:00
});
});
});