verdnatura-chat/e2e/04-createuser.spec.js

104 lines
4.3 KiB
JavaScript
Raw Normal View History

const {
device, expect, element, by, waitFor
} = require('detox');
const { logout, sleep } = require('./helpers/app');
const data = require('./data');
async function navigateToRegister() {
2020-05-14 15:55:03 +00:00
await device.launchApp({ newInstance: true });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
2020-05-14 15:55:03 +00:00
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).replaceText(data.server);
await element(by.id('new-server-view-button')).tap();
2020-05-14 15:55:03 +00:00
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('workspace-view'))).toBeVisible();
await element(by.id('workspace-view-register')).tap();
}
2020-05-14 16:01:13 +00:00
describe.skip('Create user screen', () => {
before(async() => {
2020-03-03 20:27:38 +00:00
await device.launchApp({ newInstance: true });
await navigateToRegister();
});
describe('Render', () => {
it('should have create user screen', async() => {
await expect(element(by.id('register-view'))).toBeVisible();
});
it('should have name input', async() => {
await expect(element(by.id('register-view-name'))).toBeVisible();
});
it('should have email input', async() => {
await expect(element(by.id('register-view-email'))).toBeVisible();
});
it('should have password input', async() => {
await expect(element(by.id('register-view-password'))).toBeVisible();
});
it('should have submit button', async() => {
await expect(element(by.id('register-view-submit'))).toBeVisible();
});
it('should have legal button', async() => {
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();
// });
it('should submit email already taken and raise error', async() => {
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(data.existingEmail);
await element(by.id('register-view-password')).replaceText(data.password);
2020-03-03 20:27:38 +00:00
await sleep(300);
await element(by.id('register-view-submit')).tap();
2018-12-05 20:52:08 +00:00
await waitFor(element(by.text('Email already exists. [403]')).atIndex(0)).toExist().withTimeout(10000);
await expect(element(by.text('Email already exists. [403]')).atIndex(0)).toExist();
await element(by.text('OK')).tap();
});
2020-03-03 20:27:38 +00:00
it('should submit username already taken and raise error', async() => {
const invalidEmail = 'invalidemail';
await element(by.id('register-view-name')).replaceText(data.user);
await element(by.id('register-view-username')).replaceText(data.existingName);
2018-12-05 20:52:08 +00:00
await element(by.id('register-view-email')).replaceText(data.email);
await element(by.id('register-view-password')).replaceText(data.password);
2020-03-03 20:27:38 +00:00
await sleep(300);
await element(by.id('register-view-submit')).tap();
2018-12-05 20:52:08 +00:00
await waitFor(element(by.text('Username is already in use')).atIndex(0)).toExist().withTimeout(10000);
await expect(element(by.text('Username is already in use')).atIndex(0)).toExist();
await element(by.text('OK')).tap();
});
it('should register', async() => {
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(data.email);
await element(by.id('register-view-password')).replaceText(data.password);
2020-03-03 20:27:38 +00:00
await sleep(300);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
});
2020-05-14 15:55:03 +00:00
// afterAll(async() => {
// await logout();
// });
});
});