Merge branch 'master' into deploy-seed-in-backend

This commit is contained in:
Moriz Wahl 2022-04-20 08:34:51 +02:00 committed by GitHub
commit 1b3217a212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 348 additions and 261 deletions

View File

@ -49,30 +49,40 @@
<template #row-details="row">
<b-card ref="rowDetails" class="shadow-lg pl-3 pr-3 mb-5 bg-white rounded">
<creation-formular
v-if="!row.item.deletedAt"
type="singleCreation"
pagetype="singleCreation"
:creation="row.item.creation"
:item="row.item"
:creationUserData="creationUserData"
@update-user-data="updateUserData"
/>
<div v-else>{{ $t('userIsDeleted') }}</div>
<confirm-register-mail-formular
v-if="!row.item.deletedAt"
:checked="row.item.emailChecked"
:email="row.item.email"
:dateLastSend="
row.item.emailConfirmationSend
? $d(new Date(row.item.emailConfirmationSend), 'long')
: ''
"
/>
<creation-transaction-list v-if="!row.item.deletedAt" :userId="row.item.userId" />
<transaction-link-list :userId="row.item.userId" />
<deleted-user-formular :item="row.item" @updateDeletedAt="updateDeletedAt" />
<b-tabs content-class="mt-3">
<b-tab :title="$t('creation')" active :disabled="row.item.deletedAt !== null">
<creation-formular
v-if="!row.item.deletedAt"
type="singleCreation"
pagetype="singleCreation"
:creation="row.item.creation"
:item="row.item"
:creationUserData="creationUserData"
@update-user-data="updateUserData"
/>
</b-tab>
<b-tab :title="$t('e_mail')" :disabled="row.item.deletedAt !== null">
<confirm-register-mail-formular
v-if="!row.item.deletedAt"
:checked="row.item.emailChecked"
:email="row.item.email"
:dateLastSend="
row.item.emailConfirmationSend
? $d(new Date(row.item.emailConfirmationSend), 'long')
: ''
"
/>
</b-tab>
<b-tab :title="$t('creationList')" :disabled="row.item.deletedAt !== null">
<creation-transaction-list v-if="!row.item.deletedAt" :userId="row.item.userId" />
</b-tab>
<b-tab :title="$t('transactionlink.name')" :disabled="row.item.deletedAt !== null">
<transaction-link-list v-if="!row.item.deletedAt" :userId="row.item.userId" />
</b-tab>
<b-tab :title="$t('delete_user')">
<deleted-user-formular :item="row.item" @updateDeletedAt="updateDeletedAt" />
</b-tab>
</b-tabs>
</b-card>
</template>
</b-table>

View File

@ -1,7 +1,7 @@
<template>
<div class="transaction-link-list">
<div v-if="items.length > 0">
<div class="h3">{{ $t('transactionlink.form_header') }}</div>
<div class="h3">{{ $t('transactionlink.name') }}</div>
<b-table striped hover :fields="fields" :items="items"></b-table>
</div>
<b-pagination

View File

@ -2,6 +2,7 @@
"all_emails": "Alle Nutzer",
"back": "zurück",
"creation": "Schöpfung",
"creationList": "Schöpfungsliste",
"creation_form": {
"creation_failed": "Ausstehende Schöpfung für {email} konnte nicht erzeugt werden.",
"creation_for": "Aktives Grundeinkommen für",
@ -78,7 +79,7 @@
"text": "Text",
"transactionlink": {
"created": "Erstellt",
"form_header": "Transaktion-Links",
"name": "Transaktion-Links",
"valid_until": "Gültig bis"
},
"transactionlist": {
@ -100,7 +101,6 @@
"text_false": " Die letzte Email wurde am {date} Uhr an das Mitglied ({email}) gesendet.",
"text_true": " Die Email wurde bestätigt."
},
"userIsDeleted": "Der Nutzer ist gelöscht. Es können keine GDD mehr geschöpft werden.",
"user_deleted": "Nutzer ist gelöscht.",
"user_recovered": "Nutzer ist wiederhergestellt.",
"user_search": "Nutzer-Suche"

View File

@ -2,6 +2,7 @@
"all_emails": "All users",
"back": "back",
"creation": "Creation",
"creationList": "Creation list",
"creation_form": {
"creation_failed": "Could not create pending creation for {email}",
"creation_for": "Active Basic Income for",
@ -78,7 +79,7 @@
"text": "Text",
"transactionlink": {
"created": "Created",
"form_header": "Transaction links",
"name": "Transaction links",
"valid_until": "Valid until"
},
"transactionlist": {
@ -100,7 +101,6 @@
"text_false": "The last email was sent to the member ({email}) on {date}.",
"text_true": "The email was confirmed."
},
"userIsDeleted": "The user is deleted. No more GDD can be created.",
"user_deleted": "User is deleted.",
"user_recovered": "User is recovered.",
"user_search": "User search"

View File

@ -1,4 +1,4 @@
CONFIG_VERSION=v4.2022-04-05
CONFIG_VERSION=v5.2022-04-12
# Server
PORT=4000
@ -43,6 +43,7 @@ EMAIL_SMTP_PORT=587
EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{optin}{code}
EMAIL_LINK_SETPASSWORD=http://localhost/reset-password/{optin}
EMAIL_LINK_FORGOTPASSWORD=http://localhost/forgot-password
EMAIL_LINK_OVERVIEW=http://localhost/overview
EMAIL_CODE_VALID_TIME=1440
EMAIL_CODE_REQUEST_TIME=10

View File

@ -41,6 +41,7 @@ EMAIL_SMTP_URL=$EMAIL_SMTP_URL
EMAIL_SMTP_PORT=587
EMAIL_LINK_VERIFICATION=$EMAIL_LINK_VERIFICATION
EMAIL_LINK_SETPASSWORD=$EMAIL_LINK_SETPASSWORD
EMAIL_LINK_OVERVIEW=$EMAIL_LINK_OVERVIEW
EMAIL_CODE_VALID_TIME=$EMAIL_CODE_VALID_TIME
EMAIL_CODE_REQUEST_TIME=$EMAIL_CODE_REQUEST_TIME

View File

@ -14,7 +14,7 @@ const constants = {
DECAY_START_TIME: new Date('2021-05-13 17:46:31'), // GMT+0
CONFIG_VERSION: {
DEFAULT: 'DEFAULT',
EXPECTED: 'v4.2022-04-05',
EXPECTED: 'v5.2022-04-12',
CURRENT: '',
},
}
@ -72,6 +72,7 @@ const email = {
process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/reset-password/{optin}',
EMAIL_LINK_FORGOTPASSWORD:
process.env.EMAIL_LINK_FORGOTPASSWORD || 'http://localhost/forgot-password',
EMAIL_LINK_OVERVIEW: process.env.EMAIL_LINK_OVERVIEW || 'http://localhost/overview',
// time in minutes a optin code is valid
EMAIL_CODE_VALID_TIME: process.env.EMAIL_CODE_VALID_TIME
? parseInt(process.env.EMAIL_CODE_VALID_TIME) || 1440

View File

@ -1,6 +1,8 @@
/* eslint-disable new-cap */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import CONFIG from '@/config'
import { Context, getUser } from '@/server/context'
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
import { getCustomRepository, getConnection } from '@dbTools/typeorm'
@ -134,6 +136,7 @@ export const executeTransaction = async (
senderEmail: sender.email,
amount,
memo,
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
})
return true

View File

@ -20,6 +20,7 @@ describe('sendTransactionReceivedEmail', () => {
senderEmail: 'bibi@bloxberg.de',
amount: new Decimal(42.0),
memo: 'Vielen herzlichen Dank für den neuen Hexenbesen!',
overviewURL: 'http://localhost/overview',
})
})
@ -32,7 +33,8 @@ describe('sendTransactionReceivedEmail', () => {
expect.stringContaining('42,00 GDD') &&
expect.stringContaining('Bibi Bloxberg') &&
expect.stringContaining('(bibi@bloxberg.de)') &&
expect.stringContaining('Vielen herzlichen Dank für den neuen Hexenbesen!'),
expect.stringContaining('Vielen herzlichen Dank für den neuen Hexenbesen!') &&
expect.stringContaining('http://localhost/overview'),
})
})
})

View File

@ -11,6 +11,7 @@ export const sendTransactionReceivedEmail = (data: {
senderEmail: string
amount: Decimal
memo: string
overviewURL: string
}): Promise<boolean> => {
return sendEMail({
to: `${data.recipientFirstName} ${data.recipientLastName} <${data.email}>`,

View File

@ -12,6 +12,7 @@ export const transactionReceived = {
senderEmail: string
amount: Decimal
memo: string
overviewURL: string
}): string =>
`Hallo ${data.recipientFirstName} ${data.recipientLastName}
@ -25,6 +26,9 @@ ${data.memo}
Bitte antworte nicht auf diese E-Mail!
Mit freundlichen Grüßen,
dein Gradido-Team`,
dein Gradido-Team
Link zu deinem Konto: ${data.overviewURL}`,
},
}

View File

@ -18,7 +18,7 @@ WEBHOOK_GITHUB_SECRET=secret
WEBHOOK_GITHUB_BRANCH=master
# backend
BACKEND_CONFIG_VERSION=v4.2022-04-05
BACKEND_CONFIG_VERSION=v5.2022-04-12
JWT_EXPIRES_IN=30m
GDT_API_URL=https://gdt.gradido.net
@ -44,6 +44,7 @@ EMAIL_SMTP_URL=smtp.lustig.de
EMAIL_LINK_VERIFICATION=https://stage1.gradido.net/checkEmail/{optin}{code}
EMAIL_LINK_SETPASSWORD=https://stage1.gradido.net/reset-password/{optin}
EMAIL_LINK_FORGOTPASSWORD=https://stage1.gradido.net/forgot-password
EMAIL_LINK_OVERVIEW=https://stage1.gradido.net/overview
EMAIL_CODE_VALID_TIME=1440
EMAIL_CODE_REQUEST_TIME=10

View File

@ -81,6 +81,11 @@ sudo certbot
> No names were found in your configuration files. Please enter in your domain > stage1.gradido.net
# Note: this will throw an error regarding not beeing able to identify the nginx corresponding
# config but produce the required certificate - thats perfectly fine this way
# Troubleshoot: to manually renew a certificate with running nginx use the following command:
# (this might be required once to properly have things setup for the cron to autorenew)
# sudo certbot --nginx -d example.com -d www.example.com
# Troubleshoot: to check ut if things working you can use
# sudo certbot renew --dry-run
# Install logrotate
sudo apt-get install -y logrotate

View File

@ -1,24 +1,9 @@
import { mount } from '@vue/test-utils'
import { GdtEntryType } from '@/graphql/enums'
import GdtTransactionList from './GdtTransactionList'
import { toastErrorSpy } from '@test/testSetup'
import { GdtEntryType } from '@/graphql/enums'
const localVue = global.localVue
const apolloMock = jest.fn().mockResolvedValue({
data: {
listGDTEntries: {
count: 0,
gdtEntries: [],
},
},
})
const windowScrollToMock = jest.fn()
window.scrollTo = windowScrollToMock
const state = {
language: 'en',
}
@ -37,16 +22,20 @@ describe('GdtTransactionList ', () => {
$t: jest.fn((t) => t),
$n: jest.fn((n) => n),
$d: jest.fn((d) => d),
$apollo: {
query: apolloMock,
},
}
const propsData = {
transactionsGdt: [],
transactionGdtCount: 0,
pageSize: 25,
value: 1,
}
const Wrapper = () => {
return mount(GdtTransactionList, { localVue, mocks })
return mount(GdtTransactionList, { localVue, mocks, propsData })
}
describe('mount - When no transactions are loaded', () => {
describe('transactionGdtCount is 0', () => {
beforeEach(() => {
wrapper = Wrapper()
})
@ -62,54 +51,50 @@ describe('GdtTransactionList ', () => {
})
})
describe('mount - When transactions are loaded', () => {
beforeEach(() => {
apolloMock.mockResolvedValue({
data: {
listGDTEntries: {
count: 4,
gdtEntries: [
{
id: 1,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2021-05-02T17:20:11+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 2,
amount: 1810,
gdt: 362,
factor: 0.2,
comment: 'Dezember 20',
date: '2020-12-31T12:00:00+00:00',
gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR,
},
{
id: 3,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2020-05-07T17:00:00+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 4,
amount: 100,
gdt: 110,
factor: 22,
comment: '',
date: '2020-04-10T13:28:00+00:00',
gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER,
},
],
},
},
})
describe('Transactions are loaded', () => {
beforeEach(async () => {
wrapper = Wrapper()
await wrapper.setProps({
transactionGdtCount: 42,
transactionsGdt: [
{
id: 1,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2021-05-02T17:20:11+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 2,
amount: 1810,
gdt: 362,
factor: 0.2,
comment: 'Dezember 20',
date: '2020-12-31T12:00:00+00:00',
gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR,
},
{
id: 3,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2020-05-07T17:00:00+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 4,
amount: 100,
gdt: 110,
factor: 22,
comment: '',
date: '2020-04-10T13:28:00+00:00',
gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER,
},
],
})
})
it('renders the component', () => {
@ -120,83 +105,25 @@ describe('GdtTransactionList ', () => {
expect(wrapper.find('.gdt-funding').exists()).toBe(false)
})
describe('server returns valid data', () => {
it('calls the API', async () => {
await wrapper.vm.$nextTick()
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
currentPage: 1,
pageSize: 25,
},
}),
)
})
it('scrolls to (0, 0) after API call', () => {
expect(windowScrollToMock).toBeCalledWith(0, 0)
})
})
describe('server returns error', () => {
beforeEach(() => {
jest.resetAllMocks()
apolloMock.mockRejectedValue({
message: 'Ouch!',
})
wrapper = Wrapper()
})
it('toasts an error message', () => {
expect(toastErrorSpy).toBeCalledWith('Ouch!')
})
})
describe('change of currentPage', () => {
it('calls the API after currentPage changes', async () => {
jest.clearAllMocks()
await wrapper.setData({ transactionGdtCount: 42 })
await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2)
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
currentPage: 2,
pageSize: 25,
},
}),
)
expect(wrapper.emitted('input')).toEqual([[2]])
})
describe('pagination buttons', () => {
describe('with transactionCount > pageSize', () => {
beforeEach(async () => {
apolloMock.mockResolvedValue({
data: {
listGDTEntries: {
count: 42,
gdtEntries: [],
},
},
})
wrapper = Wrapper()
})
it('shows the pagination buttons', () => {
expect(wrapper.find('ul.pagination').exists()).toBe(true)
})
})
describe('with transactionCount < pageSize', () => {
beforeEach(async () => {
apolloMock.mockResolvedValue({
data: {
listGDTEntries: {
count: 2,
gdtEntries: [],
},
},
beforeEach(() => {
wrapper.setProps({
transactionGdtCount: 10,
})
wrapper = Wrapper()
})
it('shows no pagination buttons', () => {
@ -205,5 +132,17 @@ describe('GdtTransactionList ', () => {
})
})
})
describe('server not reachable', () => {
beforeEach(() => {
wrapper.setProps({
transactionGdtCount: -1,
})
})
it('renders the not-reachable text', () => {
expect(wrapper.text()).toBe('gdt.not-reachable')
})
})
})
})

View File

@ -8,7 +8,7 @@
{{ $t('gdt.funding') }}
</b-button>
</div>
<div v-else-if="typeof transactionGdtCount === 'object'" class="text-center">
<div v-else-if="transactionGdtCount === -1" class="text-center">
{{ $t('gdt.not-reachable') }}
</div>
<div
@ -41,7 +41,6 @@
</template>
<script>
import { listGDTEntriesQuery } from '@/graphql/queries'
import Transaction from '@/components/Transaction.vue'
export default {
@ -49,44 +48,24 @@ export default {
components: {
Transaction,
},
props: {
transactionsGdt: {
type: Array,
required: true,
},
transactionGdtCount: { type: Number, required: true },
pageSize: { type: Number, required: true },
value: { type: Number, required: true },
},
data() {
return {
transactionsGdt: [],
transactionGdtCount: { type: Number, default: 0 },
currentPage: 1,
pageSize: 25,
currentPage: this.value,
link: 'https://gradido.net/' + this.$store.state.language + '/memberships/',
}
},
methods: {
async updateGdt() {
this.$apollo
.query({
query: listGDTEntriesQuery,
variables: {
currentPage: this.currentPage,
pageSize: this.pageSize,
},
})
.then((result) => {
const {
data: { listGDTEntries },
} = result
this.transactionsGdt = listGDTEntries.gdtEntries
this.transactionGdtCount = listGDTEntries.count
window.scrollTo(0, 0)
})
.catch((error) => {
this.toastError(error.message)
})
},
},
mounted() {
this.updateGdt()
},
watch: {
currentPage() {
this.updateGdt()
if (this.value !== this.currentPage) this.$emit('input', this.currentPage)
},
},
}

View File

@ -124,16 +124,17 @@
"valid_until": "Gültig bis"
},
"gdt": {
"calculation": "Berechnung der GradidoTransform",
"calculation": "Berechnung der Gradido Transform",
"contribution": "Beitrag",
"conversion": "Umrechnung",
"conversion-gdt-euro": "Umrechnung Euro / GradidoTransform (GDT)",
"conversion-gdt-euro": "Umrechnung Euro / Gradido Transform (GDT)",
"credit": "Gutschrift",
"factor": "Faktor",
"formula": "Berechnungsformel",
"funding": "Zu den Förderbeiträgen",
"gdt-received": "GradidoTransform (GDT) erhalten",
"no-transactions": "Du hast noch keine GradidoTransform (GDT).",
"gdt": "Gradido Transform",
"gdt-received": "Gradido Transform (GDT) erhalten",
"no-transactions": "Du hast noch keine Gradido Transform (GDT).",
"not-reachable": "Der GDT Server ist nicht erreichbar.",
"publisher": "Dein geworbenes Mitglied hat einen Beitrag bezahlt",
"raise": "Erhöhung",

View File

@ -124,16 +124,17 @@
"valid_until": "Valid until"
},
"gdt": {
"calculation": "Calculation of GradidoTransform",
"calculation": "Calculation of Gradido Transform",
"contribution": "Contribution",
"conversion": "Conversion",
"conversion-gdt-euro": "Conversion Euro / GradidoTransform (GDT)",
"conversion-gdt-euro": "Conversion Euro / Gradido Transform (GDT)",
"credit": "Credit",
"factor": "Factor",
"formula": "Calculation formula",
"funding": "To the funding contributions",
"gdt-received": "GradidoTransform (GDT) received",
"no-transactions": "You do not have GradidoTransform (GDT) yet.",
"gdt": "Gradido Transform",
"gdt-received": "Gradido Transform (GDT) received",
"no-transactions": "You do not have Gradido Transform (GDT) yet.",
"not-reachable": "The GDT Server is not reachable.",
"publisher": "A member you referred has paid a contribution",
"raise": "Increase",

View File

@ -25,12 +25,6 @@ describe('Overview', () => {
wrapper = Wrapper()
})
it('has a status gdd-status-gdd', () => {
expect(wrapper.find('div.gdd-status-gdd').exists()).toBeTruthy()
})
it('has a status gdd-status-gdt', () => {
expect(wrapper.find('div.gdd-status-gdt').exists()).toBeTruthy()
})
it('has a transactions table', () => {
expect(wrapper.find('div.gdd-transaction-list').exists()).toBeTruthy()
})

View File

@ -1,19 +1,6 @@
<template>
<div>
<div class="container-fluid">
<b-row class="ml-1 mr-1 mb-2">
<b-col class="col-6 p-3 g-border">
<status class="gdd-status-gdd" :pending="pending" :balance="balance" status-text="GDD" />
</b-col>
<b-col class="col-6 p-3 text-right g-border">
<status
class="gdd-status-gdt"
:pending="pending"
:balance="GdtBalance"
status-text="GDT"
/>
</b-col>
</b-row>
<gdd-transaction-list
:transactions="transactions"
:pageSize="5"
@ -29,14 +16,12 @@
</div>
</template>
<script>
import Status from '@/components/Status.vue'
import GddTransactionList from '@/components/GddTransactionList.vue'
import GddTransactionListFooter from '@/components/GddTransactionListFooter.vue'
export default {
name: 'Overview',
components: {
Status,
GddTransactionList,
GddTransactionListFooter,
},
@ -46,8 +31,6 @@ export default {
}
},
props: {
balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 },
transactions: {
default: () => [],
},

View File

@ -1,28 +1,48 @@
import { mount } from '@vue/test-utils'
import Transactions from './Transactions'
import { GdtEntryType } from '@/graphql/enums'
import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue
window.scrollTo = jest.fn()
const windowScrollToMock = jest.fn()
window.scrollTo = windowScrollToMock
const apolloMock = jest.fn().mockResolvedValue({
data: {
listGDTEntries: {
count: 0,
gdtEntries: [],
},
},
})
describe('Transactions', () => {
let wrapper
const state = {
language: 'en',
}
const mocks = {
$store: {
state,
commit: jest.fn(),
},
$t: jest.fn((t) => t),
$n: jest.fn((n) => String(n)),
$d: jest.fn((d) => d),
$i18n: {
locale: jest.fn(() => 'en'),
},
}
const stubs = {
GdtTransactionList: true,
$apollo: {
query: apolloMock,
},
}
const Wrapper = () => {
return mount(Transactions, { localVue, mocks, stubs })
return mount(Transactions, { localVue, mocks })
}
describe('mount', () => {
@ -40,7 +60,7 @@ describe('Transactions', () => {
)
})
it('emist update-transactions when update-transactions is called', () => {
it('emits update-transactions when update-transactions is called', () => {
wrapper
.findComponent({ name: 'GddTransactionList' })
.vm.$emit('update-transactions', { currentPage: 2, pageSize: 25 })
@ -63,32 +83,129 @@ describe('Transactions', () => {
})
describe('click on GDT tab', () => {
beforeEach(() => {
wrapper.findAll('li[ role="presentation"]').at(1).find('a').trigger('click')
})
it('does not show the GDD transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(0).isVisible()).toBeFalsy()
})
it('shows the GDT transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(1).isVisible()).toBeTruthy()
})
describe('click on GDD tab', () => {
describe('server returns valid data', () => {
beforeEach(() => {
wrapper.findAll('li[ role="presentation"]').at(0).find('a').trigger('click')
apolloMock.mockResolvedValue({
data: {
listGDTEntries: {
count: 4,
gdtEntries: [
{
id: 1,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2021-05-02T17:20:11+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 2,
amount: 1810,
gdt: 362,
factor: 0.2,
comment: 'Dezember 20',
date: '2020-12-31T12:00:00+00:00',
gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR,
},
{
id: 3,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2020-05-07T17:00:00+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 4,
amount: 100,
gdt: 110,
factor: 22,
comment: '',
date: '2020-04-10T13:28:00+00:00',
gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER,
},
],
},
},
})
wrapper.findAll('li[ role="presentation"]').at(1).find('a').trigger('click')
})
it('shows the GDD transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(0).isVisible()).toBeTruthy()
it('does not show the GDD transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(0).isVisible()).toBeFalsy()
})
it('does not show the GDT', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(1).isVisible()).toBeFalsy()
it('shows the GDT transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(1).isVisible()).toBeTruthy()
})
it('calls the API', () => {
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
currentPage: 1,
pageSize: 25,
},
}),
)
})
it('scrolls to (0, 0) after API call', () => {
expect(windowScrollToMock).toBeCalledWith(0, 0)
})
describe('click on GDD tab', () => {
beforeEach(() => {
wrapper.findAll('li[ role="presentation"]').at(0).find('a').trigger('click')
})
it('shows the GDD transactions', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(0).isVisible()).toBeTruthy()
})
it('does not show the GDT', () => {
expect(wrapper.findAll('div[role="tabpanel"]').at(1).isVisible()).toBeFalsy()
})
})
})
describe('server returns error', () => {
beforeEach(() => {
apolloMock.mockRejectedValue({ message: 'Ouch!' })
wrapper.findAll('li[ role="presentation"]').at(1).find('a').trigger('click')
})
it('toasts an error message', () => {
expect(toastErrorSpy).toBeCalledWith('Ouch!')
})
it('sets transactionGdtCount to -1', () => {
expect(wrapper.vm.transactionGdtCount).toBe(-1)
})
})
})
})
describe('update currentPage', () => {
beforeEach(() => {
jest.clearAllMocks()
wrapper.setData({
currentPage: 2,
})
})
it('calls the API', () => {
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
currentPage: 2,
pageSize: 25,
},
}),
)
})
})
})
})

View File

@ -1,6 +1,6 @@
<template>
<div class="pb-4">
<b-tabs content-class="" justified>
<b-tabs v-model="tabIndex" content-class="" justified>
<b-tab :title="`Gradido (${$n(balance, 'decimal')} GDD)`" class="px-4">
<p class="tab-tex">{{ $t('transaction.gdd-text') }}</p>
@ -15,13 +15,17 @@
/>
</b-tab>
<b-tab
:title="`Gradido Transform (${GdtBalance === null ? '—' : $n(GdtBalance, 'decimal')} GDT)`"
class="px-4"
>
<p class="">{{ $t('transaction.gdt-text') }}</p>
<gdt-transaction-list />
<b-tab :title="titleGdt" class="px-4" @click="updateGdt()">
<b-row class="mb-3">
<b-col>{{ $t('transaction.gdt-text') }}</b-col>
<b-col class="text-right">{{ `${$n(GdtBalance, 'decimal')} GDT` }}</b-col>
</b-row>
<gdt-transaction-list
v-model="currentPage"
:transactionsGdt="transactionsGdt"
:transactionGdtCount="transactionGdtCount"
:pageSize="pageSize"
/>
</b-tab>
</b-tabs>
</div>
@ -29,6 +33,7 @@
<script>
import GddTransactionList from '@/components/GddTransactionList.vue'
import GdtTransactionList from '@/components/GdtTransactionList.vue'
import { listGDTEntriesQuery } from '@/graphql/queries'
export default {
name: 'Transactions',
@ -48,13 +53,52 @@ export default {
data() {
return {
timestamp: Date.now(),
transactionsGdt: [],
transactionGdtCount: 0,
currentPage: 1,
pageSize: 25,
tabIndex: 0,
}
},
methods: {
async updateGdt() {
this.$apollo
.query({
query: listGDTEntriesQuery,
variables: {
currentPage: this.currentPage,
pageSize: this.pageSize,
},
})
.then((result) => {
const {
data: { listGDTEntries },
} = result
this.transactionsGdt = listGDTEntries.gdtEntries
this.transactionGdtCount = listGDTEntries.count
window.scrollTo(0, 0)
})
.catch((error) => {
this.transactionGdtCount = -1
this.toastError(error.message)
})
},
updateTransactions(pagination) {
this.$emit('update-transactions', pagination)
},
},
computed: {
titleGdt(boolean) {
if (this.tabIndex === 1)
return `${this.$t('gdt.gdt')} (${this.$n(this.GdtBalance, 'decimal')} GDT)`
return this.$t('gdt.gdt')
},
},
watch: {
currentPage() {
this.updateGdt()
},
},
}
</script>
<style>