From af19e31178a339f47097c77869a9127d6e45ade4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Apr 2023 14:32:30 +0200 Subject: [PATCH 01/22] fix(backend): posts in groups cannot be pinned --- backend/src/schema/resolvers/posts.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index d806f3803..063b2210d 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -310,6 +310,7 @@ export default { ` MATCH (user:User {id: $userId}) WHERE user.role = 'admin' MATCH (post:Post {id: $params.id}) + WHERE NOT((post)-[:IN]->(:Group)) MERGE (user)-[pinned:PINNED {createdAt: toString(datetime())}]->(post) SET post.pinned = true RETURN post, pinned.createdAt as pinnedAt @@ -322,10 +323,12 @@ export default { })) }) const [transactionResult] = await writeTxResultPromise - const { pinnedPost, pinnedAt } = transactionResult - pinnedPostWithNestedAttributes = { - ...pinnedPost, - pinnedAt, + if (transactionResult) { + const { pinnedPost, pinnedAt } = transactionResult + pinnedPostWithNestedAttributes = { + ...pinnedPost, + pinnedAt, + } } } finally { session.close() From b672b62e0df42804d6c72bd363eb52800590132a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Apr 2023 14:33:51 +0200 Subject: [PATCH 02/22] no pin post button for posts in group --- webapp/components/ContentMenu/ContentMenu.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/components/ContentMenu/ContentMenu.vue b/webapp/components/ContentMenu/ContentMenu.vue index 60bcccf43..d723a9667 100644 --- a/webapp/components/ContentMenu/ContentMenu.vue +++ b/webapp/components/ContentMenu/ContentMenu.vue @@ -80,7 +80,7 @@ export default { }) } - if (this.isAdmin) { + if (this.isAdmin && !this.resource.group) { if (!this.resource.pinnedBy) { routes.push({ label: this.$t(`post.menu.pin`), From bed693b073ffb5c07e2d907eff6696459d775f1b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 24 Apr 2023 15:49:24 +0200 Subject: [PATCH 03/22] feat(backend): filter posts by post type --- .../src/schema/resolvers/filter-posts.spec.js | 159 ++++++++++++++++++ backend/src/schema/types/type/Post.gql | 1 + 2 files changed, 160 insertions(+) create mode 100644 backend/src/schema/resolvers/filter-posts.spec.js diff --git a/backend/src/schema/resolvers/filter-posts.spec.js b/backend/src/schema/resolvers/filter-posts.spec.js new file mode 100644 index 000000000..b3109dbe4 --- /dev/null +++ b/backend/src/schema/resolvers/filter-posts.spec.js @@ -0,0 +1,159 @@ +import { createTestClient } from 'apollo-server-testing' +import Factory, { cleanDatabase } from '../../db/factories' +import { getNeode, getDriver } from '../../db/neo4j' +import createServer from '../../server' +import CONFIG from '../../config' +import { filterPosts, createPostMutation } from '../../graphql/posts' + +CONFIG.CATEGORIES_ACTIVE = false + +const driver = getDriver() +const neode = getNeode() + +let query +let mutate +let authenticatedUser +let user + +beforeAll(async () => { + await cleanDatabase() + + const { server } = createServer({ + context: () => { + return { + driver, + neode, + user: authenticatedUser, + } + }, + }) + query = createTestClient(server).query + mutate = createTestClient(server).mutate +}) + +afterAll(async () => { + await cleanDatabase() + driver.close() +}) + +describe('Filter Posts', () => { + const now = new Date() + + beforeAll(async () => { + user = await Factory.build('user', { + id: 'user', + name: 'User', + about: 'I am a user.', + }) + authenticatedUser = await user.toJson() + await mutate({ + mutation: createPostMutation(), + variables: { + id: 'a1', + title: 'I am an article', + content: 'I am an article written by user.', + }, + }) + await mutate({ + mutation: createPostMutation(), + variables: { + id: 'a2', + title: 'I am anonther article', + content: 'I am another article written by user.', + }, + }) + await mutate({ + mutation: createPostMutation(), + variables: { + id: 'e1', + title: 'Illegaler Kindergeburtstag', + content: 'Elli wird fünf. Wir feiern ihren Geburtstag.', + postType: 'Event', + eventInput: { + eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), + eventVenue: 'Garten der Familie Maier', + }, + }, + }) + await mutate({ + mutation: createPostMutation(), + variables: { + id: 'e2', + title: 'Räuber-Treffen', + content: 'Planung der nächsten Räuberereien', + postType: 'Event', + eventInput: { + eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).toISOString(), + eventVenue: 'Wirtshaus im Spessart', + }, + }, + }) + }) + + describe('no filters set', () => { + it('finds all posts', async () => { + const { + data: { Post: result }, + } = await query({ query: filterPosts() }) + expect(result).toHaveLength(4) + expect(result).toEqual( + expect.arrayContaining([ + expect.objectContaining({ id: 'a1' }), + expect.objectContaining({ id: 'a2' }), + expect.objectContaining({ id: 'e1' }), + expect.objectContaining({ id: 'e2' }), + ]), + ) + }) + }) + + describe('post type filter set to ["Article"]', () => { + it('finds the articles', async () => { + const { + data: { Post: result }, + } = await query({ query: filterPosts(), variables: { filter: { postType_in: ['Article'] } } }) + expect(result).toHaveLength(2) + expect(result).toEqual( + expect.arrayContaining([ + expect.objectContaining({ id: 'a1' }), + expect.objectContaining({ id: 'a2' }), + ]), + ) + }) + }) + + describe('post type filter set to ["Event"]', () => { + it('finds the articles', async () => { + const { + data: { Post: result }, + } = await query({ query: filterPosts(), variables: { filter: { postType_in: ['Event'] } } }) + expect(result).toHaveLength(2) + expect(result).toEqual( + expect.arrayContaining([ + expect.objectContaining({ id: 'e1' }), + expect.objectContaining({ id: 'e2' }), + ]), + ) + }) + }) + + describe('post type filter set to ["Article", "Event"]', () => { + it('finds the articles', async () => { + const { + data: { Post: result }, + } = await query({ + query: filterPosts(), + variables: { filter: { postType_in: ['Article', 'Event'] } }, + }) + expect(result).toHaveLength(4) + expect(result).toEqual( + expect.arrayContaining([ + expect.objectContaining({ id: 'a1' }), + expect.objectContaining({ id: 'a2' }), + expect.objectContaining({ id: 'e1' }), + expect.objectContaining({ id: 'e2' }), + ]), + ) + }) + }) +}) diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 22d7c1d5c..988e2b81d 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -83,6 +83,7 @@ input _PostFilter { emotions_every: _PostEMOTEDFilter group: _GroupFilter postsInMyGroups: Boolean + postType_in: [PostType] } enum _PostOrdering { From e69c036c8036da19d75981f54c7fb1c277128a00 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 24 Apr 2023 16:21:50 +0200 Subject: [PATCH 04/22] order events by event date, filter outdated events --- backend/src/graphql/posts.js | 1 + .../src/schema/resolvers/filter-posts.spec.js | 73 ++++++++++++++++++- backend/src/schema/types/type/Post.gql | 3 + 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/posts.js b/backend/src/graphql/posts.js index 7d57b8510..d1dc3ee45 100644 --- a/backend/src/graphql/posts.js +++ b/backend/src/graphql/posts.js @@ -72,6 +72,7 @@ export const filterPosts = () => { id title content + eventStart } } ` diff --git a/backend/src/schema/resolvers/filter-posts.spec.js b/backend/src/schema/resolvers/filter-posts.spec.js index b3109dbe4..0b96e001f 100644 --- a/backend/src/schema/resolvers/filter-posts.spec.js +++ b/backend/src/schema/resolvers/filter-posts.spec.js @@ -138,7 +138,7 @@ describe('Filter Posts', () => { }) describe('post type filter set to ["Article", "Event"]', () => { - it('finds the articles', async () => { + it('finds all posts', async () => { const { data: { Post: result }, } = await query({ @@ -156,4 +156,75 @@ describe('Filter Posts', () => { ) }) }) + + describe('order events by event start descending', () => { + it('finds the events orderd accordingly', async () => { + const { + data: { Post: result }, + } = await query({ + query: filterPosts(), + variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_desc'] }, + }) + expect(result).toHaveLength(2) + expect(result).toEqual([ + expect.objectContaining({ + id: 'e1', + eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), + }), + expect.objectContaining({ + id: 'e2', + eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).toISOString(), + }), + ]) + }) + }) + + describe('order events by event start ascending', () => { + it('finds the events orderd accordingly', async () => { + const { + data: { Post: result }, + } = await query({ + query: filterPosts(), + variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_asc'] }, + }) + expect(result).toHaveLength(2) + expect(result).toEqual([ + expect.objectContaining({ + id: 'e2', + eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).toISOString(), + }), + expect.objectContaining({ + id: 'e1', + eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), + }), + ]) + }) + }) + + describe('filter events by event start date', () => { + it('finds only events after given date', async () => { + const { + data: { Post: result }, + } = await query({ + query: filterPosts(), + variables: { + filter: { + postType_in: ['Event'], + eventStart_gte: new Date( + now.getFullYear(), + now.getMonth(), + now.getDate() + 2, + ).toISOString(), + }, + }, + }) + expect(result).toHaveLength(1) + expect(result).toEqual([ + expect.objectContaining({ + id: 'e1', + eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), + }), + ]) + }) + }) }) diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 988e2b81d..548f3d5aa 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -84,6 +84,7 @@ input _PostFilter { group: _GroupFilter postsInMyGroups: Boolean postType_in: [PostType] + eventStart_gte: String } enum _PostOrdering { @@ -105,6 +106,8 @@ enum _PostOrdering { language_desc pinned_asc pinned_desc + eventStart_asc + eventStart_desc } From 4091045de6db35f05bb60682760d4a07869418b9 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 24 Apr 2023 17:12:56 +0200 Subject: [PATCH 05/22] fix tests (include eventStart) --- .../schema/resolvers/postsInGroups.spec.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/backend/src/schema/resolvers/postsInGroups.spec.js b/backend/src/schema/resolvers/postsInGroups.spec.js index 86a278207..ba9041090 100644 --- a/backend/src/schema/resolvers/postsInGroups.spec.js +++ b/backend/src/schema/resolvers/postsInGroups.spec.js @@ -818,11 +818,13 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, ]), }, @@ -846,11 +848,13 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, ]), }, @@ -874,11 +878,13 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, ]), }, @@ -902,11 +908,13 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, ]), }, @@ -930,21 +938,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1319,16 +1331,19 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, ]), }, @@ -1361,21 +1376,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1410,16 +1429,19 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1452,11 +1474,13 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, ]), }, @@ -1489,21 +1513,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1534,21 +1562,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1579,21 +1611,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1628,21 +1664,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1675,21 +1715,25 @@ describe('Posts in Groups', () => { id: 'post-to-public-group', title: 'A post to a public group', content: 'I am posting into a public group as a member of the group', + eventStart: null, }, { id: 'post-without-group', title: 'A post without a group', content: 'I am a user who does not belong to a group yet.', + eventStart: null, }, { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, @@ -1739,11 +1783,13 @@ describe('Posts in Groups', () => { id: 'post-to-closed-group', title: 'A post to a closed group', content: 'I am posting into a closed group as a member of the group', + eventStart: null, }, { id: 'post-to-hidden-group', title: 'A post to a hidden group', content: 'I am posting into a hidden group as a member of the group', + eventStart: null, }, ]), }, From a10916fc1415d8f8d6c6ab4fd5c12f9b18cccf38 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:15:16 +0200 Subject: [PATCH 06/22] remove falsy values, but do not limit characters --- backend/src/schema/resolvers/searches/queryString.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/schema/resolvers/searches/queryString.js b/backend/src/schema/resolvers/searches/queryString.js index 5ef84cdce..0045f1c22 100644 --- a/backend/src/schema/resolvers/searches/queryString.js +++ b/backend/src/schema/resolvers/searches/queryString.js @@ -33,7 +33,7 @@ const matchSomeWordsExactly = (str, boost = 2) => { const matchBeginningOfWords = (str) => { return str .split(' ') - .filter((s) => s.length > 3) + .filter((s) => s) // remove falsy values .map((s) => s + '*') .join(' ') } From ca24cf44050342415baef54da3fe86ab9f7ea0e4 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:19:15 +0200 Subject: [PATCH 07/22] simplyfy logic, use language ahortcuts --- backend/src/schema/resolvers/searches.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/schema/resolvers/searches.js b/backend/src/schema/resolvers/searches.js index 3fdf22da3..3001a28b3 100644 --- a/backend/src/schema/resolvers/searches.js +++ b/backend/src/schema/resolvers/searches.js @@ -223,8 +223,7 @@ export default { }, searchResults: async (_parent, args, context, _resolveInfo) => { const { query, limit } = args - let userId = null - if (context.user) userId = context.user.id + let userId = context.user?.id || null const searchType = query.replace(/^([!@#&]?).*$/, '$1') const searchString = query.replace(/^([!@#&])/, '') From 6025706b4b2c2bfc8cbb51658f2b40d081698222 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:19:50 +0200 Subject: [PATCH 08/22] fix searchableInput field component to properly retrigger search on delete, clear properly etc --- .../generic/SearchableInput/SearchableInput.vue | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index 2149732c5..8397cccbf 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -14,9 +14,8 @@ :auto-reset-search="!searchValue" :placeholder="$t('search.placeholder')" @focus.capture.native="onFocus" - @input.native="handleInput" + @input.native="onInput" @keyup.enter.native="onEnter" - @keyup.delete.native="onDelete" @keyup.esc.native="clear" @blur.capture.native="onBlur" @input.exact="onSelect" @@ -103,11 +102,14 @@ export default { onFocus(event) { clearTimeout(this.searchProcess) }, - handleInput(event) { + onInput(event) { + console.log('input', event) clearTimeout(this.searchProcess) this.value = event.target ? event.target.value.replace(/\s+/g, ' ').trim() : '' + console.log('input', this.value) this.unprocessedSearchInput = this.value if (isEmpty(this.value) || this.value.replace(/\s+/g, '').length < 3) { + this.clear() return } this.searchProcess = setTimeout(() => { @@ -122,15 +124,6 @@ export default { }) this.$emit('clearSearch') }, - onDelete(event) { - clearTimeout(this.searchProcess) - const value = event.target ? event.target.value.trim() : '' - if (isEmpty(value)) { - this.clear() - } else { - this.handleInput(event) - } - }, clear() { this.unprocessedSearchInput = '' this.previousSearchTerm = '' From 33d5758686722128d411450680cefa6af52a5a67 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:35:43 +0200 Subject: [PATCH 09/22] removed comments --- webapp/components/generic/SearchableInput/SearchableInput.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index 8397cccbf..45ea33bab 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -103,10 +103,8 @@ export default { clearTimeout(this.searchProcess) }, onInput(event) { - console.log('input', event) clearTimeout(this.searchProcess) this.value = event.target ? event.target.value.replace(/\s+/g, ' ').trim() : '' - console.log('input', this.value) this.unprocessedSearchInput = this.value if (isEmpty(this.value) || this.value.replace(/\s+/g, '').length < 3) { this.clear() From c7fbe9beef8c1dca3549b673e4111dccaa7d9fb5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:36:01 +0200 Subject: [PATCH 10/22] removed test for onDelete event --- .../generic/SearchableInput/SearchableInput.spec.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.spec.js b/webapp/components/generic/SearchableInput/SearchableInput.spec.js index cda9150b8..223ee6186 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.spec.js +++ b/webapp/components/generic/SearchableInput/SearchableInput.spec.js @@ -63,13 +63,6 @@ describe('SearchableInput.vue', () => { expect(select.element.value).toBe('abcd') }) - it('calls onDelete when the delete key is pressed', () => { - const spy = jest.spyOn(wrapper.vm, 'onDelete') - select.trigger('input') - select.trigger('keyup.delete') - expect(spy).toHaveBeenCalledTimes(1) - }) - describe('navigating to resource', () => { beforeEach(() => { propsData = { options: searchResults } From 4a5c56203b877d166f5667c5e5f9e8ddc488727c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 02:44:46 +0200 Subject: [PATCH 11/22] simplified searchableInput further - fixed on Enter --- .../components/generic/SearchableInput/SearchableInput.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index 45ea33bab..bc349c9f6 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -78,7 +78,6 @@ export default { return { searchValue: '', value: '', - unprocessedSearchInput: '', searchProcess: null, previousSearchTerm: '', delay: 300, @@ -105,7 +104,6 @@ export default { onInput(event) { clearTimeout(this.searchProcess) this.value = event.target ? event.target.value.replace(/\s+/g, ' ').trim() : '' - this.unprocessedSearchInput = this.value if (isEmpty(this.value) || this.value.replace(/\s+/g, '').length < 3) { this.clear() return @@ -118,12 +116,11 @@ export default { onEnter(event) { this.$router.push({ path: '/search/search-results', - query: { search: this.unprocessedSearchInput }, + query: { search: this.value }, }) this.$emit('clearSearch') }, clear() { - this.unprocessedSearchInput = '' this.previousSearchTerm = '' this.searchValue = '' this.$emit('clearSearch') From 536ef92132fba043d1add9225e56a81cf7765b3b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 03:44:51 +0200 Subject: [PATCH 12/22] more simplifications --- .../SearchableInput/SearchableInput.vue | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index bc349c9f6..c27b16b66 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -1,9 +1,10 @@