mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
rename admin list all contributions query
This commit is contained in:
parent
36ac1387c4
commit
e48bbd7b47
@ -1,13 +1,13 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const adminListAllContributions = gql`
|
export const adminListContributions = gql`
|
||||||
query (
|
query (
|
||||||
$currentPage: Int = 1
|
$currentPage: Int = 1
|
||||||
$pageSize: Int = 25
|
$pageSize: Int = 25
|
||||||
$order: Order = DESC
|
$order: Order = DESC
|
||||||
$statusFilter: [ContributionStatus!]
|
$statusFilter: [ContributionStatus!]
|
||||||
) {
|
) {
|
||||||
adminListAllContributions(
|
adminListContributions(
|
||||||
currentPage: $currentPage
|
currentPage: $currentPage
|
||||||
pageSize: $pageSize
|
pageSize: $pageSize
|
||||||
order: $order
|
order: $order
|
||||||
@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
|
|||||||
import CreationConfirm from './CreationConfirm'
|
import CreationConfirm from './CreationConfirm'
|
||||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||||
import { denyContribution } from '../graphql/denyContribution'
|
import { denyContribution } from '../graphql/denyContribution'
|
||||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
import { adminListContributions } from '../graphql/adminListContributions'
|
||||||
import { confirmContribution } from '../graphql/confirmContribution'
|
import { confirmContribution } from '../graphql/confirmContribution'
|
||||||
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
||||||
import VueApollo from 'vue-apollo'
|
import VueApollo from 'vue-apollo'
|
||||||
@ -38,7 +38,7 @@ const mocks = {
|
|||||||
|
|
||||||
const defaultData = () => {
|
const defaultData = () => {
|
||||||
return {
|
return {
|
||||||
adminListAllContributions: {
|
adminListContributions: {
|
||||||
contributionCount: 2,
|
contributionCount: 2,
|
||||||
contributionList: [
|
contributionList: [
|
||||||
{
|
{
|
||||||
@ -92,14 +92,14 @@ const defaultData = () => {
|
|||||||
|
|
||||||
describe('CreationConfirm', () => {
|
describe('CreationConfirm', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
const adminListAllContributionsMock = jest.fn()
|
const adminListContributionsMock = jest.fn()
|
||||||
const adminDeleteContributionMock = jest.fn()
|
const adminDeleteContributionMock = jest.fn()
|
||||||
const adminDenyContributionMock = jest.fn()
|
const adminDenyContributionMock = jest.fn()
|
||||||
const confirmContributionMock = jest.fn()
|
const confirmContributionMock = jest.fn()
|
||||||
|
|
||||||
mockClient.setRequestHandler(
|
mockClient.setRequestHandler(
|
||||||
adminListAllContributions,
|
adminListContributions,
|
||||||
adminListAllContributionsMock
|
adminListContributionsMock
|
||||||
.mockRejectedValueOnce({ message: 'Ouch!' })
|
.mockRejectedValueOnce({ message: 'Ouch!' })
|
||||||
.mockResolvedValue({ data: defaultData() }),
|
.mockResolvedValue({ data: defaultData() }),
|
||||||
)
|
)
|
||||||
@ -337,7 +337,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('refetches contributions with proper filter', () => {
|
it('refetches contributions with proper filter', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
@ -352,7 +352,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('refetches contributions with proper filter', () => {
|
it('refetches contributions with proper filter', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
@ -368,7 +368,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('refetches contributions with proper filter', () => {
|
it('refetches contributions with proper filter', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
@ -384,7 +384,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('refetches contributions with proper filter', () => {
|
it('refetches contributions with proper filter', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
@ -400,7 +400,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('refetches contributions with proper filter', () => {
|
it('refetches contributions with proper filter', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
|
|||||||
@ -73,7 +73,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Overlay from '../components/Overlay'
|
import Overlay from '../components/Overlay'
|
||||||
import OpenCreationsTable from '../components/Tables/OpenCreationsTable'
|
import OpenCreationsTable from '../components/Tables/OpenCreationsTable'
|
||||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
import { adminListContributions } from '../graphql/adminListContributions'
|
||||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||||
import { confirmContribution } from '../graphql/confirmContribution'
|
import { confirmContribution } from '../graphql/confirmContribution'
|
||||||
import { denyContribution } from '../graphql/denyContribution'
|
import { denyContribution } from '../graphql/denyContribution'
|
||||||
@ -384,7 +384,7 @@ export default {
|
|||||||
apollo: {
|
apollo: {
|
||||||
ListAllContributions: {
|
ListAllContributions: {
|
||||||
query() {
|
query() {
|
||||||
return adminListAllContributions
|
return adminListContributions
|
||||||
},
|
},
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
@ -394,9 +394,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
update({ adminListAllContributions }) {
|
update({ adminListContributions }) {
|
||||||
this.rows = adminListAllContributions.contributionCount
|
this.rows = adminListContributions.contributionCount
|
||||||
this.items = adminListAllContributions.contributionList
|
this.items = adminListContributions.contributionList
|
||||||
},
|
},
|
||||||
error({ message }) {
|
error({ message }) {
|
||||||
this.toastError(message)
|
this.toastError(message)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import Overview from './Overview'
|
import Overview from './Overview'
|
||||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
import { adminListContributions } from '../graphql/adminListContributions'
|
||||||
import VueApollo from 'vue-apollo'
|
import VueApollo from 'vue-apollo'
|
||||||
import { createMockClient } from 'mock-apollo-client'
|
import { createMockClient } from 'mock-apollo-client'
|
||||||
import { toastErrorSpy } from '../../test/testSetup'
|
import { toastErrorSpy } from '../../test/testSetup'
|
||||||
@ -30,7 +30,7 @@ const mocks = {
|
|||||||
|
|
||||||
const defaultData = () => {
|
const defaultData = () => {
|
||||||
return {
|
return {
|
||||||
adminListAllContributions: {
|
adminListContributions: {
|
||||||
contributionCount: 2,
|
contributionCount: 2,
|
||||||
contributionList: [
|
contributionList: [
|
||||||
{
|
{
|
||||||
@ -84,11 +84,11 @@ const defaultData = () => {
|
|||||||
|
|
||||||
describe('Overview', () => {
|
describe('Overview', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
const adminListAllContributionsMock = jest.fn()
|
const adminListContributionsMock = jest.fn()
|
||||||
|
|
||||||
mockClient.setRequestHandler(
|
mockClient.setRequestHandler(
|
||||||
adminListAllContributions,
|
adminListContributions,
|
||||||
adminListAllContributionsMock
|
adminListContributionsMock
|
||||||
.mockRejectedValueOnce({ message: 'Ouch!' })
|
.mockRejectedValueOnce({ message: 'Ouch!' })
|
||||||
.mockResolvedValue({ data: defaultData() }),
|
.mockResolvedValue({ data: defaultData() }),
|
||||||
)
|
)
|
||||||
@ -109,8 +109,8 @@ describe('Overview', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the adminListAllContributions query', () => {
|
it('calls the adminListContributions query', () => {
|
||||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
expect(adminListContributionsMock).toBeCalledWith({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
order: 'DESC',
|
order: 'DESC',
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
import { adminListContributions } from '../graphql/adminListContributions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'overview',
|
name: 'overview',
|
||||||
@ -43,7 +43,7 @@ export default {
|
|||||||
apollo: {
|
apollo: {
|
||||||
AllContributions: {
|
AllContributions: {
|
||||||
query() {
|
query() {
|
||||||
return adminListAllContributions
|
return adminListContributions
|
||||||
},
|
},
|
||||||
variables() {
|
variables() {
|
||||||
// may be at some point we need a pagination here
|
// may be at some point we need a pagination here
|
||||||
@ -51,8 +51,8 @@ export default {
|
|||||||
statusFilter: this.statusFilter,
|
statusFilter: this.statusFilter,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update({ adminListAllContributions }) {
|
update({ adminListContributions }) {
|
||||||
this.$store.commit('setOpenCreations', adminListAllContributions.contributionCount)
|
this.$store.commit('setOpenCreations', adminListContributions.contributionCount)
|
||||||
},
|
},
|
||||||
error({ message }) {
|
error({ message }) {
|
||||||
this.toastError(message)
|
this.toastError(message)
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export enum RIGHTS {
|
|||||||
ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION',
|
ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION',
|
||||||
ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION',
|
ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION',
|
||||||
ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION',
|
ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION',
|
||||||
LIST_UNCONFIRMED_CONTRIBUTIONS = 'LIST_UNCONFIRMED_CONTRIBUTIONS',
|
ADMIN_LIST_CONTRIBUTIONS = 'ADMIN_LIST_CONTRIBUTIONS',
|
||||||
CONFIRM_CONTRIBUTION = 'CONFIRM_CONTRIBUTION',
|
CONFIRM_CONTRIBUTION = 'CONFIRM_CONTRIBUTION',
|
||||||
SEND_ACTIVATION_EMAIL = 'SEND_ACTIVATION_EMAIL',
|
SEND_ACTIVATION_EMAIL = 'SEND_ACTIVATION_EMAIL',
|
||||||
CREATION_TRANSACTION_LIST = 'CREATION_TRANSACTION_LIST',
|
CREATION_TRANSACTION_LIST = 'CREATION_TRANSACTION_LIST',
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
listAllContributions,
|
listAllContributions,
|
||||||
listContributions,
|
listContributions,
|
||||||
adminListAllContributions,
|
adminListContributions,
|
||||||
} from '@/seeds/graphql/queries'
|
} from '@/seeds/graphql/queries'
|
||||||
import {
|
import {
|
||||||
sendContributionConfirmedEmail,
|
sendContributionConfirmedEmail,
|
||||||
@ -2656,12 +2656,12 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('adminListAllContribution', () => {
|
describe('adminListContributions', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('returns an error', async () => {
|
it('returns an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: adminListAllContributions,
|
query: adminListContributions,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -2686,7 +2686,7 @@ describe('ContributionResolver', () => {
|
|||||||
it('returns an error', async () => {
|
it('returns an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: adminListAllContributions,
|
query: adminListContributions,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -2710,9 +2710,9 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('returns 17 creations in total', async () => {
|
it('returns 17 creations in total', async () => {
|
||||||
const {
|
const {
|
||||||
data: { adminListAllContributions: contributionListObject },
|
data: { adminListContributions: contributionListObject },
|
||||||
}: { data: { adminListAllContributions: ContributionListResult } } = await query({
|
}: { data: { adminListContributions: ContributionListResult } } = await query({
|
||||||
query: adminListAllContributions,
|
query: adminListContributions,
|
||||||
})
|
})
|
||||||
expect(contributionListObject.contributionList).toHaveLength(17)
|
expect(contributionListObject.contributionList).toHaveLength(17)
|
||||||
expect(contributionListObject).toMatchObject({
|
expect(contributionListObject).toMatchObject({
|
||||||
@ -2877,9 +2877,9 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('returns two pending creations with page size set to 2', async () => {
|
it('returns two pending creations with page size set to 2', async () => {
|
||||||
const {
|
const {
|
||||||
data: { adminListAllContributions: contributionListObject },
|
data: { adminListContributions: contributionListObject },
|
||||||
}: { data: { adminListAllContributions: ContributionListResult } } = await query({
|
}: { data: { adminListContributions: ContributionListResult } } = await query({
|
||||||
query: adminListAllContributions,
|
query: adminListContributions,
|
||||||
variables: {
|
variables: {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 2,
|
pageSize: 2,
|
||||||
|
|||||||
@ -376,9 +376,9 @@ export class ContributionResolver {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.LIST_UNCONFIRMED_CONTRIBUTIONS])
|
@Authorized([RIGHTS.ADMIN_LIST_CONTRIBUTIONS])
|
||||||
@Query(() => ContributionListResult) // [UnconfirmedContribution]
|
@Query(() => ContributionListResult)
|
||||||
async adminListAllContributions(
|
async adminListContributions(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 3, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 3, order = Order.DESC }: Paginated,
|
||||||
@Arg('statusFilter', () => [ContributionStatus], { nullable: true })
|
@Arg('statusFilter', () => [ContributionStatus], { nullable: true })
|
||||||
|
|||||||
@ -204,14 +204,14 @@ query ($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC, $statusF
|
|||||||
`
|
`
|
||||||
// from admin interface
|
// from admin interface
|
||||||
|
|
||||||
export const adminListAllContributions = gql`
|
export const adminListContributions = gql`
|
||||||
query (
|
query (
|
||||||
$currentPage: Int = 1
|
$currentPage: Int = 1
|
||||||
$pageSize: Int = 25
|
$pageSize: Int = 25
|
||||||
$order: Order = DESC
|
$order: Order = DESC
|
||||||
$statusFilter: [ContributionStatus!]
|
$statusFilter: [ContributionStatus!]
|
||||||
) {
|
) {
|
||||||
adminListAllContributions(
|
adminListContributions(
|
||||||
currentPage: $currentPage
|
currentPage: $currentPage
|
||||||
pageSize: $pageSize
|
pageSize: $pageSize
|
||||||
order: $order
|
order: $order
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user