From 8e5a1b524d940b1a4d48330830bf8af614b15f1b Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 23 Mar 2022 11:01:27 +0100 Subject: [PATCH 1/8] clear form.email if click send per link, tests if clicked --- .../GddSend/TransactionForm.spec.js | 39 +++++++++++++------ .../components/GddSend/TransactionForm.vue | 16 +++++--- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index 49b2174e0..7a527af32 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -20,6 +20,11 @@ describe('GddSend', () => { }, } + const SEND_TYPES = { + send: 'send', + link: 'link', + } + const propsData = { balance: 0.0, } @@ -34,7 +39,7 @@ describe('GddSend', () => { }) it('renders the component', () => { - expect(wrapper.find('div.transaction-form').exists()).toBeTruthy() + expect(wrapper.find('div.transaction-form').exists()).toBe(true) }) describe('transaction form disable because balance 0,0 GDD', () => { @@ -51,7 +56,7 @@ describe('GddSend', () => { expect(wrapper.find('.text-danger').text()).toBe('form.no_gdd_available') }) it('has no reset button and no submit button ', () => { - expect(wrapper.find('.test-buttons').exists()).toBeFalsy() + expect(wrapper.find('.test-buttons').exists()).toBe(false) }) }) @@ -63,13 +68,17 @@ describe('GddSend', () => { await wrapper.findAll('input[type="radio"]').at(0).setChecked() }) + it('has SEND_TYPES = send', () => { + expect(wrapper.vm.selected).toBe(SEND_TYPES.send) + }) + describe('transaction form', () => { beforeEach(() => { wrapper.setProps({ balance: 100.0 }) }) describe('transaction form show because balance 100,0 GDD', () => { it('has no warning message ', () => { - expect(wrapper.find('.errors').exists()).toBeFalsy() + expect(wrapper.find('.errors').exists()).toBe(false) }) it('has a reset button', () => { expect(wrapper.find('.test-buttons').findAll('button').at(0).attributes('type')).toBe( @@ -159,13 +168,13 @@ describe('GddSend', () => { it('flushes no errors when amount is valid', async () => { await wrapper.find('#input-group-2').find('input').setValue('87.34') await flushPromises() - expect(wrapper.find('span.errors').exists()).toBeFalsy() + expect(wrapper.find('span.errors').exists()).toBe(false) }) }) describe('message text box', () => { it('has an textarea field', () => { - expect(wrapper.find('#input-group-3').find('textarea').exists()).toBeTruthy() + expect(wrapper.find('#input-group-3').find('textarea').exists()).toBe(true) }) it('has an chat-right-text icon', () => { @@ -187,13 +196,13 @@ describe('GddSend', () => { it('flushes no error message when memo is valid', async () => { await wrapper.find('#input-group-3').find('textarea').setValue('Long enough') await flushPromises() - expect(wrapper.find('span.errors').exists()).toBeFalsy() + expect(wrapper.find('span.errors').exists()).toBe(false) }) }) describe('cancel button', () => { it('has a cancel button', () => { - expect(wrapper.find('button[type="reset"]').exists()).toBeTruthy() + expect(wrapper.find('button[type="reset"]').exists()).toBe(true) }) it('has the text "form.cancel"', () => { @@ -244,14 +253,22 @@ describe('GddSend', () => { describe('is selected: "link"', () => { beforeEach(async () => { - // await wrapper.setData({ - // selected: 'link', - // }) + await wrapper.setData({ + form: { email: 'bibi@bloxberg.de' }, + }) await wrapper.findAll('input[type="radio"]').at(1).setChecked() }) + it('has SEND_TYPES = link', () => { + expect(wrapper.vm.selected).toBe(SEND_TYPES.link) + }) + + it('clear form.email to empty ', () => { + expect(wrapper.vm.form.email).toBe('') + }) + it('has no input field of id input-group-1', () => { - expect(wrapper.find('#input-group-1').isVisible()).toBeFalsy() + expect(wrapper.find('#input-group-1').isVisible()).toBe(false) }) }) }) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index ec4aff4d3..602c341a7 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -11,7 +11,13 @@ - + {{ $t('send_per_link') }} @@ -62,9 +68,7 @@ -
- -
+
+
{{ $t('form.no_gdd_available') }}
From 0e05bded0a90603f76404bfe17c2657bbe97aa4f Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Wed, 23 Mar 2022 20:37:38 +0100 Subject: [PATCH 2/8] Update frontend/src/components/GddSend/TransactionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/GddSend/TransactionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index 7a527af32..a7ad1b531 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -251,7 +251,7 @@ describe('GddSend', () => { }) }) - describe('is selected: "link"', () => { + describe('create transaction link', () => { beforeEach(async () => { await wrapper.setData({ form: { email: 'bibi@bloxberg.de' }, From 933b55eac2ee84c8fccf50c7c36f85c906d6c1e7 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Wed, 23 Mar 2022 20:37:45 +0100 Subject: [PATCH 3/8] Update frontend/src/components/GddSend/TransactionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/GddSend/TransactionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index a7ad1b531..26bbd07ff 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -263,7 +263,7 @@ describe('GddSend', () => { expect(wrapper.vm.selected).toBe(SEND_TYPES.link) }) - it('clear form.email to empty ', () => { + it('clears form email ', () => { expect(wrapper.vm.form.email).toBe('') }) From 6167e6b1ccd11cb9fdbaa2b45264e1eec6f56b3d Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 24 Mar 2022 10:48:25 +0100 Subject: [PATCH 4/8] SEND_TYPES becomes imported --- frontend/src/components/GddSend/TransactionForm.spec.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index 26bbd07ff..ba0f02a93 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils' import TransactionForm from './TransactionForm' import flushPromises from 'flush-promises' +import { SEND_TYPES } from '@/pages/Send.vue' const localVue = global.localVue @@ -20,11 +21,6 @@ describe('GddSend', () => { }, } - const SEND_TYPES = { - send: 'send', - link: 'link', - } - const propsData = { balance: 0.0, } From 8c9472c050a2b2dd655481ed8526f44af269402c Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 24 Mar 2022 10:55:51 +0100 Subject: [PATCH 5/8] change v-show to v-if --- frontend/src/components/GddSend/TransactionForm.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index 0ab34ec62..ef645eab1 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -22,16 +22,15 @@ -
+

{{ $t('gdd_per_link.header') }}

{{ $t('gdd_per_link.choose-amount') }}
-
+
+ {{ $t('send_per_link') }} @@ -144,7 +138,6 @@ -
From 38929102fd64577a937dd41d765a1377d84555bd Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 24 Mar 2022 11:11:20 +0100 Subject: [PATCH 7/8] yarn test fixed --- frontend/src/components/GddSend/TransactionForm.spec.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index ba0f02a93..490b6d759 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -249,9 +249,6 @@ describe('GddSend', () => { describe('create transaction link', () => { beforeEach(async () => { - await wrapper.setData({ - form: { email: 'bibi@bloxberg.de' }, - }) await wrapper.findAll('input[type="radio"]').at(1).setChecked() }) @@ -259,12 +256,8 @@ describe('GddSend', () => { expect(wrapper.vm.selected).toBe(SEND_TYPES.link) }) - it('clears form email ', () => { - expect(wrapper.vm.form.email).toBe('') - }) - it('has no input field of id input-group-1', () => { - expect(wrapper.find('#input-group-1').isVisible()).toBe(false) + expect(wrapper.find('#input-group-1').exists()).toBe(false) }) }) }) From 7023959e48ead860da3d14f49ccd4bc9cf457373 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 24 Mar 2022 14:08:17 +0100 Subject: [PATCH 8/8] yarn lint --fix --- frontend/src/components/GddSend/TransactionForm.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index c536932aa..e105e2e1b 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -4,7 +4,6 @@ import flushPromises from 'flush-promises' import { SEND_TYPES } from '@/pages/Send.vue' import DashboardLayout from '@/layouts/DashboardLayout_gdd.vue' - const localVue = global.localVue describe('TransactionForm', () => {