2021-12-02 13:19:15 +00:00
|
|
|
const { navigateToRegister, platformTypes } = require('../../helpers/app');
|
2020-05-20 16:33:40 +00:00
|
|
|
const data = require('../../data');
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
describe('Create user screen', () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
let alertButtonType;
|
|
|
|
let textMatcher;
|
2021-09-13 20:41:05 +00:00
|
|
|
before(async () => {
|
2021-06-11 18:23:43 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
2018-11-14 21:42:03 +00:00
|
|
|
await navigateToRegister();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Render', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have create user screen', async () => {
|
2022-08-08 21:02:08 +00:00
|
|
|
await waitFor(element(by.id('register-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-11-14 21:42:03 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have name input', async () => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view-name'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have email input', async () => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view-email'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have password input', async () => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view-password'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have submit button', async () => {
|
2022-05-26 17:10:24 +00:00
|
|
|
await element(by.id('register-view')).atIndex(0).swipe('up', 'fast', 0.5);
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view-submit'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have legal button', async () => {
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view-more'))).toBeVisible();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Usage', () => {
|
2018-12-05 20:52:08 +00:00
|
|
|
// FIXME: Detox isn't able to check if it's tappable: https://github.com/wix/Detox/issues/246
|
2020-03-03 20:27:38 +00:00
|
|
|
// it('should submit invalid email and do nothing', async() => {
|
2018-12-05 20:52:08 +00:00
|
|
|
// const invalidEmail = 'invalidemail';
|
|
|
|
// await element(by.id('register-view-name')).replaceText(data.user);
|
|
|
|
// await element(by.id('register-view-username')).replaceText(data.user);
|
|
|
|
// await element(by.id('register-view-email')).replaceText(invalidEmail);
|
|
|
|
// await element(by.id('register-view-password')).replaceText(data.password);
|
|
|
|
// await element(by.id('register-view-submit')).tap();
|
|
|
|
// });
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should submit email already taken and raise error', async () => {
|
2020-07-15 16:28:34 +00:00
|
|
|
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
|
|
|
|
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
|
|
|
|
await element(by.id('register-view-email')).replaceText(data.users.existing.email);
|
|
|
|
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
|
2018-11-14 21:42:03 +00:00
|
|
|
await element(by.id('register-view-submit')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Email already exists. [403]')).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('OK').and(by.type(alertButtonType))).tap();
|
2018-11-14 21:42:03 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should submit username already taken and raise error', async () => {
|
2020-07-15 16:28:34 +00:00
|
|
|
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
|
|
|
|
await element(by.id('register-view-username')).replaceText(data.users.existing.username);
|
|
|
|
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
|
|
|
|
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
|
2018-11-14 21:42:03 +00:00
|
|
|
await element(by.id('register-view-submit')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Username is already in use')).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('OK').and(by.type(alertButtonType))).tap();
|
2018-11-14 21:42:03 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should register', async () => {
|
2020-07-15 16:28:34 +00:00
|
|
|
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
|
|
|
|
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
|
|
|
|
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
|
|
|
|
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
|
2018-11-14 21:42:03 +00:00
|
|
|
await element(by.id('register-view-submit')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(60000);
|
2018-11-14 21:42:03 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|