From f6c78c59ece310fc77aa3f1e2d8b95edc9354713 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 27 Mar 2025 14:42:45 +0100 Subject: [PATCH] refactor graphl queries to load only what is really needed --- .../ContributionMessagesList.spec.js | 18 ++++- .../ContributionMessagesList.vue | 8 +- .../CreationTransactionList.spec.js | 16 ++-- .../components/CreationTransactionList.vue | 16 ++-- .../graphql/adminListContributions.graphql | 73 +++++++++++++++++++ admin/src/graphql/adminListContributions.js | 52 ------------- admin/src/graphql/fragments.graphql | 9 ++- admin/src/pages/CreationConfirm.vue | 19 +++-- admin/src/pages/Overview.spec.js | 10 ++- admin/src/pages/Overview.vue | 10 ++- 10 files changed, 146 insertions(+), 85 deletions(-) create mode 100644 admin/src/graphql/adminListContributions.graphql delete mode 100644 admin/src/graphql/adminListContributions.js diff --git a/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js b/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js index bbb2f3806..46773c7d8 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js +++ b/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js @@ -68,6 +68,16 @@ const defaultData = { }, } +const defaultUser = { + firstName: 'Peter', + lastName: 'Lustig', + humhubUsername: 'peter.lustig', + createdAt: new Date().toString(), + emailContact: { + email: 'peter.lustig@example.com', + }, +} + describe('ContributionMessagesList', () => { let wrapper let mockMessages @@ -98,6 +108,7 @@ describe('ContributionMessagesList', () => { memo: 'test memo', userId: 108, status: 'PENDING', + user: defaultUser, }, hideResubmission: true, }, @@ -139,7 +150,12 @@ describe('ContributionMessagesList', () => { }) it('does not render the ContributionMessagesFormular when status is not PENDING or IN_PROGRESS', async () => { - await wrapper.setProps({ contribution: { status: 'COMPLETED' } }) + await wrapper.setProps({ + contribution: { + status: 'COMPLETED', + user: defaultUser, + }, + }) expect(wrapper.find('contribution-messages-formular-stub').exists()).toBe(false) }) diff --git a/admin/src/components/ContributionMessages/ContributionMessagesList.vue b/admin/src/components/ContributionMessages/ContributionMessagesList.vue index 9b0d11cbe..3ba3b0b56 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesList.vue +++ b/admin/src/components/ContributionMessages/ContributionMessagesList.vue @@ -3,16 +3,16 @@ - {{ contribution.firstName }} {{ contribution.lastName }} + {{ contribution.user.firstName }} {{ contribution.user.lastName }}   - {{ contribution.email }} + {{ contribution.user.emailContact.email }} {{ $t('filter.byEmail') }}   - {{ contribution.username }} + {{ contribution.user.humhubUsername }}   - {{ $t('registered') }}: {{ new Date(contribution.createdAt).toLocaleString() }} + {{ $t('registered') }}: {{ new Date(contribution.user.createdAt).toLocaleString() }} diff --git a/admin/src/components/CreationTransactionList.spec.js b/admin/src/components/CreationTransactionList.spec.js index fa626ab32..4b6b43b66 100644 --- a/admin/src/components/CreationTransactionList.spec.js +++ b/admin/src/components/CreationTransactionList.spec.js @@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils' import { describe, it, expect, beforeEach, vi } from 'vitest' import CreationTransactionList from './CreationTransactionList.vue' import { useQuery } from '@vue/apollo-composable' -import { adminListContributions } from '../graphql/adminListContributions' +import { adminListContributionsShort } from '../graphql/adminListContributions.graphql' import { useI18n } from 'vue-i18n' import { useAppToast } from '@/composables/useToast' @@ -65,13 +65,17 @@ describe('CreationTransactionList', () => { it('calls useQuery with correct parameters', () => { expect(useQuery).toHaveBeenCalled() const call = useQuery.mock.calls[0] - expect(call[0]).toBe(adminListContributions) + expect(call[0]).toBe(adminListContributionsShort) expect(call[1]).toEqual( expect.objectContaining({ - currentPage: expect.any(Number), - pageSize: expect.any(Number), - order: 'DESC', - userId: 1, + filter: { + userId: 1, + }, + paginated: { + currentPage: expect.any(Number), + pageSize: expect.any(Number), + order: 'DESC', + }, }), ) }) diff --git a/admin/src/components/CreationTransactionList.vue b/admin/src/components/CreationTransactionList.vue index 9eeb9055a..09dd41901 100644 --- a/admin/src/components/CreationTransactionList.vue +++ b/admin/src/components/CreationTransactionList.vue @@ -45,7 +45,7 @@