diff --git a/frontend/src/components/Inputs/InputAmount.vue b/frontend/src/components/Inputs/InputAmount.vue index 3268a0ec1..4a77474d7 100644 --- a/frontend/src/components/Inputs/InputAmount.vue +++ b/frontend/src/components/Inputs/InputAmount.vue @@ -7,8 +7,9 @@ :name="name" v-slot="{ errors, valid, validated, ariaInput, ariaMsg }" > - + { beforeEach(async () => { const transactionForm = wrapper.findComponent({ name: 'TransactionForm' }) await transactionForm.findAll('input[type="radio"]').at(0).setChecked() - await transactionForm.find('input[type="email"]').setValue('user@example.org') - await transactionForm.find('input[type="text"]').setValue('23.45') + await transactionForm.find('[data-test="input-identifier"]').setValue('user@example.org') + await transactionForm.find('[data-test="input-amount"]').setValue('23.45') await transactionForm.find('textarea').setValue('Make the best of it!') await transactionForm.find('form').trigger('submit') await flushPromises() @@ -91,8 +91,10 @@ describe('Send', () => { }) it('restores the previous data in the formular', () => { - expect(wrapper.find("input[type='email']").vm.$el.value).toBe('user@example.org') - expect(wrapper.find("input[type='text']").vm.$el.value).toBe('23.45') + expect(wrapper.find('[data-test="input-identifier"]').vm.$el.value).toBe( + 'user@example.org', + ) + expect(wrapper.find('[data-test="input-amount"]').vm.$el.value).toBe('23.45') expect(wrapper.find('textarea').vm.$el.value).toBe('Make the best of it!') }) }) @@ -175,7 +177,10 @@ describe('Send', () => { it('has no email input field', () => { expect( - wrapper.findComponent({ name: 'TransactionForm' }).find('input[type="email"]').exists(), + wrapper + .findComponent({ name: 'TransactionForm' }) + .find('[data-test="input-identifier"]') + .exists(), ).toBe(false) }) @@ -183,7 +188,7 @@ describe('Send', () => { beforeEach(async () => { jest.clearAllMocks() const transactionForm = wrapper.findComponent({ name: 'TransactionForm' }) - await transactionForm.find('input[type="text"]').setValue('34.56') + await transactionForm.find('[data-test="input-amount"]').setValue('34.56') await transactionForm.find('textarea').setValue('Make the best of it!') await transactionForm.find('form').trigger('submit') await flushPromises() @@ -243,7 +248,7 @@ describe('Send', () => { }) const transactionForm = wrapper.findComponent({ name: 'TransactionForm' }) await transactionForm.findAll('input[type="radio"]').at(1).setChecked() - await transactionForm.find('input[type="text"]').setValue('56.78') + await transactionForm.find('[data-test="input-amount"]').setValue('56.78') await transactionForm.find('textarea').setValue('Make the best of the link!') await transactionForm.find('form').trigger('submit') await flushPromises() diff --git a/frontend/src/validation-rules.js b/frontend/src/validation-rules.js index a23d69215..2dbd5368e 100644 --- a/frontend/src/validation-rules.js +++ b/frontend/src/validation-rules.js @@ -168,7 +168,7 @@ export const loadAllRules = (i18nCallback, apollo) => { extend('validIdentifier', { validate(value) { - const isEmail = !!value.match(emailRegex) + const isEmail = !!emailRegex.test(value) const isUsername = !!value.match(usernameRegex) const isGradidoId = validateUuid(value) && versionUuid(value) === 4 return isEmail || isUsername || isGradidoId