Merge branch 'master' into remove_unnecessary_repositories

This commit is contained in:
Ulf Gebhardt 2022-02-07 04:07:34 +01:00 committed by GitHub
commit 44c0adb0c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 357 additions and 236 deletions

View File

@ -448,7 +448,7 @@ jobs:
report_name: Coverage Admin Interface report_name: Coverage Admin Interface
type: lcov type: lcov
result_path: ./coverage/lcov.info result_path: ./coverage/lcov.info
min_coverage: 91 min_coverage: 93
token: ${{ github.token }} token: ${{ github.token }}
############################################################################## ##############################################################################

View File

@ -13,3 +13,11 @@ export default {
components: { defaultLayout }, components: { defaultLayout },
} }
</script> </script>
<style>
.pointer {
cursor: pointer;
}
.pointer:hover {
background-color: rgb(216, 213, 213);
}
</style>

View File

@ -11,22 +11,36 @@ describe('UserTable', () => {
const defaultItemsUser = [ const defaultItemsUser = [
{ {
email: 'bibi@bloxberg.de', userId: 1,
firstName: 'Bibi', firstName: 'Bibi',
lastName: 'Bloxberg', lastName: 'Bloxberg',
creation: [1000, 1000, 1000], email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
emailChecked: true,
}, },
{ {
email: 'bibi@bloxberg.de', userId: 2,
firstName: 'Bibi', firstName: 'Benjamin',
lastName: 'Bloxberg', lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [1000, 1000, 1000], creation: [1000, 1000, 1000],
emailChecked: true,
}, },
{ {
email: 'bibi@bloxberg.de', userId: 3,
firstName: 'Bibi', firstName: 'Peter',
lastName: 'Bloxberg', lastName: 'Lustig',
email: 'peter@lustig.de',
creation: [0, 0, 0],
emailChecked: true,
},
{
userId: 4,
firstName: 'New',
lastName: 'User',
email: 'new@user.ch',
creation: [1000, 1000, 1000], creation: [1000, 1000, 1000],
emailChecked: false,
}, },
] ]
@ -107,7 +121,7 @@ describe('UserTable', () => {
const mocks = { const mocks = {
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => String(d)),
$apollo: { $apollo: {
query: apolloQueryMock, query: apolloQueryMock,
}, },
@ -122,7 +136,7 @@ describe('UserTable', () => {
describe('mount', () => { describe('mount', () => {
describe('type PageUserSearch', () => { describe('type PageUserSearch', () => {
beforeEach(() => { beforeEach(async () => {
wrapper = Wrapper(propsDataPageUserSearch) wrapper = Wrapper(propsDataPageUserSearch)
}) })
@ -175,12 +189,12 @@ describe('UserTable', () => {
}) })
describe('content', () => { describe('content', () => {
it('has 3 rows', () => { it('has 4 rows', () => {
expect(wrapper.findAll('tbody tr').length).toBe(3) expect(wrapper.findAll('tbody tr')).toHaveLength(4)
}) })
it('has 7 columns', () => { it('has 7 columns', () => {
expect(wrapper.findAll('tr:nth-child(1) > td').length).toBe(7) expect(wrapper.findAll('tr:nth-child(1) > td')).toHaveLength(7)
}) })
it('find button on fifth column', () => { it('find button on fifth column', () => {
@ -189,6 +203,110 @@ describe('UserTable', () => {
).toBeTruthy() ).toBeTruthy()
}) })
}) })
describe('row toggling', () => {
describe('user with email not activated', () => {
it('has no details button', () => {
expect(
wrapper.findAll('tbody > tr').at(3).findAll('td').at(4).find('button').exists(),
).toBeFalsy()
})
it('has a red confirmed button with envelope item', () => {
const row = wrapper.findAll('tbody > tr').at(3)
expect(row.findAll('td').at(5).find('button').exists()).toBeTruthy()
expect(row.findAll('td').at(5).find('button').classes('btn-danger')).toBeTruthy()
expect(row.findAll('td').at(5).find('svg').classes('bi-envelope')).toBeTruthy()
})
describe('click on envelope', () => {
beforeEach(async () => {
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
})
it('opens the details', async () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
expect(wrapper.findAll('tbody > tr').at(5).find('input').element.value).toBe(
'new@user.ch',
)
expect(wrapper.findAll('tbody > tr').at(5).text()).toContain(
'unregister_mail.text_false',
)
// HACK: for some reason we need to close the row details after this test
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
})
describe('click on envelope again', () => {
beforeEach(async () => {
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
})
it('closes the details', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(4)
})
})
describe('click on close details', () => {
beforeEach(async () => {
await wrapper.findAll('tbody > tr').at(5).findAll('button').at(1).trigger('click')
})
it('closes the details', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(4)
})
})
})
})
describe('different details', () => {
it.skip('shows the creation formular for second user', async () => {
await wrapper
.findAll('tbody > tr')
.at(1)
.findAll('td')
.at(4)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
expect(
wrapper
.findAll('tbody > tr')
.at(3)
.find('div.component-creation-formular')
.exists(),
).toBeTruthy()
})
it.skip('shows the transactions for third user', async () => {
await wrapper
.findAll('tbody > tr')
.at(4)
.findAll('td')
.at(6)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
})
})
})
}) })
}) })

View File

@ -133,7 +133,7 @@
variant="danger" variant="danger"
v-show="type === 'UserListMassCreation' || type === 'PageCreationConfirm'" v-show="type === 'UserListMassCreation' || type === 'PageCreationConfirm'"
size="md" size="md"
@click="overlayShow('remove', row.item)" @click="bookmarkRemove(row.item)"
class="mr-2" class="mr-2"
> >
<b-icon icon="x" variant="light"></b-icon> <b-icon icon="x" variant="light"></b-icon>
@ -242,13 +242,6 @@ export default {
this.overlayBookmarkType = bookmarkType this.overlayBookmarkType = bookmarkType
this.overlayItem = item this.overlayItem = item
if (bookmarkType === 'remove') {
this.overlayText.header = this.$t('overlay.remove.title')
this.overlayText.text1 = this.$t('overlay.remove.text')
this.overlayText.text2 = this.$t('overlay.remove.question')
this.overlayText.button_ok = this.$t('overlay.remove.yes')
this.overlayText.button_cancel = this.$t('overlay.remove.no')
}
if (bookmarkType === 'confirm') { if (bookmarkType === 'confirm') {
this.overlayText.header = this.$t('overlay.confirm.title') this.overlayText.header = this.$t('overlay.confirm.title')
this.overlayText.text1 = this.$t('overlay.confirm.text') this.overlayText.text1 = this.$t('overlay.confirm.text')
@ -258,9 +251,6 @@ export default {
} }
}, },
overlayOK(bookmarkType, item) { overlayOK(bookmarkType, item) {
if (bookmarkType === 'remove') {
this.bookmarkRemove(item)
}
if (bookmarkType === 'confirm') { if (bookmarkType === 'confirm') {
this.$emit('confirm-creation', item) this.$emit('confirm-creation', item)
} }

View File

@ -54,6 +54,7 @@
} }
}, },
"remove": "Entfernen", "remove": "Entfernen",
"remove_all": "alle Nutzer entfernen",
"transaction": "Transaktion", "transaction": "Transaktion",
"transactionlist": { "transactionlist": {
"amount": "Betrag", "amount": "Betrag",

View File

@ -54,6 +54,7 @@
} }
}, },
"remove": "Remove", "remove": "Remove",
"remove_all": "Remove all users",
"transaction": "Transaction", "transaction": "Transaction",
"transactionlist": { "transactionlist": {
"amount": "Amount", "amount": "Amount",

View File

@ -154,55 +154,16 @@ describe('Creation', () => {
}, },
]) ])
}) })
})
describe('remove item', () => { describe('remove item', () => {
beforeEach(async () => {
await wrapper
.findAll('table')
.at(0)
.findAll('tbody > tr')
.at(1)
.find('button')
.trigger('click')
await wrapper
.findAll('table')
.at(1)
.findAll('tbody > tr')
.at(0)
.find('button')
.trigger('click')
})
it('opens a dialog', () => {
expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeTruthy()
})
describe('cancel remove item', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.findAll('#overlay').at(1).findAll('button').at(0).trigger('click') await wrapper
}) .findAll('table')
.at(1)
it('closes the dialog', () => { .findAll('tbody > tr')
expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeFalsy() .at(0)
}) .find('button')
.trigger('click')
it('has one item in left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1)
})
it('has one item in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1)
})
})
describe('confirm remove item', () => {
beforeEach(async () => {
await wrapper.findAll('#overlay').at(1).findAll('button').at(1).trigger('click')
})
it('closes the dialog', () => {
expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeFalsy()
}) })
it('has two items in left table', () => { it('has two items in left table', () => {
@ -223,32 +184,24 @@ describe('Creation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
}) })
}) })
})
// this can only happen after API call in CreationForm describe('remove all bookmarks', () => {
describe('remove all bookmarks', () => { beforeEach(async () => {
beforeEach(async () => { jest.clearAllMocks()
await wrapper await wrapper.find('button.btn-light').trigger('click')
.findAll('table') })
.at(0)
.findAll('tbody > tr')
.at(1)
.find('button')
.trigger('click')
jest.clearAllMocks()
wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark')
})
it('has no items in right table', () => { it('has no items in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0)
}) })
it('commits empty array to userSelectedInMassCreation', () => { it('commits empty array to userSelectedInMassCreation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
}) })
it('calls searchUsers', () => { it('calls searchUsers', () => {
expect(apolloQueryMock).toBeCalled() expect(apolloQueryMock).toBeCalled()
})
}) })
}) })
@ -288,17 +241,38 @@ describe('Creation', () => {
jest.clearAllMocks() jest.clearAllMocks()
}) })
it('calls API when criteria changes', async () => { describe('search criteria', () => {
await wrapper.setData({ criteria: 'XX' }) beforeEach(async () => {
expect(apolloQueryMock).toBeCalledWith( await wrapper.setData({ criteria: 'XX' })
expect.objectContaining({ })
variables: {
searchText: 'XX', it('calls API when criteria changes', async () => {
currentPage: 1, expect(apolloQueryMock).toBeCalledWith(
pageSize: 25, expect.objectContaining({
}, variables: {
}), searchText: 'XX',
) currentPage: 1,
pageSize: 25,
},
}),
)
})
describe('reset search criteria', () => {
it('calls the API', async () => {
jest.clearAllMocks()
await wrapper.find('.test-click-clear-criteria').trigger('click')
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
},
}),
)
})
})
}) })
it('calls API when currentPage changes', async () => { it('calls API when currentPage changes', async () => {

View File

@ -3,12 +3,20 @@
<b-row> <b-row>
<b-col cols="12" lg="6"> <b-col cols="12" lg="6">
<label>Usersuche</label> <label>Usersuche</label>
<b-input <b-input-group>
type="text" <b-form-input
v-model="criteria" type="text"
class="shadow p-3 mb-5 bg-white rounded" class="test-input-criteria"
placeholder="User suche" v-model="criteria"
></b-input> :placeholder="$t('user_search')"
></b-form-input>
<b-input-group-append class="test-click-clear-criteria" @click="criteria = ''">
<b-input-group-text class="pointer">
<b-icon icon="x" />
</b-input-group-text>
</b-input-group-append>
</b-input-group>
<user-table <user-table
v-if="itemsList.length > 0" v-if="itemsList.length > 0"
type="UserListSearch" type="UserListSearch"
@ -25,14 +33,22 @@
></b-pagination> ></b-pagination>
</b-col> </b-col>
<b-col cols="12" lg="6" class="shadow p-3 mb-5 rounded bg-info"> <b-col cols="12" lg="6" class="shadow p-3 mb-5 rounded bg-info">
<user-table <div v-show="itemsMassCreation.length > 0">
v-show="itemsMassCreation.length > 0" <div class="text-right pr-4 mb-1">
class="shadow p-3 mb-5 bg-white rounded" <b-button @click="removeAllBookmarks()" variant="light">
type="UserListMassCreation" <b-icon icon="x" scale="2" variant="danger"></b-icon>
:itemsUser="itemsMassCreation"
:fieldsTable="fields" {{ $t('remove_all') }}
@remove-item="removeItem" </b-button>
/> </div>
<user-table
class="shadow p-3 mb-5 bg-white rounded"
type="UserListMassCreation"
:itemsUser="itemsMassCreation"
:fieldsTable="fields"
@remove-item="removeItem"
/>
</div>
<div v-if="itemsMassCreation.length === 0"> <div v-if="itemsMassCreation.length === 0">
{{ $t('multiple_creation_text') }} {{ $t('multiple_creation_text') }}
</div> </div>
@ -41,7 +57,7 @@
type="massCreation" type="massCreation"
:creation="creation" :creation="creation"
:items="itemsMassCreation" :items="itemsMassCreation"
@remove-all-bookmark="removeAllBookmark" @remove-all-bookmark="removeAllBookmarks"
/> />
</b-col> </b-col>
</b-row> </b-row>
@ -123,7 +139,7 @@ export default {
) )
this.$store.commit('setUserSelectedInMassCreation', this.itemsMassCreation) this.$store.commit('setUserSelectedInMassCreation', this.itemsMassCreation)
}, },
removeAllBookmark() { removeAllBookmarks() {
this.itemsMassCreation = [] this.itemsMassCreation = []
this.$store.commit('setUserSelectedInMassCreation', []) this.$store.commit('setUserSelectedInMassCreation', [])
this.getUsers() this.getUsers()

View File

@ -78,6 +78,7 @@ describe('CreationConfirm', () => {
it('commits resetOpenCreations to store', () => { it('commits resetOpenCreations to store', () => {
expect(storeCommitMock).toBeCalledWith('resetOpenCreations') expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
}) })
it('commits setOpenCreations to store', () => { it('commits setOpenCreations to store', () => {
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2) expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2)
}) })
@ -85,7 +86,7 @@ describe('CreationConfirm', () => {
describe('remove creation with success', () => { describe('remove creation with success', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 }) await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
}) })
it('calls the deletePendingCreation mutation', () => { it('calls the deletePendingCreation mutation', () => {
@ -107,7 +108,7 @@ describe('CreationConfirm', () => {
describe('remove creation with error', () => { describe('remove creation with error', () => {
beforeEach(async () => { beforeEach(async () => {
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' }) apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 }) await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
}) })
it('toasts an error message', () => { it('toasts an error message', () => {
@ -118,22 +119,52 @@ describe('CreationConfirm', () => {
describe('confirm creation with success', () => { describe('confirm creation with success', () => {
beforeEach(async () => { beforeEach(async () => {
apolloMutateMock.mockResolvedValue({}) apolloMutateMock.mockResolvedValue({})
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('confirm-creation', { id: 2 }) await wrapper.findAll('tr').at(2).findAll('button').at(2).trigger('click')
}) })
it('calls the confirmPendingCreation mutation', () => { describe('overlay', () => {
expect(apolloMutateMock).toBeCalledWith({ it('opens the overlay', () => {
mutation: confirmPendingCreation, expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
variables: { id: 2 },
}) })
})
it('commits openCreationsMinus to store', () => { describe('cancel confirmation', () => {
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) beforeEach(async () => {
}) await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
})
it('toasts a success message', () => { it('closes the overlay', () => {
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created') expect(wrapper.find('#overlay').isVisible()).toBeFalsy()
})
it('still has 2 items in the table', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(2)
})
})
describe('confirm creation', () => {
beforeEach(async () => {
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
})
it('calls the confirmPendingCreation mutation', () => {
expect(apolloMutateMock).toBeCalledWith({
mutation: confirmPendingCreation,
variables: { id: 2 },
})
})
it('commits openCreationsMinus to store', () => {
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
})
it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
})
it('has 1 item left in the table', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
})
})
}) })
}) })

View File

@ -88,100 +88,6 @@ describe('UserSearch', () => {
) )
}) })
describe('row toggling', () => {
it('has 4 users in the table', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(4)
})
describe('user with email not activated', () => {
it('has no details button', () => {
expect(
wrapper.findAll('tbody > tr').at(3).findAll('td').at(4).find('button').exists(),
).toBeFalsy()
})
it('has a red confirmed button with envelope item', () => {
const row = wrapper.findAll('tbody > tr').at(3)
expect(row.findAll('td').at(5).find('button').exists()).toBeTruthy()
expect(row.findAll('td').at(5).find('button').classes('btn-danger')).toBeTruthy()
expect(row.findAll('td').at(5).find('svg').classes('bi-envelope')).toBeTruthy()
})
describe('click on envelope', () => {
it('opens the details', async () => {
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
expect(wrapper.findAll('tbody > tr').at(5).find('input').element.value).toBe(
'new@user.ch',
)
expect(wrapper.findAll('tbody > tr').at(5).text()).toContain(
'unregister_mail.text_false',
)
})
describe('click on envelope again', () => {
it('closes the details', async () => {
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(4)
})
})
describe('click on close details', () => {
it('closes the details', async () => {
await wrapper
.findAll('tbody > tr')
.at(3)
.findAll('td')
.at(5)
.find('button')
.trigger('click')
await wrapper.findAll('tbody > tr').at(5).findAll('button').at(1).trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(4)
})
})
})
})
describe('different details', () => {
it.skip('shows the creation formular for second user', async () => {
await wrapper
.findAll('tbody > tr')
.at(1)
.findAll('td')
.at(4)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
expect(
wrapper.findAll('tbody > tr').at(3).find('div.component-creation-formular').exists(),
).toBeTruthy()
})
it.skip('shows the transactions for third user', async () => {
await wrapper
.findAll('tbody > tr')
.at(4)
.findAll('td')
.at(6)
.find('button')
.trigger('click')
expect(wrapper.findAll('tbody > tr')).toHaveLength(6)
})
})
})
describe('unconfirmed emails', () => { describe('unconfirmed emails', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.find('button.btn-block').trigger('click') await wrapper.find('button.btn-block').trigger('click')
@ -237,6 +143,23 @@ describe('UserSearch', () => {
}), }),
) )
}) })
describe('reset the search field', () => {
it('calls the API with empty criteria', async () => {
jest.clearAllMocks()
await wrapper.find('.test-click-clear-criteria').trigger('click')
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
notActivated: false,
},
}),
)
})
})
}) })
describe('apollo returns error', () => { describe('apollo returns error', () => {

View File

@ -7,12 +7,21 @@
</b-button> </b-button>
</div> </div>
<label>{{ $t('user_search') }}</label> <label>{{ $t('user_search') }}</label>
<b-input <div>
type="text" <b-input-group>
v-model="criteria" <b-form-input
class="shadow p-3 mb-3 bg-white rounded" type="text"
:placeholder="$t('user_search')" class="test-input-criteria"
></b-input> v-model="criteria"
:placeholder="$t('user_search')"
></b-form-input>
<b-input-group-append class="test-click-clear-criteria" @click="criteria = ''">
<b-input-group-text class="pointer">
<b-icon icon="x" />
</b-input-group-text>
</b-input-group-append>
</b-input-group>
</div>
<user-table type="PageUserSearch" :itemsUser="searchResult" :fieldsTable="fields" /> <user-table type="PageUserSearch" :itemsUser="searchResult" :fieldsTable="fields" />
<b-pagination <b-pagination
pills pills

View File

@ -69,6 +69,7 @@
"memo": "Nachricht", "memo": "Nachricht",
"message": "Nachricht", "message": "Nachricht",
"new_balance": "Neuer Kontostand nach Bestätigung", "new_balance": "Neuer Kontostand nach Bestätigung",
"no_gdd_available": "Du hast keine GDD zum versenden.",
"password": "Passwort", "password": "Passwort",
"passwordRepeat": "Passwort wiederholen", "passwordRepeat": "Passwort wiederholen",
"password_new": "Neues Passwort", "password_new": "Neues Passwort",

View File

@ -69,6 +69,7 @@
"memo": "Message", "memo": "Message",
"message": "Message", "message": "Message",
"new_balance": "Account balance after confirmation", "new_balance": "Account balance after confirmation",
"no_gdd_available": "You do not have GDD to send.",
"password": "Password", "password": "Password",
"passwordRepeat": "Repeat password", "passwordRepeat": "Repeat password",
"password_new": "New password", "password_new": "New password",

View File

@ -21,7 +21,7 @@ describe('GddSend', () => {
} }
const propsData = { const propsData = {
balance: 100.0, balance: 0.0,
} }
const Wrapper = () => { const Wrapper = () => {
@ -37,7 +37,44 @@ describe('GddSend', () => {
expect(wrapper.find('div.transaction-form').exists()).toBeTruthy() expect(wrapper.find('div.transaction-form').exists()).toBeTruthy()
}) })
describe('transaction form disable because balance 0,0 GDD', () => {
it('has a disabled input field of type email', () => {
expect(wrapper.find('#input-group-1').find('input').attributes('disabled')).toBe('disabled')
})
it('has a disabled input field for amount', () => {
expect(wrapper.find('#input-2').find('input').attributes('disabled')).toBe('disabled')
})
it('has a disabled textarea field ', () => {
expect(wrapper.find('#input-3').find('textarea').attributes('disabled')).toBe('disabled')
})
it('has a message indicating that there are no GDDs to send ', () => {
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()
})
})
describe('transaction form', () => { 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('.text-danger').exists()).toBeFalsy()
})
it('has a reset button', () => {
expect(wrapper.find('.test-buttons').findAll('button').at(0).attributes('type')).toBe(
'reset',
)
})
it('has a submit button', () => {
expect(wrapper.find('.test-buttons').findAll('button').at(1).attributes('type')).toBe(
'submit',
)
})
})
describe('email field', () => { describe('email field', () => {
it('has an input field of type email', () => { it('has an input field of type email', () => {
expect(wrapper.find('#input-group-1').find('input').attributes('type')).toBe('email') expect(wrapper.find('#input-group-1').find('input').attributes('type')).toBe('email')

View File

@ -41,6 +41,7 @@
placeholder="E-Mail" placeholder="E-Mail"
style="font-size: large" style="font-size: large"
class="pl-3" class="pl-3"
:disabled="isBalanceDisabled"
></b-form-input> ></b-form-input>
</b-input-group> </b-input-group>
<b-col v-if="errors"> <b-col v-if="errors">
@ -76,6 +77,7 @@
:placeholder="$n(0.01)" :placeholder="$n(0.01)"
style="font-size: large" style="font-size: large"
class="pl-3" class="pl-3"
:disabled="isBalanceDisabled"
></b-form-input> ></b-form-input>
</b-input-group> </b-input-group>
<b-col v-if="errors"> <b-col v-if="errors">
@ -105,6 +107,7 @@
v-model="form.memo" v-model="form.memo"
class="pl-3" class="pl-3"
style="font-size: large" style="font-size: large"
:disabled="isBalanceDisabled"
></b-form-textarea> ></b-form-textarea>
</b-input-group> </b-input-group>
<b-col v-if="errors"> <b-col v-if="errors">
@ -114,7 +117,10 @@
</div> </div>
<br /> <br />
<b-row> <div v-if="!!isBalanceDisabled" class="text-danger">
{{ $t('form.no_gdd_available') }}
</div>
<b-row v-else class="test-buttons">
<b-col> <b-col>
<b-button type="reset" variant="secondary" @click="onReset"> <b-button type="reset" variant="secondary" @click="onReset">
{{ $t('form.reset') }} {{ $t('form.reset') }}
@ -192,6 +198,11 @@ export default {
this.form.email = this.form.email.trim() this.form.email = this.form.email.trim()
}, },
}, },
computed: {
isBalanceDisabled() {
return this.balance <= 0 ? 'disabled' : false
},
},
} }
</script> </script>
<style> <style>