mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into linked-user-email
This commit is contained in:
commit
0ed539b098
@ -38,8 +38,8 @@ EMAIL_SENDER=info@gradido.net
|
||||
EMAIL_PASSWORD=xxx
|
||||
EMAIL_SMTP_URL=gmail.com
|
||||
EMAIL_SMTP_PORT=587
|
||||
EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{code}
|
||||
EMAIL_LINK_SETPASSWORD=http://localhost/reset/{code}
|
||||
EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{optin}{code}
|
||||
EMAIL_LINK_SETPASSWORD=http://localhost/reset/{optin}
|
||||
EMAIL_CODE_VALID_TIME=10
|
||||
|
||||
# Webhook
|
||||
|
||||
@ -62,9 +62,9 @@ const email = {
|
||||
EMAIL_SMTP_URL: process.env.EMAIL_SMTP_URL || 'gmail.com',
|
||||
EMAIL_SMTP_PORT: process.env.EMAIL_SMTP_PORT || '587',
|
||||
EMAIL_LINK_VERIFICATION:
|
||||
process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/checkEmail/{code}',
|
||||
process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/checkEmail/{optin}{code}',
|
||||
EMAIL_LINK_SETPASSWORD:
|
||||
process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/reset-password/{code}',
|
||||
process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/reset-password/{optin}',
|
||||
EMAIL_CODE_VALID_TIME: process.env.EMAIL_CODE_VALID_TIME
|
||||
? parseInt(process.env.EMAIL_CODE_VALID_TIME) || 10
|
||||
: 10,
|
||||
|
||||
@ -16,4 +16,7 @@ export default class CreateUserArgs {
|
||||
|
||||
@Field(() => Int, { nullable: true })
|
||||
publisherId: number
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
redeemCode?: string | null
|
||||
}
|
||||
|
||||
@ -124,7 +124,10 @@ describe('UserResolver', () => {
|
||||
|
||||
describe('account activation email', () => {
|
||||
it('sends an account activation email', () => {
|
||||
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(/{code}/g, emailOptIn)
|
||||
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
|
||||
/{optin}/g,
|
||||
emailOptIn,
|
||||
).replace(/{code}/g, '')
|
||||
expect(sendAccountActivationEmail).toBeCalledWith({
|
||||
link: activationLink,
|
||||
firstName: 'Peter',
|
||||
|
||||
@ -7,6 +7,7 @@ import { getConnection, getCustomRepository, QueryRunner } from '@dbTools/typeor
|
||||
import CONFIG from '@/config'
|
||||
import { User } from '@model/User'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
||||
import { encode } from '@/auth/JWT'
|
||||
import CreateUserArgs from '@arg/CreateUserArgs'
|
||||
import UnsecureLoginArgs from '@arg/UnsecureLoginArgs'
|
||||
@ -305,7 +306,8 @@ export class UserResolver {
|
||||
@Authorized([RIGHTS.CREATE_USER])
|
||||
@Mutation(() => User)
|
||||
async createUser(
|
||||
@Args() { email, firstName, lastName, language, publisherId }: CreateUserArgs,
|
||||
@Args()
|
||||
{ email, firstName, lastName, language, publisherId, redeemCode = null }: CreateUserArgs,
|
||||
): Promise<User> {
|
||||
// TODO: wrong default value (should be null), how does graphql work here? Is it an required field?
|
||||
// default int publisher_id = 0;
|
||||
@ -338,6 +340,12 @@ export class UserResolver {
|
||||
dbUser.language = language
|
||||
dbUser.publisherId = publisherId
|
||||
dbUser.passphrase = passphrase.join(' ')
|
||||
if (redeemCode) {
|
||||
const transactionLink = await dbTransactionLink.findOne({ code: redeemCode })
|
||||
if (transactionLink) {
|
||||
dbUser.referrerId = transactionLink.userId
|
||||
}
|
||||
}
|
||||
// TODO this field has no null allowed unlike the loginServer table
|
||||
// dbUser.pubKey = Buffer.from(randomBytes(32)) // Buffer.alloc(32, 0) default to 0000...
|
||||
// dbUser.pubkey = keyPair[0]
|
||||
@ -360,9 +368,9 @@ export class UserResolver {
|
||||
const emailOptIn = await createEmailOptIn(dbUser.id, queryRunner)
|
||||
|
||||
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
|
||||
/{code}/g,
|
||||
/{optin}/g,
|
||||
emailOptIn.verificationCode.toString(),
|
||||
)
|
||||
).replace(/{code}/g, redeemCode ? '/' + redeemCode : '')
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const emailSent = await sendAccountActivationEmail({
|
||||
@ -379,6 +387,7 @@ export class UserResolver {
|
||||
console.log(`Account confirmation link: ${activationLink}`)
|
||||
}
|
||||
*/
|
||||
|
||||
await queryRunner.commitTransaction()
|
||||
} catch (e) {
|
||||
await queryRunner.rollbackTransaction()
|
||||
@ -404,7 +413,7 @@ export class UserResolver {
|
||||
const emailOptIn = await createEmailOptIn(user.id, queryRunner)
|
||||
|
||||
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
|
||||
/{code}/g,
|
||||
/{optin}/g,
|
||||
emailOptIn.verificationCode.toString(),
|
||||
)
|
||||
|
||||
@ -443,7 +452,7 @@ export class UserResolver {
|
||||
const optInCode = await getOptInCode(user.id)
|
||||
|
||||
const link = CONFIG.EMAIL_LINK_SETPASSWORD.replace(
|
||||
/{code}/g,
|
||||
/{optin}/g,
|
||||
optInCode.verificationCode.toString(),
|
||||
)
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ export const createUser = gql`
|
||||
$email: String!
|
||||
$language: String!
|
||||
$publisherId: Int
|
||||
$redeemCode: String
|
||||
) {
|
||||
createUser(
|
||||
email: $email
|
||||
@ -52,6 +53,7 @@ export const createUser = gql`
|
||||
lastName: $lastName
|
||||
language: $language
|
||||
publisherId: $publisherId
|
||||
redeemCode: $redeemCode
|
||||
) {
|
||||
id
|
||||
}
|
||||
|
||||
@ -160,6 +160,9 @@ export default {
|
||||
},
|
||||
props: {
|
||||
balance: { type: Number, default: 0 },
|
||||
email: { type: String, default: '' },
|
||||
amount: { type: Number, default: 0 },
|
||||
memo: { type: String, default: '' },
|
||||
},
|
||||
inject: ['getTunneledEmail'],
|
||||
data() {
|
||||
@ -167,9 +170,9 @@ export default {
|
||||
amountFocused: false,
|
||||
emailFocused: false,
|
||||
form: {
|
||||
email: '',
|
||||
amount: '',
|
||||
memo: '',
|
||||
email: this.email,
|
||||
amount: this.amount ? String(this.amount) : '',
|
||||
memo: this.memo,
|
||||
amountValue: 0.0,
|
||||
},
|
||||
selected: SEND_TYPES.send,
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'TransactionResultSend',
|
||||
name: 'TransactionResultSendError',
|
||||
props: {
|
||||
error: { type: Boolean, default: false },
|
||||
errorResult: { type: String, default: '' },
|
||||
|
||||
@ -45,6 +45,7 @@ export const createUser = gql`
|
||||
$email: String!
|
||||
$language: String!
|
||||
$publisherId: Int
|
||||
$redeemCode: String
|
||||
) {
|
||||
createUser(
|
||||
email: $email
|
||||
@ -52,6 +53,7 @@ export const createUser = gql`
|
||||
lastName: $lastName
|
||||
language: $language
|
||||
publisherId: $publisherId
|
||||
redeemCode: $redeemCode
|
||||
) {
|
||||
id
|
||||
}
|
||||
|
||||
@ -140,14 +140,6 @@ describe('DashboardLayoutGdd', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('update balance', () => {
|
||||
it('updates the amount correctelly', async () => {
|
||||
await wrapper.findComponent({ ref: 'router-view' }).vm.$emit('update-balance', 5)
|
||||
await flushPromises()
|
||||
expect(wrapper.vm.balance).toBe(-5)
|
||||
})
|
||||
})
|
||||
|
||||
describe('update transactions', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockResolvedValue({
|
||||
|
||||
@ -27,7 +27,6 @@
|
||||
:transactionLinkCount="transactionLinkCount"
|
||||
:pending="pending"
|
||||
:decayStartBlock="decayStartBlock"
|
||||
@update-balance="updateBalance"
|
||||
@update-transactions="updateTransactions"
|
||||
@set-tunneled-email="setTunneledEmail"
|
||||
></router-view>
|
||||
@ -119,9 +118,6 @@ export default {
|
||||
// what to do when loading balance fails?
|
||||
})
|
||||
},
|
||||
updateBalance(ammount) {
|
||||
this.balance -= ammount
|
||||
},
|
||||
admin() {
|
||||
window.location.assign(CONFIG.ADMIN_AUTH_URL.replace('{token}', this.$store.state.token))
|
||||
this.$store.dispatch('logout') // logout without redirect
|
||||
|
||||
@ -54,25 +54,27 @@ describe('ResetPassword', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
describe('No valid optin', () => {
|
||||
it.skip('does not render the Reset Password form when not authenticated', () => {
|
||||
expect(wrapper.find('form').exists()).toBeFalsy()
|
||||
describe('no valid optin', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
apolloQueryMock.mockRejectedValue({ message: 'Your time is up!' })
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it.skip('toasts an error when no valid optin is given', () => {
|
||||
expect(toastErrorSpy).toHaveBeenCalledWith('error')
|
||||
it('toasts an error when no valid optin is given', () => {
|
||||
expect(toastErrorSpy).toHaveBeenCalledWith('Your time is up!')
|
||||
})
|
||||
|
||||
it.skip('has a message suggesting to contact the support', () => {
|
||||
expect(wrapper.find('div.header').text()).toContain('settings.password.reset')
|
||||
expect(wrapper.find('div.header').text()).toContain('settings.password.not-authenticated')
|
||||
it('redirects to /forgot-password/resetPassword', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/forgot-password/resetPassword')
|
||||
})
|
||||
})
|
||||
|
||||
describe('is authenticated', () => {
|
||||
describe('valid optin', () => {
|
||||
it('renders the Reset Password form when authenticated', () => {
|
||||
expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy()
|
||||
})
|
||||
@ -148,7 +150,6 @@ describe('ResetPassword', () => {
|
||||
|
||||
describe('server response with error code > 10min', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
apolloMutationMock.mockRejectedValue({ message: '...Code is older than 10 minutes' })
|
||||
await wrapper.find('form').trigger('submit')
|
||||
await flushPromises()
|
||||
@ -163,7 +164,7 @@ describe('ResetPassword', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('server response with error code > 10min', () => {
|
||||
describe('server response with error', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
apolloMutationMock.mockRejectedValueOnce({ message: 'Error' })
|
||||
@ -178,6 +179,7 @@ describe('ResetPassword', () => {
|
||||
|
||||
describe('server response with success on /checkEmail', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
mocks.$route.path.mock = 'checkEmail'
|
||||
apolloMutationMock.mockResolvedValue({
|
||||
data: {
|
||||
@ -204,6 +206,28 @@ describe('ResetPassword', () => {
|
||||
it('redirects to "/thx/checkEmail"', () => {
|
||||
expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail')
|
||||
})
|
||||
|
||||
describe('with param code', () => {
|
||||
beforeEach(async () => {
|
||||
mocks.$route.params.code = 'the-most-secret-code-ever'
|
||||
apolloMutationMock.mockResolvedValue({
|
||||
data: {
|
||||
resetPassword: 'success',
|
||||
},
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
await wrapper.findAll('input').at(0).setValue('Aa123456_')
|
||||
await wrapper.findAll('input').at(1).setValue('Aa123456_')
|
||||
await wrapper.find('form').trigger('submit')
|
||||
await flushPromises()
|
||||
})
|
||||
|
||||
it('redirects to "/thx/checkEmail/the-most-secret-code-ever"', () => {
|
||||
expect(routerPushMock).toHaveBeenCalledWith(
|
||||
'/thx/checkEmail/the-most-secret-code-ever',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('server response with success on /reset-password', () => {
|
||||
|
||||
@ -6,11 +6,11 @@
|
||||
<b-row class="justify-content-center">
|
||||
<b-col xl="5" lg="6" md="8" class="px-2">
|
||||
<!-- eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys-->
|
||||
<h1>{{ $t(displaySetup.authenticated) }}</h1>
|
||||
<h1>{{ $t(displaySetup.title) }}</h1>
|
||||
<div class="pb-4">
|
||||
<span>
|
||||
<!-- eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys-->
|
||||
{{ $t(displaySetup.notAuthenticated) }}
|
||||
{{ $t(displaySetup.text) }}
|
||||
</span>
|
||||
</div>
|
||||
</b-col>
|
||||
@ -53,14 +53,14 @@ import { queryOptIn } from '@/graphql/queries'
|
||||
|
||||
const textFields = {
|
||||
reset: {
|
||||
authenticated: 'settings.password.change-password',
|
||||
notAuthenticated: 'settings.password.reset-password.text',
|
||||
title: 'settings.password.change-password',
|
||||
text: 'settings.password.reset-password.text',
|
||||
button: 'settings.password.change-password',
|
||||
linkTo: '/login',
|
||||
},
|
||||
checkEmail: {
|
||||
authenticated: 'settings.password.set',
|
||||
notAuthenticated: 'settings.password.set-password.text',
|
||||
title: 'settings.password.set',
|
||||
text: 'settings.password.set-password.text',
|
||||
button: 'settings.password.set',
|
||||
linkTo: '/login',
|
||||
},
|
||||
@ -97,7 +97,11 @@ export default {
|
||||
.then(() => {
|
||||
this.form.password = ''
|
||||
if (this.$route.path.includes('checkEmail')) {
|
||||
this.$router.push('/thx/checkEmail')
|
||||
if (this.$route.params.code) {
|
||||
this.$router.push('/thx/checkEmail/' + this.$route.params.code)
|
||||
} else {
|
||||
this.$router.push('/thx/checkEmail')
|
||||
}
|
||||
} else {
|
||||
this.$router.push('/thx/resetPassword')
|
||||
}
|
||||
|
||||
@ -18,9 +18,7 @@ describe('Send', () => {
|
||||
const propsData = {
|
||||
balance: 123.45,
|
||||
GdtBalance: 1234.56,
|
||||
transactions: [{ balance: 0.1 }],
|
||||
pending: true,
|
||||
currentTransactionStep: TRANSACTION_STEPS.transactionConfirmationSend,
|
||||
}
|
||||
|
||||
const mocks = {
|
||||
@ -54,11 +52,10 @@ describe('Send', () => {
|
||||
})
|
||||
|
||||
it('has a send field', () => {
|
||||
expect(wrapper.find('div.gdd-send').exists()).toBeTruthy()
|
||||
expect(wrapper.find('div.gdd-send').exists()).toBe(true)
|
||||
})
|
||||
|
||||
/* SEND */
|
||||
describe('transaction form send', () => {
|
||||
describe('fill transaction form for send coins', () => {
|
||||
beforeEach(async () => {
|
||||
wrapper.findComponent({ name: 'TransactionForm' }).vm.$emit('set-transaction', {
|
||||
email: 'user@example.org',
|
||||
@ -67,86 +64,92 @@ describe('Send', () => {
|
||||
selected: SEND_TYPES.send,
|
||||
})
|
||||
})
|
||||
|
||||
it('steps forward in the dialog', () => {
|
||||
expect(wrapper.findComponent({ name: 'TransactionConfirmationSend' }).exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirm transaction if selected: SEND_TYPES.send', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.setData({
|
||||
currentTransactionStep: TRANSACTION_STEPS.transactionConfirmationSend,
|
||||
transactionData: {
|
||||
email: 'user@example.org',
|
||||
amount: 23.45,
|
||||
memo: 'Make the best of it!',
|
||||
selected: SEND_TYPES.send,
|
||||
},
|
||||
})
|
||||
})
|
||||
describe('confirm transaction view', () => {
|
||||
describe('cancel confirmation', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('on-reset')
|
||||
})
|
||||
|
||||
it('resets the transaction process when on-reset is emitted', async () => {
|
||||
await wrapper.findComponent({ name: 'TransactionConfirmationSend' }).vm.$emit('on-reset')
|
||||
expect(wrapper.findComponent({ name: 'TransactionForm' }).exists()).toBeTruthy()
|
||||
expect(wrapper.vm.transactionData).toEqual({
|
||||
email: 'user@example.org',
|
||||
amount: 23.45,
|
||||
memo: 'Make the best of it!',
|
||||
selected: SEND_TYPES.send,
|
||||
})
|
||||
})
|
||||
it('shows the transaction formular again', () => {
|
||||
expect(wrapper.findComponent({ name: 'TransactionForm' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
describe('transaction is confirmed and server response is success', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('send-transaction')
|
||||
it('restores the previous data in the formular', () => {
|
||||
expect(wrapper.find('#input-group-1').find('input').vm.$el.value).toBe(
|
||||
'user@example.org',
|
||||
)
|
||||
expect(wrapper.find('#input-group-2').find('input').vm.$el.value).toBe('23.45')
|
||||
expect(wrapper.find('#input-group-3').find('textarea').vm.$el.value).toBe(
|
||||
'Make the best of it!',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('calls the API when send-transaction is emitted', async () => {
|
||||
expect(apolloMutationMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'user@example.org',
|
||||
amount: 23.45,
|
||||
memo: 'Make the best of it!',
|
||||
selected: SEND_TYPES.send,
|
||||
},
|
||||
}),
|
||||
)
|
||||
describe('confirm transaction with server succees', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('send-transaction')
|
||||
})
|
||||
|
||||
it('calls the API when send-transaction is emitted', async () => {
|
||||
expect(apolloMutationMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'user@example.org',
|
||||
amount: 23.45,
|
||||
memo: 'Make the best of it!',
|
||||
selected: SEND_TYPES.send,
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('emits update transactions', () => {
|
||||
expect(wrapper.emitted('update-transactions')).toBeTruthy()
|
||||
expect(wrapper.emitted('update-transactions')).toEqual(expect.arrayContaining([[{}]]))
|
||||
})
|
||||
|
||||
it('shows the success page', () => {
|
||||
expect(wrapper.find('div.card-body').text()).toContain('form.send_transaction_success')
|
||||
})
|
||||
})
|
||||
|
||||
it('emits update-balance', () => {
|
||||
expect(wrapper.emitted('update-balance')).toBeTruthy()
|
||||
expect(wrapper.emitted('update-balance')).toEqual([[23.45]])
|
||||
})
|
||||
describe('confirm transaction with server error', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
apolloMutationMock.mockRejectedValue({ message: 'recipient not known' })
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('send-transaction')
|
||||
})
|
||||
|
||||
it('shows the success page', () => {
|
||||
expect(wrapper.find('div.card-body').text()).toContain('form.send_transaction_success')
|
||||
})
|
||||
})
|
||||
it('has a component TransactionResultSendError', () => {
|
||||
expect(wrapper.findComponent({ name: 'TransactionResultSendError' }).exists()).toBe(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
describe('transaction is confirmed and server response is error', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
apolloMutationMock.mockRejectedValue({ message: 'recipient not known' })
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('send-transaction')
|
||||
})
|
||||
it('has an standard error text', () => {
|
||||
expect(wrapper.find('.test-send_transaction_error').text()).toContain(
|
||||
'form.send_transaction_error',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the error page', () => {
|
||||
expect(wrapper.find('.test-send_transaction_error').text()).toContain(
|
||||
'form.send_transaction_error',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows recipient not found', () => {
|
||||
expect(wrapper.find('.test-receiver-not-found').text()).toContain(
|
||||
'transaction.receiverNotFound',
|
||||
)
|
||||
it('shows recipient not found', () => {
|
||||
expect(wrapper.find('.test-receiver-not-found').text()).toContain(
|
||||
'transaction.receiverNotFound',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -160,10 +163,11 @@ describe('Send', () => {
|
||||
})
|
||||
await wrapper.findComponent({ name: 'TransactionForm' }).vm.$emit('set-transaction', {
|
||||
amount: 56.78,
|
||||
memo: 'Make the best of it link!',
|
||||
memo: 'Make the best of the link!',
|
||||
selected: SEND_TYPES.link,
|
||||
})
|
||||
})
|
||||
|
||||
it('steps forward in the dialog', () => {
|
||||
expect(wrapper.findComponent({ name: 'TransactionConfirmationLink' }).exists()).toBe(true)
|
||||
})
|
||||
@ -182,18 +186,18 @@ describe('Send', () => {
|
||||
mutation: createTransactionLink,
|
||||
variables: {
|
||||
amount: 56.78,
|
||||
memo: 'Make the best of it link!',
|
||||
memo: 'Make the best of the link!',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it.skip('emits update-balance', () => {
|
||||
expect(wrapper.emitted('update-balance')).toBeTruthy()
|
||||
expect(wrapper.emitted('update-balance')).toEqual([[56.78]])
|
||||
it('emits update-transactions', () => {
|
||||
expect(wrapper.emitted('update-transactions')).toBeTruthy()
|
||||
expect(wrapper.emitted('update-transactions')).toEqual(expect.arrayContaining([[{}]]))
|
||||
})
|
||||
|
||||
it('find components ClipBoard', () => {
|
||||
it('finds the clip board component', () => {
|
||||
expect(wrapper.findComponent({ name: 'ClipboardCopy' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
@ -205,7 +209,7 @@ describe('Send', () => {
|
||||
expect(wrapper.find('div.card-body').text()).toContain('form.close')
|
||||
})
|
||||
|
||||
describe('Copy link to Clipboard', () => {
|
||||
describe('copy link to clipboard', () => {
|
||||
const navigatorClipboard = navigator.clipboard
|
||||
beforeAll(() => {
|
||||
delete navigator.clipboard
|
||||
@ -260,5 +264,39 @@ describe('Send', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('no field selected on send transaction', () => {
|
||||
const errorHandler = localVue.config.errorHandler
|
||||
|
||||
beforeAll(() => {
|
||||
localVue.config.errorHandler = jest.fn()
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
localVue.config.errorHandler = errorHandler
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({
|
||||
currentTransactionStep: TRANSACTION_STEPS.transactionConfirmationSend,
|
||||
transactionData: {
|
||||
email: 'user@example.org',
|
||||
amount: 23.45,
|
||||
memo: 'Make the best of it!',
|
||||
selected: 'not-valid',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('throws an error', async () => {
|
||||
try {
|
||||
await wrapper
|
||||
.findComponent({ name: 'TransactionConfirmationSend' })
|
||||
.vm.$emit('send-transaction')
|
||||
} catch (error) {
|
||||
expect(error).toBe('undefined transactionData.selected : not-valid')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -3,7 +3,11 @@
|
||||
<b-container>
|
||||
<gdd-send :currentTransactionStep="currentTransactionStep" class="pt-3 ml-2 mr-2">
|
||||
<template #transactionForm>
|
||||
<transaction-form :balance="balance" @set-transaction="setTransaction"></transaction-form>
|
||||
<transaction-form
|
||||
v-bind="transactionData"
|
||||
:balance="balance"
|
||||
@set-transaction="setTransaction"
|
||||
></transaction-form>
|
||||
</template>
|
||||
<template #transactionConfirmationSend>
|
||||
<transaction-confirmation-send
|
||||
@ -124,8 +128,9 @@ export default {
|
||||
})
|
||||
.then(() => {
|
||||
this.error = false
|
||||
this.$emit('update-balance', this.transactionData.amount)
|
||||
this.$emit('set-tunneled-email', null)
|
||||
this.updateTransactions({})
|
||||
this.transactionData = { ...EMPTY_TRANSACTION_DATA }
|
||||
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultSendSuccess
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -144,6 +149,7 @@ export default {
|
||||
this.$emit('set-tunneled-email', null)
|
||||
this.code = result.data.createTransactionLink.code
|
||||
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink
|
||||
this.updateTransactions({})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error)
|
||||
@ -162,7 +168,7 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.updateTransactions(0)
|
||||
this.updateTransactions({})
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -9,7 +9,11 @@
|
||||
<!-- eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys-->
|
||||
<p class="h4">{{ $t(displaySetup.subtitle) }}</p>
|
||||
<hr />
|
||||
<b-button v-if="displaySetup.linkTo" :to="displaySetup.linkTo">
|
||||
<b-button v-if="$route.params.code" :to="`/redeem/${$route.params.code}`">
|
||||
<!-- eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys-->
|
||||
{{ $t(displaySetup.button) }}
|
||||
</b-button>
|
||||
<b-button v-else :to="displaySetup.linkTo">
|
||||
<!-- eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys-->
|
||||
{{ $t(displaySetup.button) }}
|
||||
</b-button>
|
||||
|
||||
@ -112,7 +112,7 @@ describe('router', () => {
|
||||
})
|
||||
|
||||
describe('thx', () => {
|
||||
const thx = routes.find((r) => r.path === '/thx/:comingFrom')
|
||||
const thx = routes.find((r) => r.path === '/thx/:comingFrom/:code?')
|
||||
|
||||
it('loads the "Thx" page', async () => {
|
||||
const component = await thx.component()
|
||||
@ -177,7 +177,9 @@ describe('router', () => {
|
||||
|
||||
describe('checkEmail', () => {
|
||||
it('loads the "CheckEmail" page', async () => {
|
||||
const component = await routes.find((r) => r.path === '/checkEmail/:optin').component()
|
||||
const component = await routes
|
||||
.find((r) => r.path === '/checkEmail/:optin/:code?')
|
||||
.component()
|
||||
expect(component.default.name).toBe('ResetPassword')
|
||||
})
|
||||
})
|
||||
|
||||
@ -47,7 +47,7 @@ const routes = [
|
||||
component: () => import('@/pages/Register.vue'),
|
||||
},
|
||||
{
|
||||
path: '/thx/:comingFrom',
|
||||
path: '/thx/:comingFrom/:code?',
|
||||
component: () => import('@/pages/thx.vue'),
|
||||
beforeEnter: (to, from, next) => {
|
||||
const validFrom = ['forgot-password', 'reset-password', 'register', 'login', 'checkEmail']
|
||||
@ -79,7 +79,7 @@ const routes = [
|
||||
component: () => import('@/pages/ResetPassword.vue'),
|
||||
},
|
||||
{
|
||||
path: '/checkEmail/:optin',
|
||||
path: '/checkEmail/:optin/:code?',
|
||||
component: () => import('@/pages/ResetPassword.vue'),
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user