Merge branch 'master' into 1400-No-GDD-value-when-reloading-User-Profile

This commit is contained in:
Alexander Friedland 2022-02-04 18:44:10 +01:00 committed by GitHub
commit 45338b37f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 23 deletions

View File

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

View File

@ -241,17 +241,38 @@ describe('Creation', () => {
jest.clearAllMocks()
})
it('calls API when criteria changes', async () => {
await wrapper.setData({ criteria: 'XX' })
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: 'XX',
currentPage: 1,
pageSize: 25,
},
}),
)
describe('search criteria', () => {
beforeEach(async () => {
await wrapper.setData({ criteria: 'XX' })
})
it('calls API when criteria changes', async () => {
expect(apolloQueryMock).toBeCalledWith(
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 () => {

View File

@ -3,12 +3,20 @@
<b-row>
<b-col cols="12" lg="6">
<label>Usersuche</label>
<b-input
type="text"
v-model="criteria"
class="shadow p-3 mb-5 bg-white rounded"
placeholder="User suche"
></b-input>
<b-input-group>
<b-form-input
type="text"
class="test-input-criteria"
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>
<user-table
v-if="itemsList.length > 0"
type="UserListSearch"

View File

@ -143,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', () => {

View File

@ -7,12 +7,21 @@
</b-button>
</div>
<label>{{ $t('user_search') }}</label>
<b-input
type="text"
v-model="criteria"
class="shadow p-3 mb-3 bg-white rounded"
:placeholder="$t('user_search')"
></b-input>
<div>
<b-input-group>
<b-form-input
type="text"
class="test-input-criteria"
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" />
<b-pagination
pills