From e9dcfd04fd9a80660657c694c2c550ac96aa9eb2 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 22 Nov 2019 15:04:06 +0100 Subject: [PATCH 1/3] Expose #2329 --- webapp/components/LoginForm/LoginForm.spec.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 webapp/components/LoginForm/LoginForm.spec.js diff --git a/webapp/components/LoginForm/LoginForm.spec.js b/webapp/components/LoginForm/LoginForm.spec.js new file mode 100644 index 000000000..b8697e771 --- /dev/null +++ b/webapp/components/LoginForm/LoginForm.spec.js @@ -0,0 +1,73 @@ +import LoginForm from './LoginForm.vue' +import Styleguide from '@human-connection/styleguide' +import Vuex from 'vuex' +import { config, mount, createLocalVue } from '@vue/test-utils' + +const localVue = createLocalVue() +localVue.use(Vuex) +localVue.use(Styleguide) + +config.stubs['nuxt-link'] = '' +config.stubs['locale-switch'] = '' +config.stubs['client-only'] = '' + +describe('LoginForm', () => { + let mocks + let propsData + let storeMocks + + beforeEach(() => { + propsData = {} + }) + + describe('mount', () => { + const Wrapper = () => { + storeMocks = { + getters: { + 'auth/pending': () => false, + }, + actions: { + 'auth/login': jest.fn(), + }, + } + const store = new Vuex.Store(storeMocks) + mocks = { + $t: () => {}, + $toast: { + success: jest.fn(), + error: jest.fn(), + }, + } + return mount(LoginForm, { mocks, localVue, propsData, store }) + } + + describe('fill in email and password and submit', () => { + const fillIn = (wrapper, opts = {}) => { + const { email = 'email@example.org', password = '1234' } = opts + wrapper.find('input[name="email"]').setValue(email) + wrapper.find('input[name="password"]').setValue(password) + wrapper.find('form').trigger('submit') + } + + it('dispatches login with form data', () => { + fillIn(Wrapper()) + expect(storeMocks.actions['auth/login']).toHaveBeenCalledWith( + expect.any(Object), + { email: 'email@example.org', password: '1234' }, + undefined, + ) + }) + + describe('given email is a gmail address', () => { + it('removes dots, issue #2329', () => { + fillIn(Wrapper(), { email: 'example.user@gmail.com' }) + expect(storeMocks.actions['auth/login']).toHaveBeenCalledWith( + expect.any(Object), + { email: 'exampleuser@gmail.com', password: '1234' }, + undefined, + ) + }) + }) + }) + }) +}) From 145b6727b16ef1a7a9052286ea42873e61123785 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 22 Nov 2019 15:08:25 +0100 Subject: [PATCH 2/3] Fix 2329 in the frontend --- webapp/components/LoginForm/LoginForm.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/components/LoginForm/LoginForm.vue b/webapp/components/LoginForm/LoginForm.vue index 91693ed4b..0d13772a9 100644 --- a/webapp/components/LoginForm/LoginForm.vue +++ b/webapp/components/LoginForm/LoginForm.vue @@ -73,6 +73,7 @@