mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
rename query file and query, update specs
This commit is contained in:
parent
457cea4619
commit
a811b2bf2d
@ -1,6 +1,6 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const listAllContributions = gql`
|
||||
export const adminListAllContributions = gql`
|
||||
query (
|
||||
$currentPage: Int = 1
|
||||
$pageSize: Int = 25
|
||||
@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
|
||||
import CreationConfirm from './CreationConfirm'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { denyContribution } from '../graphql/denyContribution'
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
||||
import VueApollo from 'vue-apollo'
|
||||
@ -38,7 +38,7 @@ const mocks = {
|
||||
|
||||
const defaultData = () => {
|
||||
return {
|
||||
listAllContributions: {
|
||||
adminListAllContributions: {
|
||||
contributionCount: 2,
|
||||
contributionList: [
|
||||
{
|
||||
@ -97,7 +97,7 @@ describe('CreationConfirm', () => {
|
||||
const confirmContributionMock = jest.fn()
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
listAllContributions,
|
||||
adminListAllContributions,
|
||||
jest
|
||||
.fn()
|
||||
.mockRejectedValueOnce({ message: 'Ouch!' })
|
||||
@ -331,67 +331,93 @@ describe('CreationConfirm', () => {
|
||||
|
||||
describe('filter tabs', () => {
|
||||
describe('click tab "confirmed"', () => {
|
||||
let refetchSpy
|
||||
let requestIdCounter
|
||||
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch')
|
||||
requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId
|
||||
await wrapper.find('a[data-test="confirmed"]').trigger('click')
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe(
|
||||
`${Number(requestIdCounter) + 1}`,
|
||||
)
|
||||
})
|
||||
|
||||
it('has statusFilter set to ["CONFIRMED"]', () => {
|
||||
expect(
|
||||
wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables,
|
||||
).toMatchObject({ statusFilter: ['CONFIRMED'] })
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(refetchSpy).toBeCalled()
|
||||
})
|
||||
|
||||
describe('click tab "open"', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch')
|
||||
requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId
|
||||
await wrapper.find('a[data-test="open"]').trigger('click')
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe(
|
||||
`${Number(requestIdCounter) + 1}`,
|
||||
)
|
||||
})
|
||||
|
||||
it('has statusFilter set to ["IN_PROGRESS", "PENDING"]', () => {
|
||||
expect(
|
||||
wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables,
|
||||
).toMatchObject({ statusFilter: ['IN_PROGRESS', 'PENDING'] })
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(refetchSpy).toBeCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('click tab "denied"', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch')
|
||||
requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId
|
||||
await wrapper.find('a[data-test="denied"]').trigger('click')
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe(
|
||||
`${Number(requestIdCounter) + 1}`,
|
||||
)
|
||||
})
|
||||
|
||||
it('has statusFilter set to ["DENIED"]', () => {
|
||||
expect(
|
||||
wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables,
|
||||
).toMatchObject({ statusFilter: ['DENIED'] })
|
||||
})
|
||||
})
|
||||
|
||||
describe('click tab "deleted"', () => {
|
||||
beforeEach(async () => {
|
||||
requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId
|
||||
await wrapper.find('a[data-test="deleted"]').trigger('click')
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(refetchSpy).toBeCalled()
|
||||
expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe(
|
||||
`${Number(requestIdCounter) + 1}`,
|
||||
)
|
||||
})
|
||||
|
||||
it('has statusFilter set to ["DELETED"]', () => {
|
||||
expect(
|
||||
wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables,
|
||||
).toMatchObject({ statusFilter: ['DELETED'] })
|
||||
})
|
||||
})
|
||||
|
||||
describe('click tab "all"', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch')
|
||||
requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId
|
||||
await wrapper.find('a[data-test="all"]').trigger('click')
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe(
|
||||
`${Number(requestIdCounter) + 1}`,
|
||||
)
|
||||
})
|
||||
it('has statusFilter set to ["IN_PROGRESS", "PENDING", "CONFIRMED", "DENIED", "DELETED"]', () => {
|
||||
expect(
|
||||
wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables,
|
||||
@ -399,10 +425,6 @@ describe('CreationConfirm', () => {
|
||||
statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'],
|
||||
})
|
||||
})
|
||||
|
||||
it('refetches contributions', () => {
|
||||
expect(refetchSpy).toBeCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -412,10 +434,20 @@ describe('CreationConfirm', () => {
|
||||
await wrapper.findComponent({ name: 'OpenCreationsTable' }).vm.$emit('update-state', 2)
|
||||
})
|
||||
|
||||
it.skip('updates the status', () => {
|
||||
it('updates the status', () => {
|
||||
expect(wrapper.vm.items.find((obj) => obj.id === 2).messagesCount).toBe(1)
|
||||
expect(wrapper.vm.items.find((obj) => obj.id === 2).state).toBe('IN_PROGRESS')
|
||||
})
|
||||
})
|
||||
|
||||
describe('unknown variant', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({ variant: 'unknown' })
|
||||
})
|
||||
|
||||
it('has overlay icon "info"', () => {
|
||||
expect(wrapper.vm.overlayIcon).toBe('info')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<script>
|
||||
import Overlay from '../components/Overlay'
|
||||
import OpenCreationsTable from '../components/Tables/OpenCreationsTable'
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { denyContribution } from '../graphql/denyContribution'
|
||||
@ -384,7 +384,7 @@ export default {
|
||||
apollo: {
|
||||
ListAllContributions: {
|
||||
query() {
|
||||
return listAllContributions
|
||||
return adminListAllContributions
|
||||
},
|
||||
variables() {
|
||||
return {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Overview from './Overview'
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
||||
import VueApollo from 'vue-apollo'
|
||||
import { createMockClient } from 'mock-apollo-client'
|
||||
import { toastErrorSpy } from '../../test/testSetup'
|
||||
@ -30,7 +30,7 @@ const mocks = {
|
||||
|
||||
const defaultData = () => {
|
||||
return {
|
||||
listAllContributions: {
|
||||
adminListAllContributions: {
|
||||
contributionCount: 2,
|
||||
contributionList: [
|
||||
{
|
||||
@ -84,11 +84,11 @@ const defaultData = () => {
|
||||
|
||||
describe('Overview', () => {
|
||||
let wrapper
|
||||
const listAllContributionsMock = jest.fn()
|
||||
const adminListAllContributionsMock = jest.fn()
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
listAllContributions,
|
||||
listAllContributionsMock
|
||||
adminListAllContributions,
|
||||
adminListAllContributionsMock
|
||||
.mockRejectedValueOnce({ message: 'Ouch!' })
|
||||
.mockResolvedValue({ data: defaultData() }),
|
||||
)
|
||||
@ -109,8 +109,8 @@ describe('Overview', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('calls the listAllContributions query', () => {
|
||||
expect(listAllContributionsMock).toBeCalledWith({
|
||||
it('calls the adminListAllContributions query', () => {
|
||||
expect(adminListAllContributionsMock).toBeCalledWith({
|
||||
currentPage: 1,
|
||||
order: 'DESC',
|
||||
pageSize: 25,
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminListAllContributions } from '../graphql/adminListAllContributions'
|
||||
|
||||
export default {
|
||||
name: 'overview',
|
||||
@ -43,7 +43,7 @@ export default {
|
||||
apollo: {
|
||||
AllContributions: {
|
||||
query() {
|
||||
return listAllContributions
|
||||
return adminListAllContributions
|
||||
},
|
||||
variables() {
|
||||
// may be at some point we need a pagination here
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user