From 7fe1499dfb082045c5d7e3e76363a13e9d8e3618 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Fri, 10 Feb 2017 18:18:17 -0200 Subject: [#922] Adds integration test for translations with @tayanefernandes --- web-ui/test/integration/i18n.js | 14 ++++++++++++++ web-ui/test/integration/setup.js | 15 +++++++++++++++ web-ui/test/integration/translations.spec.js | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 web-ui/test/integration/i18n.js create mode 100644 web-ui/test/integration/setup.js create mode 100644 web-ui/test/integration/translations.spec.js (limited to 'web-ui/test/integration') diff --git a/web-ui/test/integration/i18n.js b/web-ui/test/integration/i18n.js new file mode 100644 index 00000000..099df2d7 --- /dev/null +++ b/web-ui/test/integration/i18n.js @@ -0,0 +1,14 @@ +import i18n from 'i18next'; +import translations from '../../app/locales/en_US/translation.json'; + +i18n + .init({ + lng: 'en', + resources: { + en: { + translation: translations + } + } + }); + +export default i18n; diff --git a/web-ui/test/integration/setup.js b/web-ui/test/integration/setup.js new file mode 100644 index 00000000..49cd381e --- /dev/null +++ b/web-ui/test/integration/setup.js @@ -0,0 +1,15 @@ +// Enzyme setup file +// https://github.com/airbnb/enzyme/blob/master/docs/guides/jsdom.md +var jsdom = require('jsdom').jsdom; + +global.document = jsdom(''); +global.window = document.defaultView; +Object.keys(document.defaultView).forEach((property) => { + if (typeof global[property] === 'undefined') { + global[property] = document.defaultView[property]; + } +}); + +global.navigator = { + userAgent: 'node.js' +}; diff --git a/web-ui/test/integration/translations.spec.js b/web-ui/test/integration/translations.spec.js new file mode 100644 index 00000000..1173695d --- /dev/null +++ b/web-ui/test/integration/translations.spec.js @@ -0,0 +1,21 @@ +import { mount } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import App from 'src/backup_account/app'; +import testI18n from './i18n' + +describe('App', () => { + let app; + + beforeEach(() => { + app = mount(); + }); + + it('renders translated header logout text', () => { + expect(app.find('header').text()).toContain('Logout'); + }); + + it('renders translated footer text', () => { + expect(app.find('footer').text()).toContain('Product in development. Feedback and issues to team@pixelated-project.org'); + }); +}); -- cgit v1.2.3 From 1997c401a5e67b76663d3996ec085eb6782c34e9 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Thu, 23 Feb 2017 11:34:14 -0300 Subject: [#907] Adds integration test for translations For this test, we refactored the way translations were done for backup account and login, concentrating them in the common/app.js component. with @thaissiqueira --- web-ui/test/integration/translations.spec.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'web-ui/test/integration') diff --git a/web-ui/test/integration/translations.spec.js b/web-ui/test/integration/translations.spec.js index 1173695d..fe17838b 100644 --- a/web-ui/test/integration/translations.spec.js +++ b/web-ui/test/integration/translations.spec.js @@ -1,21 +1,23 @@ import { mount } from 'enzyme'; import expect from 'expect'; import React from 'react'; -import App from 'src/backup_account/app'; -import testI18n from './i18n' +import App from 'src/common/app'; +import BackupAccountPage from 'src/backup_account/page'; +import LoginPage from 'src/login/page'; +import testI18n from './i18n'; -describe('App', () => { - let app; - - beforeEach(() => { - app = mount(); - }); - - it('renders translated header logout text', () => { - expect(app.find('header').text()).toContain('Logout'); +describe('Translations', () => { + context('Backup Account Page', () => { + it('translates all key', () => { + const app = mount(} />); + expect(app.text()).toNotContain('untranslated', 'Unstranslated message found in the text: ' + app.text()); + }); }); - it('renders translated footer text', () => { - expect(app.find('footer').text()).toContain('Product in development. Feedback and issues to team@pixelated-project.org'); + context('Login Page', () => { + it('translates all key', () => { + const app = mount(} />); + expect(app.text()).toNotContain('untranslated', 'Unstranslated message found in the text: ' + app.text()); + }); }); }); -- cgit v1.2.3 From 8b42d7b769807031e808e5212cd5c50097db333b Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Fri, 10 Mar 2017 15:35:24 -0300 Subject: [#923] Create integration test for the validation of backup account with @FrailWords --- web-ui/test/integration/backup_account.spec.js | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 web-ui/test/integration/backup_account.spec.js (limited to 'web-ui/test/integration') diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js new file mode 100644 index 00000000..2a37442e --- /dev/null +++ b/web-ui/test/integration/backup_account.spec.js @@ -0,0 +1,35 @@ +import { mount } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import App from 'src/common/app'; +import BackupAccountPage from 'src/backup_account/page'; +import testI18n from './i18n'; + +describe('Backup account email validation', () => { + context('Backup Account Page', () => { + let app, backupAccountPage; + + beforeEach(() => { + app = mount(} />); + backupAccountPage = app.find('Page'); + }); + + it('shows no error and enables submit button when a valid email is entered', () => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test@test.com'}}); + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(false); + }); + + it('shows error and disables submit button on invalid email', () => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test'}}); + expect(backupAccountPage.find('InputField').props().errorText).toEqual('Your email is invalid'); + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); + + it('shows no error and disables submit button when email is empty', () => { + backupAccountPage.find('input').simulate('change', {target: {value: ''}}); + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); + }); +}); -- cgit v1.2.3 From 3c1cf6548939d164c4296eeaf637ec4a9901b0f4 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Fri, 10 Mar 2017 16:11:07 -0300 Subject: [#923] Add translation for the validation error @FrailWords --- web-ui/test/integration/backup_account.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web-ui/test/integration') diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js index 2a37442e..eb247653 100644 --- a/web-ui/test/integration/backup_account.spec.js +++ b/web-ui/test/integration/backup_account.spec.js @@ -22,7 +22,7 @@ describe('Backup account email validation', () => { it('shows error and disables submit button on invalid email', () => { backupAccountPage.find('input').simulate('change', {target: {value: 'test'}}); - expect(backupAccountPage.find('InputField').props().errorText).toEqual('Your email is invalid'); + expect(backupAccountPage.find('InputField').props().errorText).toEqual('Please enter a valid email address'); expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); }); -- cgit v1.2.3 From def51d0d4265e9a489d05ca8cb4bec6abb26073f Mon Sep 17 00:00:00 2001 From: Sriram Viswanathan Date: Fri, 10 Mar 2017 17:36:24 -0300 Subject: [#923] Separate out asserts into different tests with @tayanefernandes --- web-ui/test/integration/backup_account.spec.js | 48 +++++++++++++++++++------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'web-ui/test/integration') diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js index eb247653..b44c3b2c 100644 --- a/web-ui/test/integration/backup_account.spec.js +++ b/web-ui/test/integration/backup_account.spec.js @@ -14,22 +14,46 @@ describe('Backup account email validation', () => { backupAccountPage = app.find('Page'); }); - it('shows no error and enables submit button when a valid email is entered', () => { - backupAccountPage.find('input').simulate('change', {target: {value: 'test@test.com'}}); - expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); - expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(false); + context('with valid email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test@test.com'}}); + }); + + it('shows no validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + }); + + it('submit button is enabled', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(false); + }); }); - it('shows error and disables submit button on invalid email', () => { - backupAccountPage.find('input').simulate('change', {target: {value: 'test'}}); - expect(backupAccountPage.find('InputField').props().errorText).toEqual('Please enter a valid email address'); - expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + context('with invalid email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test'}}); + }); + + it('shows validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual('Please enter a valid email address'); + }); + + it('disables submit button', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); }); - it('shows no error and disables submit button when email is empty', () => { - backupAccountPage.find('input').simulate('change', {target: {value: ''}}); - expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); - expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + context('with empty email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: ''}}); + }); + + it('shows no validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + }); + + it('disables submit button', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); }); }); }); -- cgit v1.2.3