Merge branch 'master' into 2428-feature-federation-implement-multiple-apollo-graphql-endpoints

This commit is contained in:
clauspeterhuebner 2023-01-13 14:21:20 +01:00 committed by GitHub
commit db6d18da1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 266 additions and 215 deletions

View File

@ -437,7 +437,7 @@ jobs:
report_name: Coverage Frontend
type: lcov
result_path: ./coverage/lcov.info
min_coverage: 89
min_coverage: 91
token: ${{ github.token }}
##############################################################################

View File

@ -35,6 +35,7 @@ export enum RIGHTS {
SEARCH_ADMIN_USERS = 'SEARCH_ADMIN_USERS',
CREATE_CONTRIBUTION_MESSAGE = 'CREATE_CONTRIBUTION_MESSAGE',
LIST_ALL_CONTRIBUTION_MESSAGES = 'LIST_ALL_CONTRIBUTION_MESSAGES',
OPEN_CREATIONS = 'OPEN_CREATIONS',
// Admin
SEARCH_USERS = 'SEARCH_USERS',
SET_USER_ROLE = 'SET_USER_ROLE',

View File

@ -33,6 +33,7 @@ export const ROLE_USER = new Role('user', [
RIGHTS.COMMUNITY_STATISTICS,
RIGHTS.CREATE_CONTRIBUTION_MESSAGE,
RIGHTS.LIST_ALL_CONTRIBUTION_MESSAGES,
RIGHTS.OPEN_CREATIONS,
])
export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights

View File

@ -0,0 +1,14 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ObjectType()
export class OpenCreation {
@Field(() => Int)
month: number
@Field(() => Int)
year: number
@Field(() => Decimal)
amount: Decimal
}

View File

@ -1,13 +1,11 @@
import { ObjectType, Field } from 'type-graphql'
import { KlickTipp } from './KlickTipp'
import { User as dbUser } from '@entity/User'
import Decimal from 'decimal.js-light'
import { FULL_CREATION_AVAILABLE } from '../resolver/const/const'
import { UserContact } from './UserContact'
@ObjectType()
export class User {
constructor(user: dbUser, creation: Decimal[] = FULL_CREATION_AVAILABLE) {
constructor(user: dbUser) {
this.id = user.id
this.gradidoID = user.gradidoID
this.alias = user.alias
@ -26,7 +24,6 @@ export class User {
this.isAdmin = user.isAdmin
this.klickTipp = null
this.hasElopage = null
this.creation = creation
this.hideAmountGDD = user.hideAmountGDD
this.hideAmountGDT = user.hideAmountGDT
}
@ -34,9 +31,6 @@ export class User {
@Field(() => Number)
id: number
// `public_key` binary(32) DEFAULT NULL,
// `privkey` binary(80) DEFAULT NULL,
@Field(() => String)
gradidoID: string
@ -62,9 +56,6 @@ export class User {
@Field(() => Date, { nullable: true })
deletedAt: Date | null
// `password` bigint(20) unsigned DEFAULT 0,
// `email_hash` binary(32) DEFAULT NULL,
@Field(() => Date)
createdAt: Date
@ -84,8 +75,6 @@ export class User {
@Field(() => Number, { nullable: true })
publisherId: number | null
// `passphrase` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@Field(() => Date, { nullable: true })
isAdmin: Date | null
@ -94,7 +83,4 @@ export class User {
@Field(() => Boolean, { nullable: true })
hasElopage: boolean | null
@Field(() => [Decimal])
creation: Decimal[]
}

View File

@ -11,8 +11,9 @@ import { Transaction as DbTransaction } from '@entity/Transaction'
import { AdminCreateContributions } from '@model/AdminCreateContributions'
import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
import { Contribution, ContributionListResult } from '@model/Contribution'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import { Decay } from '@model/Decay'
import { OpenCreation } from '@model/OpenCreation'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import { TransactionTypeId } from '@enum/TransactionTypeId'
import { Order } from '@enum/Order'
import { ContributionType } from '@enum/ContributionType'
@ -27,6 +28,7 @@ import { RIGHTS } from '@/auth/RIGHTS'
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import { backendLogger as logger } from '@/server/logger'
import {
getCreationDates,
getUserCreation,
getUserCreations,
validateContribution,
@ -691,4 +693,23 @@ export class ContributionResolver {
)
// return userTransactions.map((t) => new Transaction(t, new User(user), communityUser))
}
@Authorized([RIGHTS.OPEN_CREATIONS])
@Query(() => [OpenCreation])
async openCreations(
@Arg('userId', () => Int, { nullable: true }) userId: number | null,
@Ctx() context: Context,
): Promise<OpenCreation[]> {
const id = userId || getUser(context).id
const clientTimezoneOffset = getClientTimezoneOffset(context)
const creationDates = getCreationDates(clientTimezoneOffset)
const creations = await getUserCreation(id, clientTimezoneOffset)
return creationDates.map((date, index) => {
return {
month: date.getMonth(),
year: date.getFullYear(),
amount: creations[index],
}
})
}
}

View File

@ -58,7 +58,7 @@ import {
EventSendConfirmationEmail,
EventActivateAccount,
} from '@/event/Event'
import { getUserCreation, getUserCreations } from './util/creations'
import { getUserCreations } from './util/creations'
import { isValidPassword } from '@/password/EncryptorUtils'
import { FULL_CREATION_AVAILABLE } from './const/const'
import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor'
@ -114,9 +114,8 @@ export class UserResolver {
async verifyLogin(@Ctx() context: Context): Promise<User> {
logger.info('verifyLogin...')
// TODO refactor and do not have duplicate code with login(see below)
const clientTimezoneOffset = getClientTimezoneOffset(context)
const userEntity = getUser(context)
const user = new User(userEntity, await getUserCreation(userEntity.id, clientTimezoneOffset))
const user = new User(userEntity)
// Elopage Status & Stored PublisherId
user.hasElopage = await this.hasElopage(context)
@ -132,7 +131,6 @@ export class UserResolver {
@Ctx() context: Context,
): Promise<User> {
logger.info(`login with ${email}, ***, ${publisherId} ...`)
const clientTimezoneOffset = getClientTimezoneOffset(context)
email = email.trim().toLowerCase()
const dbUser = await findUserByEmail(email)
if (dbUser.deletedAt) {
@ -163,7 +161,7 @@ export class UserResolver {
logger.addContext('user', dbUser.id)
logger.debug('validation of login credentials successful...')
const user = new User(dbUser, await getUserCreation(dbUser.id, clientTimezoneOffset))
const user = new User(dbUser)
logger.debug(`user= ${JSON.stringify(user, null, 2)}`)
i18n.setLocale(user.language)

View File

@ -101,15 +101,19 @@ export const getUserCreation = async (
}
const getCreationMonths = (timezoneOffset: number): number[] => {
return getCreationDates(timezoneOffset).map((date) => date.getMonth() + 1)
}
export const getCreationDates = (timezoneOffset: number): Date[] => {
const clientNow = new Date()
clientNow.setTime(clientNow.getTime() - timezoneOffset * 60 * 1000)
logger.info(
`getCreationMonths -- offset: ${timezoneOffset} -- clientNow: ${clientNow.toISOString()}`,
)
return [
new Date(clientNow.getFullYear(), clientNow.getMonth() - 2, 1).getMonth() + 1,
new Date(clientNow.getFullYear(), clientNow.getMonth() - 1, 1).getMonth() + 1,
clientNow.getMonth() + 1,
new Date(clientNow.getFullYear(), clientNow.getMonth() - 2, 1),
new Date(clientNow.getFullYear(), clientNow.getMonth() - 1, 1),
clientNow,
]
}

View File

@ -231,3 +231,32 @@ This opens the `crontab` in edit-mode and insert the following entry:
```bash
0 4 * * * find /tmp -name "yarn--*" -ctime +1 -exec rm -r {} \; > /dev/null
```
## Define Cronjob To start backup script automatically
At least at production stage we need a daily backup of our database. This can be done by adding a cronjob
to start the existing backup.sh script.
### On production / stage3 / stage2
To check for existing cronjobs for the `gradido` user, please
Run:
```bash
crontab -l
```
This show all existing entries of the crontab for user `gradido`
To install/add the cronjob for a daily backup at 3:00am please
Run:
```bash
crontab -e
```
and insert the following line
```bash
0 3 * * * ~/gradido/deployment/bare_metal/backup.sh
```

View File

@ -1,112 +1,115 @@
<template>
<b-row class="transaction-form">
<b-col cols="12">
<b-card class="appBoxShadow gradido-border-radius" body-class="p-3">
<validation-observer v-slot="{ handleSubmit }" ref="formValidator">
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)" @reset="onReset">
<b-form-radio-group v-model="radioSelected" class="container">
<b-row class="mb-4">
<b-col cols="12" lg="6">
<b-row class="bg-248 gradido-border-radius pt-lg-2 mr-lg-2">
<b-col cols="10" @click="radioSelected = sendTypes.send" class="pointer">
{{ $t('send_gdd') }}
</b-col>
<b-col cols="2">
<b-form-radio
name="shipping"
size="lg"
:value="sendTypes.send"
stacked
class="custom-radio-button pointer"
></b-form-radio>
</b-col>
</b-row>
</b-col>
<div class="transaction-form">
<b-row>
<b-col cols="12">
<b-card class="appBoxShadow gradido-border-radius" body-class="p-3">
<validation-observer v-slot="{ handleSubmit }" ref="formValidator">
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)" @reset="onReset">
<b-form-radio-group v-model="radioSelected" class="container">
<b-row class="mb-4">
<b-col cols="12" lg="6">
<b-row class="bg-248 gradido-border-radius pt-lg-2 mr-lg-2">
<b-col cols="10" @click="radioSelected = sendTypes.send" class="pointer">
{{ $t('send_gdd') }}
</b-col>
<b-col cols="2">
<b-form-radio
name="shipping"
size="lg"
:value="sendTypes.send"
stacked
class="custom-radio-button pointer"
></b-form-radio>
</b-col>
</b-row>
</b-col>
<b-col>
<b-row class="bg-248 gradido-border-radius pt-lg-2 ml-lg-2 mt-2 mt-lg-0">
<b-col cols="10" @click="radioSelected = sendTypes.link" class="pointer">
{{ $t('send_per_link') }}
</b-col>
<b-col cols="2" class="pointer">
<b-form-radio
name="shipping"
:value="sendTypes.link"
size="lg"
class="custom-radio-button"
></b-form-radio>
</b-col>
</b-row>
</b-col>
</b-row>
<div class="mt-4 mb-4" v-if="radioSelected === sendTypes.link">
<h2 class="alert-heading">{{ $t('gdd_per_link.header') }}</h2>
<div>
{{ $t('gdd_per_link.choose-amount') }}
</div>
</div>
</b-form-radio-group>
<b-row>
<b-col>
<b-row class="bg-248 gradido-border-radius pt-lg-2 ml-lg-2 mt-2 mt-lg-0">
<b-col cols="10" @click="radioSelected = sendTypes.link" class="pointer">
{{ $t('send_per_link') }}
<b-row>
<b-col cols="12">
<div v-if="radioSelected === sendTypes.send">
<input-email
:name="$t('form.recipient')"
:label="$t('form.recipient')"
:placeholder="$t('form.email')"
v-model="form.email"
:disabled="isBalanceDisabled"
@onValidation="onValidation"
/>
</div>
</b-col>
<b-col cols="2" class="pointer">
<b-form-radio
name="shipping"
:value="sendTypes.link"
size="lg"
class="custom-radio-button"
></b-form-radio>
<b-col cols="12" lg="6">
<input-amount
v-model="form.amount"
:name="$t('form.amount')"
:label="$t('form.amount')"
:placeholder="'0.01'"
:rules="{ required: true, gddSendAmount: [0.01, balance] }"
typ="TransactionForm"
:disabled="isBalanceDisabled"
></input-amount>
</b-col>
</b-row>
</b-col>
</b-row>
<div class="mt-4 mb-4" v-if="radioSelected === sendTypes.link">
<h2 class="alert-heading">{{ $t('gdd_per_link.header') }}</h2>
<div>
{{ $t('gdd_per_link.choose-amount') }}
</div>
<b-row>
<b-col>
<input-textarea
v-model="form.memo"
:name="$t('form.message')"
:label="$t('form.message')"
:placeholder="$t('form.message')"
:rules="{ required: true, min: 5, max: 255 }"
:disabled="isBalanceDisabled"
/>
</b-col>
</b-row>
<div v-if="!!isBalanceDisabled" class="text-danger mt-5">
{{ $t('form.no_gdd_available') }}
</div>
</b-form-radio-group>
<b-row>
<b-col>
<b-row>
<b-col cols="12">
<div v-if="radioSelected === sendTypes.send">
<input-email
:name="$t('form.recipient')"
:label="$t('form.recipient')"
:placeholder="$t('form.email')"
v-model="form.email"
:disabled="isBalanceDisabled"
/>
</div>
</b-col>
<b-col cols="12" lg="6">
<input-amount
v-model="form.amount"
:name="$t('form.amount')"
:label="$t('form.amount')"
:placeholder="'0.01'"
:rules="{ required: true, gddSendAmount: [0.01, balance] }"
typ="TransactionForm"
:disabled="isBalanceDisabled"
></input-amount>
</b-col>
</b-row>
</b-col>
</b-row>
<b-row>
<b-col>
<input-textarea
v-model="form.memo"
:name="$t('form.message')"
:label="$t('form.message')"
:placeholder="$t('form.message')"
:rules="{ required: true, min: 5, max: 255 }"
:disabled="isBalanceDisabled"
/>
</b-col>
</b-row>
<div v-if="!!isBalanceDisabled" class="text-danger mt-5">
{{ $t('form.no_gdd_available') }}
</div>
<b-row v-else class="test-buttons mt-5">
<b-col>
<b-button type="reset" variant="secondary" @click="onReset">
{{ $t('form.reset') }}
</b-button>
</b-col>
<b-col class="text-right">
<b-button type="submit" variant="gradido">
{{ $t('form.check_now') }}
</b-button>
</b-col>
</b-row>
</b-form>
</validation-observer>
</b-card>
</b-col>
</b-row>
<b-row v-else class="test-buttons mt-5">
<b-col>
<b-button type="reset" variant="secondary" @click="onReset">
{{ $t('form.reset') }}
</b-button>
</b-col>
<b-col class="text-right">
<b-button type="submit" variant="gradido">
{{ $t('form.check_now') }}
</b-button>
</b-col>
</b-row>
</b-form>
</validation-observer>
</b-card>
</b-col>
</b-row>
</div>
</template>
<script>
import { SEND_TYPES } from '@/pages/Send.vue'
@ -140,6 +143,9 @@ export default {
}
},
methods: {
onValidation() {
this.$refs.formValidator.validate()
},
onSubmit() {
this.$emit('set-transaction', {
selected: this.radioSelected,
@ -153,6 +159,7 @@ export default {
this.form.email = ''
this.form.amount = ''
this.form.memo = ''
this.$refs.formValidator.validate()
},
setNewRecipientEmail() {
this.form.email = this.recipientEmail ? this.recipientEmail : this.form.email
@ -177,6 +184,9 @@ export default {
created() {
this.setNewRecipientEmail()
},
mounted() {
if (this.form.email !== '') this.$refs.formValidator.validate()
},
}
</script>
<style>

View File

@ -19,7 +19,7 @@
<div v-else>{{ errorResult }}</div>
</div>
<p class="text-center mt-5">
<b-button variant="secondary" @click="$emit('on-reset')">
<b-button variant="secondary" @click="$emit('on-back')">
{{ $t('form.close') }}
</b-button>
</p>

View File

@ -22,6 +22,7 @@
@focus="amountFocused = true"
@blur="normalizeAmount(true)"
:disabled="disabled"
autocomplete="off"
></b-form-input>
<b-form-invalid-feedback v-bind="ariaMsg">
@ -63,7 +64,7 @@ export default {
},
data() {
return {
currentValue: '',
currentValue: this.value,
amountValue: 0.0,
amountFocused: false,
}

View File

@ -21,6 +21,7 @@
@focus="emailFocused = true"
@blur="normalizeEmail()"
:disabled="disabled"
autocomplete="off"
></b-form-input>
<b-form-invalid-feedback v-bind="ariaMsg">
{{ errors[0] }}
@ -62,7 +63,10 @@ export default {
this.$emit('input', this.currentValue)
},
value() {
if (this.value !== this.currentValue) this.currentValue = this.value
if (this.value !== this.currentValue) {
this.currentValue = this.value
}
this.$emit('onValidation')
},
},
methods: {

View File

@ -58,7 +58,7 @@ describe('InputTextarea', () => {
})
it('has the value ""', () => {
expect(wrapper.vm.currentValue).toEqual('')
expect(wrapper.vm.currentValue).toEqual('Long enough')
})
it('has the label "input-field-label"', () => {
@ -72,9 +72,8 @@ describe('InputTextarea', () => {
describe('input value changes', () => {
it('emits input with new value', async () => {
await wrapper.find('textarea').setValue('Long enough')
expect(wrapper.emitted('input')).toBeTruthy()
expect(wrapper.emitted('input')).toEqual([['Long enough']])
await wrapper.find('textarea').setValue('New Text')
expect(wrapper.emitted('input')).toEqual([['New Text']])
})
})

View File

@ -41,7 +41,7 @@ export default {
},
data() {
return {
currentValue: '',
currentValue: this.value,
}
},
computed: {

View File

@ -154,7 +154,6 @@ export const login = gql`
hasElopage
publisherId
isAdmin
creation
hideAmountGDD
hideAmountGDT
}

View File

@ -250,3 +250,13 @@ export const listContributionMessages = gql`
}
}
`
export const openCreations = gql`
query {
openCreations {
year
month
amount
}
}
`

View File

@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
import Community from './Community'
import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup'
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
import { listContributions, listAllContributions, verifyLogin } from '@/graphql/queries'
import { listContributions, listAllContributions } from '@/graphql/queries'
import VueRouter from 'vue-router'
import routes from '../routes/routes'
@ -13,6 +13,7 @@ localVue.use(VueRouter)
const mockStoreDispach = jest.fn()
const apolloQueryMock = jest.fn()
const apolloMutationMock = jest.fn()
const apolloRefetchMock = jest.fn()
const router = new VueRouter({
base: '/',
@ -39,6 +40,11 @@ describe('Community', () => {
$apollo: {
query: apolloQueryMock,
mutate: apolloMutationMock,
queries: {
OpenCreations: {
refetch: apolloRefetchMock,
},
},
},
$store: {
dispatch: mockStoreDispach,
@ -207,10 +213,7 @@ describe('Community', () => {
})
it('verifies the login (to get the new creations available)', () => {
expect(apolloQueryMock).toBeCalledWith({
query: verifyLogin,
fetchPolicy: 'network-only',
})
expect(apolloRefetchMock).toBeCalled()
})
it('set all data to the default values)', () => {
@ -294,10 +297,7 @@ describe('Community', () => {
})
it('verifies the login (to get the new creations available)', () => {
expect(apolloQueryMock).toBeCalledWith({
query: verifyLogin,
fetchPolicy: 'network-only',
})
expect(apolloRefetchMock).toBeCalled()
})
it('set all data to the default values)', () => {
@ -376,10 +376,7 @@ describe('Community', () => {
})
it('verifies the login (to get the new creations available)', () => {
expect(apolloQueryMock).toBeCalledWith({
query: verifyLogin,
fetchPolicy: 'network-only',
})
expect(apolloRefetchMock).toBeCalled()
})
})

View File

@ -5,8 +5,8 @@
<b-tab no-body>
<open-creations-amount
:minimalDate="minimalDate"
:maxGddThisMonth="maxGddThisMonth"
:maxGddLastMonth="maxGddLastMonth"
:maxGddLastMonth="maxForMonths[0]"
:maxGddThisMonth="maxForMonths[1]"
/>
<div class="mb-3"></div>
<contribution-form
@ -15,8 +15,8 @@
v-model="form"
:isThisMonth="isThisMonth"
:minimalDate="minimalDate"
:maxGddLastMonth="maxGddLastMonth"
:maxGddThisMonth="maxGddThisMonth"
:maxGddLastMonth="maxForMonths[0]"
:maxGddThisMonth="maxForMonths[1]"
/>
</b-tab>
<b-tab no-body>
@ -52,7 +52,7 @@ import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount.
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
import ContributionList from '@/components/Contributions/ContributionList.vue'
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
import { listContributions, listAllContributions, verifyLogin } from '@/graphql/queries'
import { listContributions, listAllContributions, openCreations } from '@/graphql/queries'
export default {
name: 'Community',
@ -82,6 +82,7 @@ export default {
},
updateAmount: '',
maximalDate: new Date(),
openCreations: [],
}
},
mounted() {
@ -90,6 +91,23 @@ export default {
this.hashLink = this.$route.hash
})
},
apollo: {
OpenCreations: {
query() {
return openCreations
},
fetchPolicy: 'network-only',
variables() {
return {}
},
update({ openCreations }) {
this.openCreations = openCreations
},
error({ message }) {
this.toastError(message)
},
},
},
watch: {
$route(to, from) {
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === to.hash)
@ -120,17 +138,20 @@ export default {
formDate.getMonth() === this.maximalDate.getMonth()
)
},
maxGddLastMonth() {
amountToAdd() {
// when existing contribution is edited, the amount is added back on top of the amount
return this.form.id && !this.isThisMonth
? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount)
: parseInt(this.$store.state.creation[1])
if (this.form.id) return parseInt(this.updateAmount)
return 0
},
maxGddThisMonth() {
// when existing contribution is edited, the amount is added back on top of the amount
return this.form.id && this.isThisMonth
? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount)
: parseInt(this.$store.state.creation[2])
maxForMonths() {
const formDate = new Date(this.form.date)
if (this.openCreations && this.openCreations.length)
return this.openCreations.slice(1).map((creation) => {
if (creation.year === formDate.getFullYear() && creation.month === formDate.getMonth())
return parseInt(creation.amount) + this.amountToAdd
return parseInt(creation.amount)
})
return [0, 0]
},
},
methods: {
@ -160,7 +181,7 @@ export default {
currentPage: this.currentPage,
pageSize: this.pageSize,
})
this.verifyLogin()
this.$apollo.queries.OpenCreations.refetch()
})
.catch((err) => {
this.toastError(err.message)
@ -188,7 +209,7 @@ export default {
currentPage: this.currentPage,
pageSize: this.pageSize,
})
this.verifyLogin()
this.$apollo.queries.OpenCreations.refetch()
})
.catch((err) => {
this.toastError(err.message)
@ -213,7 +234,7 @@ export default {
currentPage: this.currentPage,
pageSize: this.pageSize,
})
this.verifyLogin()
this.$apollo.queries.OpenCreations.refetch()
})
.catch((err) => {
this.toastError(err.message)
@ -268,22 +289,6 @@ export default {
this.toastError(err.message)
})
},
verifyLogin() {
this.$apollo
.query({
query: verifyLogin,
fetchPolicy: 'network-only',
})
.then((result) => {
const {
data: { verifyLogin },
} = result
this.$store.dispatch('login', verifyLogin)
})
.catch(() => {
this.$emit('logout')
})
},
updateContributionForm(item) {
this.form.id = item.id
this.form.date = item.contributionDate
@ -303,8 +308,6 @@ export default {
},
created() {
// verifyLogin is important at this point so that creation is updated on reload if they are deleted in a session in the admin area.
this.verifyLogin()
this.updateListContributions({
currentPage: this.currentPage,
pageSize: this.pageSize,

View File

@ -13,7 +13,7 @@ const navigatorClipboardMock = jest.fn()
const localVue = global.localVue
describe.skip('Send', () => {
describe('Send', () => {
let wrapper
const propsData = {

View File

@ -47,9 +47,6 @@ export const mutations = {
hasElopage: (state, hasElopage) => {
state.hasElopage = hasElopage
},
creation: (state, creation) => {
state.creation = creation
},
hideAmountGDD: (state, hideAmountGDD) => {
state.hideAmountGDD = !!hideAmountGDD
},
@ -69,7 +66,6 @@ export const actions = {
commit('hasElopage', data.hasElopage)
commit('publisherId', data.publisherId)
commit('isAdmin', data.isAdmin)
commit('creation', data.creation)
commit('hideAmountGDD', data.hideAmountGDD)
commit('hideAmountGDT', data.hideAmountGDT)
},
@ -83,7 +79,6 @@ export const actions = {
commit('hasElopage', false)
commit('publisherId', null)
commit('isAdmin', false)
commit('creation', null)
commit('hideAmountGDD', false)
commit('hideAmountGDT', true)
localStorage.clear()
@ -111,7 +106,6 @@ try {
newsletterState: null,
hasElopage: false,
publisherId: null,
creation: null,
hideAmountGDD: null,
hideAmountGDT: null,
},

View File

@ -30,7 +30,6 @@ const {
publisherId,
isAdmin,
hasElopage,
creation,
hideAmountGDD,
hideAmountGDT,
} = mutations
@ -143,14 +142,6 @@ describe('Vuex store', () => {
})
})
describe('creation', () => {
it('sets the state of creation', () => {
const state = { creation: null }
creation(state, true)
expect(state.creation).toEqual(true)
})
})
describe('hideAmountGDD', () => {
it('sets the state of hideAmountGDD', () => {
const state = { hideAmountGDD: false }
@ -183,14 +174,13 @@ describe('Vuex store', () => {
hasElopage: false,
publisherId: 1234,
isAdmin: true,
creation: ['1000', '1000', '1000'],
hideAmountGDD: false,
hideAmountGDT: true,
}
it('calls eleven commits', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenCalledTimes(11)
expect(commit).toHaveBeenCalledTimes(10)
})
it('commits email', () => {
@ -233,19 +223,14 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', true)
})
it('commits creation', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(9, 'creation', ['1000', '1000', '1000'])
})
it('commits hideAmountGDD', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(10, 'hideAmountGDD', false)
expect(commit).toHaveBeenNthCalledWith(9, 'hideAmountGDD', false)
})
it('commits hideAmountGDT', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(11, 'hideAmountGDT', true)
expect(commit).toHaveBeenNthCalledWith(10, 'hideAmountGDT', true)
})
})
@ -255,7 +240,7 @@ describe('Vuex store', () => {
it('calls eleven commits', () => {
logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(11)
expect(commit).toHaveBeenCalledTimes(10)
})
it('commits token', () => {
@ -298,19 +283,14 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', false)
})
it('commits creation', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(9, 'creation', null)
})
it('commits hideAmountGDD', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(10, 'hideAmountGDD', false)
expect(commit).toHaveBeenNthCalledWith(9, 'hideAmountGDD', false)
})
it('commits hideAmountGDT', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(11, 'hideAmountGDT', true)
expect(commit).toHaveBeenNthCalledWith(10, 'hideAmountGDT', true)
})
// how to get this working?
it.skip('calls localStorage.clear()', () => {