mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' of github.com:gradido/gradido into 2392-refactor-more-emails-to-translatables
This commit is contained in:
commit
a82f0a2864
@ -1,39 +0,0 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
|
||||||
import CommunityStatistic from './CommunityStatistic'
|
|
||||||
|
|
||||||
const localVue = global.localVue
|
|
||||||
|
|
||||||
const mocks = {
|
|
||||||
$t: jest.fn((t) => t),
|
|
||||||
$n: jest.fn((n) => n),
|
|
||||||
}
|
|
||||||
|
|
||||||
const propsData = {
|
|
||||||
value: {
|
|
||||||
totalUsers: '123',
|
|
||||||
activeUsers: '100',
|
|
||||||
deletedUsers: '5',
|
|
||||||
totalGradidoCreated: '2500',
|
|
||||||
totalGradidoDecayed: '200',
|
|
||||||
totalGradidoAvailable: '500',
|
|
||||||
totalGradidoUnbookedDecayed: '111',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('CommunityStatistic', () => {
|
|
||||||
let wrapper
|
|
||||||
|
|
||||||
const Wrapper = () => {
|
|
||||||
return mount(CommunityStatistic, { localVue, mocks, propsData })
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('mount', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = Wrapper()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('renders the Div Element ".community-statistic"', () => {
|
|
||||||
expect(wrapper.find('div.community-statistic').exists()).toBe(true)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="community-statistic">
|
|
||||||
<div>
|
|
||||||
<b-jumbotron bg-variant="info" text-variant="white" border-variant="dark">
|
|
||||||
<template #header>{{ $t('statistic.name') }}</template>
|
|
||||||
|
|
||||||
<hr class="my-4" />
|
|
||||||
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.totalUsers') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ value.totalUsers }}</b>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.activeUsers') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ value.activeUsers }}</b>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.deletedUsers') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ value.deletedUsers }}</b>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.totalGradidoCreated') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ $n(value.totalGradidoCreated, 'decimal') }} {{ $t('GDD') }}</b>
|
|
||||||
<small class="ml-5">{{ value.totalGradidoCreated }}</small>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.totalGradidoDecayed') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ $n(value.totalGradidoDecayed, 'decimal') }} {{ $t('GDD') }}</b>
|
|
||||||
<small class="ml-5">{{ value.totalGradidoDecayed }}</small>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.totalGradidoAvailable') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ $n(value.totalGradidoAvailable, 'decimal') }} {{ $t('GDD') }}</b>
|
|
||||||
<small class="ml-5">{{ value.totalGradidoAvailable }}</small>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ $t('statistic.totalGradidoUnbookedDecayed') }}{{ $t('math.colon') }}
|
|
||||||
<b>{{ $n(value.totalGradidoUnbookedDecayed, 'decimal') }} {{ $t('GDD') }}</b>
|
|
||||||
<small class="ml-5">{{ value.totalGradidoUnbookedDecayed }}</small>
|
|
||||||
</div>
|
|
||||||
</b-jumbotron>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import CONFIG from '@/config'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'CommunityStatistic',
|
|
||||||
props: {
|
|
||||||
value: { type: Object },
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
CONFIG,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@ -49,28 +49,36 @@ describe('NavBar', () => {
|
|||||||
it('has a link to overview', () => {
|
it('has a link to overview', () => {
|
||||||
expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/')
|
expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a link to /user', () => {
|
it('has a link to /user', () => {
|
||||||
expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe('/user')
|
expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe('/user')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a link to /creation', () => {
|
it('has a link to /creation', () => {
|
||||||
expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe('/creation')
|
expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe('/creation')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a link to /creation-confirm', () => {
|
it('has a link to /creation-confirm', () => {
|
||||||
expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe(
|
expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe(
|
||||||
'/creation-confirm',
|
'/creation-confirm',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a link to /contribution-links', () => {
|
it('has a link to /contribution-links', () => {
|
||||||
expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe(
|
expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe(
|
||||||
'/contribution-links',
|
'/contribution-links',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('has a link to /statistic', () => {
|
||||||
|
expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('/statistic')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('wallet', () => {
|
describe('wallet', () => {
|
||||||
const assignLocationSpy = jest.fn()
|
const assignLocationSpy = jest.fn()
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.findAll('.nav-item').at(5).find('a').trigger('click')
|
await wrapper.findAll('.nav-item').at(6).find('a').trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('changes window location to wallet', () => {
|
it.skip('changes window location to wallet', () => {
|
||||||
@ -89,7 +97,7 @@ describe('NavBar', () => {
|
|||||||
window.location = {
|
window.location = {
|
||||||
assign: windowLocationMock,
|
assign: windowLocationMock,
|
||||||
}
|
}
|
||||||
await wrapper.findAll('.nav-item').at(6).find('a').trigger('click')
|
await wrapper.findAll('.nav-item').at(7).find('a').trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('redirects to /logout', () => {
|
it('redirects to /logout', () => {
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
<b-nav-item to="/contribution-links">
|
<b-nav-item to="/contribution-links">
|
||||||
{{ $t('navbar.automaticContributions') }}
|
{{ $t('navbar.automaticContributions') }}
|
||||||
</b-nav-item>
|
</b-nav-item>
|
||||||
|
<b-nav-item to="/statistic">{{ $t('navbar.statistic') }}</b-nav-item>
|
||||||
<b-nav-item @click="wallet">{{ $t('navbar.my-account') }}</b-nav-item>
|
<b-nav-item @click="wallet">{{ $t('navbar.my-account') }}</b-nav-item>
|
||||||
<b-nav-item @click="logout">{{ $t('navbar.logout') }}</b-nav-item>
|
<b-nav-item @click="logout">{{ $t('navbar.logout') }}</b-nav-item>
|
||||||
</b-navbar-nav>
|
</b-navbar-nav>
|
||||||
|
|||||||
50
admin/src/components/Tables/StatisticTable.spec.js
Normal file
50
admin/src/components/Tables/StatisticTable.spec.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import StatisticTable from './StatisticTable.vue'
|
||||||
|
|
||||||
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
const propsData = {
|
||||||
|
value: {
|
||||||
|
totalUsers: 3113,
|
||||||
|
activeUsers: 1057,
|
||||||
|
deletedUsers: 35,
|
||||||
|
totalGradidoCreated: '4083774.05000000000000000000',
|
||||||
|
totalGradidoDecayed: '-1062639.13634129622923372197',
|
||||||
|
totalGradidoAvailable: '2513565.869444365732411569',
|
||||||
|
totalGradidoUnbookedDecayed: '-500474.6738366222166261272',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const mocks = {
|
||||||
|
$t: jest.fn((t) => t),
|
||||||
|
$n: jest.fn((n) => n),
|
||||||
|
$d: jest.fn((d) => d),
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('StatisticTable', () => {
|
||||||
|
let wrapper
|
||||||
|
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(StatisticTable, { localVue, mocks, propsData })
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a DIV element with the class .statistic-table', () => {
|
||||||
|
expect(wrapper.find('div.statistic-table').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('renders the table', () => {
|
||||||
|
it('with three colunms', () => {
|
||||||
|
expect(wrapper.findAll('thead > tr > th')).toHaveLength(3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('with seven rows', () => {
|
||||||
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(7)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
84
admin/src/components/Tables/StatisticTable.vue
Normal file
84
admin/src/components/Tables/StatisticTable.vue
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<!-- eslint-disable vue/no-static-inline-styles -->
|
||||||
|
<template>
|
||||||
|
<div class="statistic-table">
|
||||||
|
<b-table-simple style="width: auto" class="mt-5" striped stacked="md">
|
||||||
|
<b-thead>
|
||||||
|
<b-tr>
|
||||||
|
<b-th></b-th>
|
||||||
|
<b-th class="text-right">{{ $t('statistic.count') }}</b-th>
|
||||||
|
<b-th class="text-right">{{ $t('statistic.details') }}</b-th>
|
||||||
|
</b-tr>
|
||||||
|
</b-thead>
|
||||||
|
<b-tbody>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.totalUsers') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.totalUsers }}</b-td>
|
||||||
|
<b-td></b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.activeUsers') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.activeUsers }}</b-td>
|
||||||
|
<b-td></b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.deletedUsers') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.deletedUsers }}</b-td>
|
||||||
|
<b-td></b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.totalGradidoCreated') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">
|
||||||
|
{{ $n(value.totalGradidoCreated, 'decimal') }} {{ $t('GDD') }}
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.totalGradidoCreated }}</b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.totalGradidoDecayed') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">
|
||||||
|
{{ $n(value.totalGradidoDecayed, 'decimal') }} {{ $t('GDD') }}
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.totalGradidoDecayed }}</b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.totalGradidoAvailable') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">
|
||||||
|
{{ $n(value.totalGradidoAvailable, 'decimal') }} {{ $t('GDD') }}
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.totalGradidoAvailable }}</b-td>
|
||||||
|
</b-tr>
|
||||||
|
<b-tr>
|
||||||
|
<b-td>
|
||||||
|
<b>{{ $t('statistic.totalGradidoUnbookedDecayed') }}</b>
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">
|
||||||
|
{{ $n(value.totalGradidoUnbookedDecayed, 'decimal') }} {{ $t('GDD') }}
|
||||||
|
</b-td>
|
||||||
|
<b-td class="text-right">{{ value.totalGradidoUnbookedDecayed }}</b-td>
|
||||||
|
</b-tr>
|
||||||
|
</b-tbody>
|
||||||
|
</b-table-simple>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'StatisticTable',
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -85,7 +85,6 @@
|
|||||||
"hide_details": "Details verbergen",
|
"hide_details": "Details verbergen",
|
||||||
"lastname": "Nachname",
|
"lastname": "Nachname",
|
||||||
"math": {
|
"math": {
|
||||||
"colon": ":",
|
|
||||||
"equals": "=",
|
"equals": "=",
|
||||||
"exclaim": "!",
|
"exclaim": "!",
|
||||||
"pipe": "|",
|
"pipe": "|",
|
||||||
@ -104,6 +103,7 @@
|
|||||||
"my-account": "Mein Konto",
|
"my-account": "Mein Konto",
|
||||||
"open_creation": "Offene Schöpfungen",
|
"open_creation": "Offene Schöpfungen",
|
||||||
"overview": "Übersicht",
|
"overview": "Übersicht",
|
||||||
|
"statistic": "Statistik",
|
||||||
"user_search": "Nutzersuche"
|
"user_search": "Nutzersuche"
|
||||||
},
|
},
|
||||||
"not_open_creations": "Keine offenen Schöpfungen",
|
"not_open_creations": "Keine offenen Schöpfungen",
|
||||||
@ -125,8 +125,9 @@
|
|||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
"statistic": {
|
"statistic": {
|
||||||
"activeUsers": "Aktive Mitglieder",
|
"activeUsers": "Aktive Mitglieder",
|
||||||
|
"count": "Menge",
|
||||||
"deletedUsers": "Gelöschte Mitglieder",
|
"deletedUsers": "Gelöschte Mitglieder",
|
||||||
"name": "Statistik",
|
"details": "Details",
|
||||||
"totalGradidoAvailable": "GDD insgesamt im Umlauf",
|
"totalGradidoAvailable": "GDD insgesamt im Umlauf",
|
||||||
"totalGradidoCreated": "GDD insgesamt geschöpft",
|
"totalGradidoCreated": "GDD insgesamt geschöpft",
|
||||||
"totalGradidoDecayed": "GDD insgesamt verfallen",
|
"totalGradidoDecayed": "GDD insgesamt verfallen",
|
||||||
|
|||||||
@ -85,7 +85,6 @@
|
|||||||
"hide_details": "Hide details",
|
"hide_details": "Hide details",
|
||||||
"lastname": "Lastname",
|
"lastname": "Lastname",
|
||||||
"math": {
|
"math": {
|
||||||
"colon": ":",
|
|
||||||
"equals": "=",
|
"equals": "=",
|
||||||
"exclaim": "!",
|
"exclaim": "!",
|
||||||
"pipe": "|",
|
"pipe": "|",
|
||||||
@ -104,6 +103,7 @@
|
|||||||
"my-account": "My Account",
|
"my-account": "My Account",
|
||||||
"open_creation": "Open creations",
|
"open_creation": "Open creations",
|
||||||
"overview": "Overview",
|
"overview": "Overview",
|
||||||
|
"statistic": "Statistic",
|
||||||
"user_search": "User search"
|
"user_search": "User search"
|
||||||
},
|
},
|
||||||
"not_open_creations": "No open creations",
|
"not_open_creations": "No open creations",
|
||||||
@ -125,8 +125,9 @@
|
|||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
"statistic": {
|
"statistic": {
|
||||||
"activeUsers": "Active members",
|
"activeUsers": "Active members",
|
||||||
|
"count": "Count",
|
||||||
"deletedUsers": "Deleted members",
|
"deletedUsers": "Deleted members",
|
||||||
"name": "Statistic",
|
"details": "Details",
|
||||||
"totalGradidoAvailable": "Total GDD in circulation",
|
"totalGradidoAvailable": "Total GDD in circulation",
|
||||||
"totalGradidoCreated": "Total created GDD",
|
"totalGradidoCreated": "Total created GDD",
|
||||||
"totalGradidoDecayed": "Total GDD decay",
|
"totalGradidoDecayed": "Total GDD decay",
|
||||||
|
|||||||
98
admin/src/pages/CommunityStatistic.spec.js
Normal file
98
admin/src/pages/CommunityStatistic.spec.js
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import CommunityStatistic from './CommunityStatistic.vue'
|
||||||
|
import { communityStatistics } from '@/graphql/communityStatistics.js'
|
||||||
|
import { toastErrorSpy } from '../../test/testSetup'
|
||||||
|
import VueApollo from 'vue-apollo'
|
||||||
|
import { createMockClient } from 'mock-apollo-client'
|
||||||
|
|
||||||
|
const mockClient = createMockClient()
|
||||||
|
const apolloProvider = new VueApollo({
|
||||||
|
defaultClient: mockClient,
|
||||||
|
})
|
||||||
|
|
||||||
|
const localVue = global.localVue
|
||||||
|
localVue.use(VueApollo)
|
||||||
|
|
||||||
|
const defaultData = () => {
|
||||||
|
return {
|
||||||
|
communityStatistics: {
|
||||||
|
totalUsers: 3113,
|
||||||
|
activeUsers: 1057,
|
||||||
|
deletedUsers: 35,
|
||||||
|
totalGradidoCreated: '4083774.05000000000000000000',
|
||||||
|
totalGradidoDecayed: '-1062639.13634129622923372197',
|
||||||
|
totalGradidoAvailable: '2513565.869444365732411569',
|
||||||
|
totalGradidoUnbookedDecayed: '-500474.6738366222166261272',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mocks = {
|
||||||
|
$t: jest.fn((t) => t),
|
||||||
|
$n: jest.fn((n) => n),
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('CommunityStatistic', () => {
|
||||||
|
let wrapper
|
||||||
|
|
||||||
|
const communityStatisticsMock = jest.fn()
|
||||||
|
|
||||||
|
mockClient.setRequestHandler(
|
||||||
|
communityStatistics,
|
||||||
|
communityStatisticsMock
|
||||||
|
.mockRejectedValueOnce({ message: 'Ouch!' })
|
||||||
|
.mockResolvedValue({ data: defaultData() }),
|
||||||
|
)
|
||||||
|
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(CommunityStatistic, { localVue, mocks, apolloProvider })
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the Div Element ".community-statistic"', () => {
|
||||||
|
expect(wrapper.find('div.community-statistic').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('server response for get statistics is an error', () => {
|
||||||
|
it('toast an error message', () => {
|
||||||
|
expect(toastErrorSpy).toBeCalledWith('Ouch!')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('server response for getting statistics is success', () => {
|
||||||
|
it('renders the data correctly', () => {
|
||||||
|
expect(wrapper.findAll('tr').at(1).findAll('td').at(1).text()).toEqual('3113')
|
||||||
|
expect(wrapper.findAll('tr').at(2).findAll('td').at(1).text()).toEqual('1057')
|
||||||
|
expect(wrapper.findAll('tr').at(3).findAll('td').at(1).text()).toEqual('35')
|
||||||
|
expect(wrapper.findAll('tr').at(4).findAll('td').at(1).text()).toEqual(
|
||||||
|
'4083774.05000000000000000000 GDD',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(4).findAll('td').at(2).text()).toEqual(
|
||||||
|
'4083774.05000000000000000000',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(5).findAll('td').at(1).text()).toEqual(
|
||||||
|
'-1062639.13634129622923372197 GDD',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(5).findAll('td').at(2).text()).toEqual(
|
||||||
|
'-1062639.13634129622923372197',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(6).findAll('td').at(1).text()).toEqual(
|
||||||
|
'2513565.869444365732411569 GDD',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(6).findAll('td').at(2).text()).toEqual(
|
||||||
|
'2513565.869444365732411569',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(7).findAll('td').at(1).text()).toEqual(
|
||||||
|
'-500474.6738366222166261272 GDD',
|
||||||
|
)
|
||||||
|
expect(wrapper.findAll('tr').at(7).findAll('td').at(2).text()).toEqual(
|
||||||
|
'-500474.6738366222166261272',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
42
admin/src/pages/CommunityStatistic.vue
Normal file
42
admin/src/pages/CommunityStatistic.vue
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<div class="community-statistic">
|
||||||
|
<statistic-table v-model="statistics" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { communityStatistics } from '@/graphql/communityStatistics.js'
|
||||||
|
import StatisticTable from '../components/Tables/StatisticTable.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CommunityStatistic',
|
||||||
|
components: {
|
||||||
|
StatisticTable,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
statistics: {
|
||||||
|
totalUsers: null,
|
||||||
|
activeUsers: null,
|
||||||
|
deletedUsers: null,
|
||||||
|
totalGradidoCreated: null,
|
||||||
|
totalGradidoDecayed: null,
|
||||||
|
totalGradidoAvailable: null,
|
||||||
|
totalGradidoUnbookedDecayed: null,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
apollo: {
|
||||||
|
CommunityStatistics: {
|
||||||
|
query() {
|
||||||
|
return communityStatistics
|
||||||
|
},
|
||||||
|
update({ communityStatistics }) {
|
||||||
|
this.statistics = communityStatistics
|
||||||
|
},
|
||||||
|
error({ message }) {
|
||||||
|
this.toastError(message)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -1,6 +1,5 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import Overview from './Overview.vue'
|
import Overview from './Overview.vue'
|
||||||
import { communityStatistics } from '@/graphql/communityStatistics.js'
|
|
||||||
import { listUnconfirmedContributions } from '@/graphql/listUnconfirmedContributions.js'
|
import { listUnconfirmedContributions } from '@/graphql/listUnconfirmedContributions.js'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
@ -22,19 +21,6 @@ const apolloQueryMock = jest
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.mockResolvedValueOnce({
|
|
||||||
data: {
|
|
||||||
communityStatistics: {
|
|
||||||
totalUsers: 3113,
|
|
||||||
activeUsers: 1057,
|
|
||||||
deletedUsers: 35,
|
|
||||||
totalGradidoCreated: '4083774.05000000000000000000',
|
|
||||||
totalGradidoDecayed: '-1062639.13634129622923372197',
|
|
||||||
totalGradidoAvailable: '2513565.869444365732411569',
|
|
||||||
totalGradidoUnbookedDecayed: '-500474.6738366222166261272',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.mockResolvedValue({
|
.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
listUnconfirmedContributions: [
|
listUnconfirmedContributions: [
|
||||||
@ -88,14 +74,6 @@ describe('Overview', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls communityStatistics', () => {
|
|
||||||
expect(apolloQueryMock).toBeCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
query: communityStatistics,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('commits three pending creations to store', () => {
|
it('commits three pending creations to store', () => {
|
||||||
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 3)
|
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 3)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -28,32 +28,13 @@
|
|||||||
</b-link>
|
</b-link>
|
||||||
</b-card-text>
|
</b-card-text>
|
||||||
</b-card>
|
</b-card>
|
||||||
<community-statistic class="mt-5" v-model="statistics" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { communityStatistics } from '@/graphql/communityStatistics.js'
|
|
||||||
import CommunityStatistic from '../components/CommunityStatistic.vue'
|
|
||||||
import { listUnconfirmedContributions } from '@/graphql/listUnconfirmedContributions.js'
|
import { listUnconfirmedContributions } from '@/graphql/listUnconfirmedContributions.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'overview',
|
name: 'overview',
|
||||||
components: {
|
|
||||||
CommunityStatistic,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
statistics: {
|
|
||||||
totalUsers: null,
|
|
||||||
activeUsers: null,
|
|
||||||
deletedUsers: null,
|
|
||||||
totalGradidoCreated: null,
|
|
||||||
totalGradidoDecayed: null,
|
|
||||||
totalGradidoAvailable: null,
|
|
||||||
totalGradidoUnbookedDecayed: null,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
getPendingCreations() {
|
getPendingCreations() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
@ -65,30 +46,9 @@ export default {
|
|||||||
this.$store.commit('setOpenCreations', result.data.listUnconfirmedContributions.length)
|
this.$store.commit('setOpenCreations', result.data.listUnconfirmedContributions.length)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getCommunityStatistics() {
|
|
||||||
this.$apollo
|
|
||||||
.query({
|
|
||||||
query: communityStatistics,
|
|
||||||
})
|
|
||||||
.then((result) => {
|
|
||||||
this.statistics.totalUsers = result.data.communityStatistics.totalUsers
|
|
||||||
this.statistics.activeUsers = result.data.communityStatistics.activeUsers
|
|
||||||
this.statistics.deletedUsers = result.data.communityStatistics.deletedUsers
|
|
||||||
this.statistics.totalGradidoCreated = result.data.communityStatistics.totalGradidoCreated
|
|
||||||
this.statistics.totalGradidoDecayed = result.data.communityStatistics.totalGradidoDecayed
|
|
||||||
this.statistics.totalGradidoAvailable =
|
|
||||||
result.data.communityStatistics.totalGradidoAvailable
|
|
||||||
this.statistics.totalGradidoUnbookedDecayed =
|
|
||||||
result.data.communityStatistics.totalGradidoUnbookedDecayed
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.toastError('communityStatistics has no result, use default data')
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getPendingCreations()
|
this.getPendingCreations()
|
||||||
this.getCommunityStatistics()
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -44,8 +44,8 @@ describe('router', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('routes', () => {
|
describe('routes', () => {
|
||||||
it('has seven routes defined', () => {
|
it('has nine routes defined', () => {
|
||||||
expect(routes).toHaveLength(8)
|
expect(routes).toHaveLength(9)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has "/overview" as default', async () => {
|
it('has "/overview" as default', async () => {
|
||||||
@ -82,12 +82,19 @@ describe('router', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('contribution-links', () => {
|
describe('contribution-links', () => {
|
||||||
it('loads the "ContributionLinks" component', async () => {
|
it('loads the "ContributionLinks" page', async () => {
|
||||||
const component = await routes.find((r) => r.path === '/contribution-links').component()
|
const component = await routes.find((r) => r.path === '/contribution-links').component()
|
||||||
expect(component.default.name).toBe('ContributionLinks')
|
expect(component.default.name).toBe('ContributionLinks')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('statistics', () => {
|
||||||
|
it('loads the "CommunityStatistic" page', async () => {
|
||||||
|
const component = await routes.find((r) => r.path === '/statistic').component()
|
||||||
|
expect(component.default.name).toBe('CommunityStatistic')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('not found page', () => {
|
describe('not found page', () => {
|
||||||
it('renders the "NotFound" component', async () => {
|
it('renders the "NotFound" component', async () => {
|
||||||
const component = await routes.find((r) => r.path === '*').component()
|
const component = await routes.find((r) => r.path === '*').component()
|
||||||
|
|||||||
@ -6,6 +6,10 @@ const routes = [
|
|||||||
path: '/',
|
path: '/',
|
||||||
component: () => import('@/pages/Overview.vue'),
|
component: () => import('@/pages/Overview.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/statistic',
|
||||||
|
component: () => import('@/pages/CommunityStatistic.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// TODO: Implement a "You are logged out"-Page
|
// TODO: Implement a "You are logged out"-Page
|
||||||
path: '/logout',
|
path: '/logout',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user