From 53757893fde5fcf2cc419cc73fde9683f4b3e8c6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 10:06:00 +0100 Subject: [PATCH 01/22] Co-authored-by: ogerly Add hideAmountGDD & hideAmountGDT to users table. --- .../0059-add_hide_amount_to_users/User.ts | 118 ++++++++++++++++++ database/entity/User.ts | 2 +- 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 database/entity/0059-add_hide_amount_to_users/User.ts diff --git a/database/entity/0059-add_hide_amount_to_users/User.ts b/database/entity/0059-add_hide_amount_to_users/User.ts new file mode 100644 index 000000000..ba9e5fc49 --- /dev/null +++ b/database/entity/0059-add_hide_amount_to_users/User.ts @@ -0,0 +1,118 @@ +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + DeleteDateColumn, + OneToMany, + JoinColumn, + OneToOne, +} from 'typeorm' +import { Contribution } from '../Contribution' +import { ContributionMessage } from '../ContributionMessage' +import { UserContact } from '../UserContact' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ + name: 'gradido_id', + length: 36, + nullable: false, + collation: 'utf8mb4_unicode_ci', + }) + gradidoID: string + + @Column({ + name: 'alias', + length: 20, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + alias: string + + @OneToOne(() => UserContact, (emailContact: UserContact) => emailContact.user) + @JoinColumn({ name: 'email_id' }) + emailContact: UserContact + + @Column({ name: 'email_id', type: 'int', unsigned: true, nullable: true, default: null }) + emailId: number | null + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @DeleteDateColumn({ name: 'deleted_at', nullable: true }) + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ + name: 'password_encryption_type', + type: 'int', + unsigned: true, + nullable: false, + default: 0, + }) + passwordEncryptionType: number + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ type: 'bool', default: false }) + hideAmountGDD: boolean + + @Column({ type: 'bool', default: false }) + hideAmountGDT: boolean + + @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null }) + isAdmin: Date | null + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ + name: 'contribution_link_id', + type: 'int', + unsigned: true, + nullable: true, + default: null, + }) + contributionLinkId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @OneToMany(() => Contribution, (contribution) => contribution.user) + @JoinColumn({ name: 'user_id' }) + contributions?: Contribution[] + + @OneToMany(() => ContributionMessage, (message) => message.user) + @JoinColumn({ name: 'user_id' }) + messages?: ContributionMessage[] + + @OneToMany(() => UserContact, (userContact: UserContact) => userContact.user) + @JoinColumn({ name: 'user_id' }) + userContacts?: UserContact[] +} diff --git a/database/entity/User.ts b/database/entity/User.ts index 5cffc688e..fbb65204c 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0057-clear_old_password_junk/User' +export { User } from './0059-add_hide_amount_to_users/User' From 643de6144a36d2032323c323aec99f02249b9756 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 10:09:58 +0100 Subject: [PATCH 02/22] Co-authored-by: ogerly Add new database version to backend. --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 698b17e67..209f0cf81 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0058-add_communities_table', + DB_VERSION: '0059-add_hide_amount_to_users', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From 465dc469b0342e5bb0e06a81f6b335cb3a67ebd1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 10:13:01 +0100 Subject: [PATCH 03/22] Add hideAmount to updataUserInfos args & change updateUserInfo method. Co-authored-by: ogerly --- backend/src/graphql/arg/UpdateUserInfosArgs.ts | 6 ++++++ backend/src/graphql/resolver/UserResolver.ts | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index 81c07a329..8ac3f40a2 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -19,4 +19,10 @@ export default class UpdateUserInfosArgs { @Field({ nullable: true }) passwordNew?: string + + @Field({ nullable: false }) + hideAmountGDD: boolean + + @Field({ nullable: false }) + hideAmountGDT: boolean } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 4b4744b67..b58a8132a 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -567,7 +567,15 @@ export class UserResolver { @Mutation(() => Boolean) async updateUserInfos( @Args() - { firstName, lastName, language, password, passwordNew }: UpdateUserInfosArgs, + { + firstName, + lastName, + language, + password, + passwordNew, + hideAmountGDD, + hideAmountGDT, + }: UpdateUserInfosArgs, @Ctx() context: Context, ): Promise { logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`) @@ -609,6 +617,10 @@ export class UserResolver { userEntity.password = encryptPassword(userEntity, passwordNew) } + // Save hideAmountGDD value + userEntity.hideAmountGDD = hideAmountGDD + userEntity.hideAmountGDT = hideAmountGDT + const queryRunner = getConnection().createQueryRunner() await queryRunner.connect() await queryRunner.startTransaction('REPEATABLE READ') From 3d8e28e16c80f9146d906f1ff6d674db17b2c60b Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 10:42:54 +0100 Subject: [PATCH 04/22] Add comment to update hideAmountGDT. --- backend/src/graphql/resolver/UserResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index b58a8132a..8ce964c71 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -619,6 +619,7 @@ export class UserResolver { // Save hideAmountGDD value userEntity.hideAmountGDD = hideAmountGDD + // Save hideAmountGDT value userEntity.hideAmountGDT = hideAmountGDT const queryRunner = getConnection().createQueryRunner() From 84afbf9a9e6b02e957e220d781e3165b3e61bf0f Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 11:21:25 +0100 Subject: [PATCH 05/22] Fix imported User path. --- database/entity/0057-clear_old_password_junk/UserContact.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/entity/0057-clear_old_password_junk/UserContact.ts b/database/entity/0057-clear_old_password_junk/UserContact.ts index c101fba4c..dd06d3bbc 100644 --- a/database/entity/0057-clear_old_password_junk/UserContact.ts +++ b/database/entity/0057-clear_old_password_junk/UserContact.ts @@ -6,7 +6,7 @@ import { DeleteDateColumn, OneToOne, } from 'typeorm' -import { User } from './User' +import { User } from '../User' @Entity('user_contacts', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class UserContact extends BaseEntity { From ce909108a9f756edae3f3c1e13d954ddaaceb66b Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 11:22:26 +0100 Subject: [PATCH 06/22] Add migration for the new fields. --- database/migrations/0059-add_hide_amount_to_users.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 database/migrations/0059-add_hide_amount_to_users.ts diff --git a/database/migrations/0059-add_hide_amount_to_users.ts b/database/migrations/0059-add_hide_amount_to_users.ts new file mode 100644 index 000000000..d06e00559 --- /dev/null +++ b/database/migrations/0059-add_hide_amount_to_users.ts @@ -0,0 +1,12 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('ALTER TABLE users ADD COLUMN hideAmountGDD bool DEFAULT false;') + await queryFn('ALTER TABLE users ADD COLUMN hideAmountGDT bool DEFAULT false;') +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('ALTER TABLE users DROP COLUMN hideAmountGDD;') + await queryFn('ALTER TABLE users DROP COLUMN hideAmountGDT;') +} From e936e2bf401e85912cc244acc5bb9b6708b56579 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 11:28:20 +0100 Subject: [PATCH 07/22] Add new fields hideAmount... to the communityUser. --- backend/src/util/communityUser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index 98279db15..4d04be1b8 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -18,6 +18,8 @@ const communityDbUser: dbUser = { lastName: 'Akademie', deletedAt: null, password: BigInt(0), + hideAmountGDD: false, + hideAmountGDT: false, // emailHash: Buffer.from(''), createdAt: new Date(), // emailChecked: false, From 2010a1b059dfbe4725717a77472bb129ed44f166 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 3 Jan 2023 12:24:49 +0100 Subject: [PATCH 08/22] Add hideAmountGDD and hideAmountGDT to the login mutations and the verifyLogin queries --- backend/src/graphql/model/User.ts | 8 ++++++++ frontend/src/graphql/mutations.js | 6 ++++++ frontend/src/graphql/queries.js | 2 ++ frontend/src/store/store.js | 12 ++++++++++++ 4 files changed, 28 insertions(+) diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index cc52ff1f1..6e353f6a7 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -27,6 +27,8 @@ export class User { this.klickTipp = null this.hasElopage = null this.creation = creation + this.hideAmountGDD = user.hideAmountGDD + this.hideAmountGDT = user.hideAmountGDT } @Field(() => Number) @@ -72,6 +74,12 @@ export class User { @Field(() => String) language: string + @Field(() => Boolean) + hideAmountGDD: boolean + + @Field(() => Boolean) + hideAmountGDT: boolean + // This is not the users publisherId, but the one of the users who recommend him @Field(() => Number, { nullable: true }) publisherId: number | null diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 3156c2861..8b0464244 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -31,6 +31,8 @@ export const updateUserInfos = gql` $password: String $passwordNew: String $locale: String + $hideAmountGDD: boolean! + $hideAmountGDT: boolean! ) { updateUserInfos( firstName: $firstName @@ -38,6 +40,8 @@ export const updateUserInfos = gql` password: $password passwordNew: $passwordNew language: $locale + hideAmountGDD: $hideAmountGDD + hideAmountGDT: $hideAmountGDT ) } ` @@ -151,6 +155,8 @@ export const login = gql` publisherId isAdmin creation + hideAmountGDD + hideAmountGDT } } ` diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index d261797c2..d4973146d 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -14,6 +14,8 @@ export const verifyLogin = gql` publisherId isAdmin creation + hideAmountGDD + hideAmountGDT } } ` diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 8fdbc519e..dff96ee1d 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -50,6 +50,12 @@ export const mutations = { creation: (state, creation) => { state.creation = creation }, + hideAmountGDD: (state, hideAmountGDD) => { + state.hideAmountGDD = hideAmountGDD + }, + hideAmountGDT: (state, hideAmountGDT) => { + state.hideAmountGDT = hideAmountGDT + }, } export const actions = { @@ -64,6 +70,8 @@ export const actions = { commit('publisherId', data.publisherId) commit('isAdmin', data.isAdmin) commit('creation', data.creation) + commit('hideAmountGDD', data.hideAmountGDD) + commit('hideAmountGDT', data.hideAmountGDT) }, logout: ({ commit, state }) => { commit('token', null) @@ -76,6 +84,8 @@ export const actions = { commit('publisherId', null) commit('isAdmin', false) commit('creation', null) + commit('hideAmountGDD', null) + commit('hideAmountGDT', null) localStorage.clear() }, } @@ -102,6 +112,8 @@ try { hasElopage: false, publisherId: null, creation: null, + hideAmountGDD: null, + hideAmountGDT: null, }, getters: {}, // Syncronous mutation of the state From 914f50e09d0f9a048dc135ee5bec06e2852a6f53 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 9 Jan 2023 11:40:26 +0100 Subject: [PATCH 09/22] Navbar sheets are under the user icon --- frontend/src/components/Menu/Navbar.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index 7efb0d2ef..87e571c4f 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -12,14 +12,15 @@ - - + +
+
From 2e54641f20621cccc7b5b07188be0745db15bd40 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 9 Jan 2023 11:49:20 +0100 Subject: [PATCH 10/22] error corrected GdtBalance not null --- frontend/src/layouts/DashboardLayout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue index e5bf394f2..13c942dbc 100755 --- a/frontend/src/layouts/DashboardLayout.vue +++ b/frontend/src/layouts/DashboardLayout.vue @@ -177,7 +177,7 @@ export default { } = result this.GdtBalance = transactionList.balance.balanceGDT === null - ? null + ? 0 : Number(transactionList.balance.balanceGDT) this.transactions = transactionList.transactions this.balance = Number(transactionList.balance.balance) From ab9dc86925189b440ea7e2af5d675118a0c94ce4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 9 Jan 2023 15:33:45 +0100 Subject: [PATCH 11/22] InputEmail label and placeholder are displayed correctly per language --- frontend/src/components/Inputs/InputEmail.vue | 10 +++++----- frontend/src/pages/ForgotPassword.vue | 7 ++++++- frontend/src/pages/Login.vue | 9 ++++++++- frontend/src/pages/Register.vue | 9 ++++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Inputs/InputEmail.vue b/frontend/src/components/Inputs/InputEmail.vue index 1532e1edd..3a7ed4f4e 100644 --- a/frontend/src/components/Inputs/InputEmail.vue +++ b/frontend/src/components/Inputs/InputEmail.vue @@ -40,11 +40,11 @@ export default { } }, }, - name: { type: String, default: 'Email' }, - label: { type: String, default: 'Email' }, - placeholder: { type: String, default: 'Email' }, - value: { required: true, type: String, default: '' }, - disabled: { required: false, type: Boolean, default: false }, + name: { type: String, required: true }, + label: { type: String, required: true }, + placeholder: { type: String, required: true }, + value: { type: String, required: true }, + disabled: { type: Boolean, required: false, default: false }, }, data() { return { diff --git a/frontend/src/pages/ForgotPassword.vue b/frontend/src/pages/ForgotPassword.vue index 095920046..77c2ac926 100644 --- a/frontend/src/pages/ForgotPassword.vue +++ b/frontend/src/pages/ForgotPassword.vue @@ -6,7 +6,12 @@ - +
{{ $t('settings.password.send_now') }} diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 6d2dff5fa..bd07af3ef 100755 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -5,7 +5,14 @@ - + + + - + + +
Date: Mon, 9 Jan 2023 15:47:45 +0100 Subject: [PATCH 12/22] Avatar always has 2 letters --- frontend/src/components/Menu/Navbar.vue | 7 ++++++- .../src/components/Template/RightSide/LastTransactions.vue | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index 7efb0d2ef..caebbed07 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -16,7 +16,12 @@
- +
diff --git a/frontend/src/components/Template/RightSide/LastTransactions.vue b/frontend/src/components/Template/RightSide/LastTransactions.vue index 419bf334d..1cfb02061 100644 --- a/frontend/src/components/Template/RightSide/LastTransactions.vue +++ b/frontend/src/components/Template/RightSide/LastTransactions.vue @@ -24,6 +24,7 @@ :size="72" :color="'#fff'" :username="`${transaction.linkedUser.firstName} ${transaction.linkedUser.lastName}`" + :initials="`${transaction.linkedUser.firstName[0]} ${transaction.linkedUser.lastName[0]}`" >
From 5b44da35c5b4df7c9b5dfff6399724bc3edbe9a8 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 9 Jan 2023 17:25:44 +0100 Subject: [PATCH 13/22] fix test --- frontend/src/pages/ForgotPassword.spec.js | 4 ++-- frontend/src/pages/Login.spec.js | 17 +++++++++++++---- frontend/src/pages/Register.spec.js | 17 +++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/ForgotPassword.spec.js b/frontend/src/pages/ForgotPassword.spec.js index af7931793..f4b74e555 100644 --- a/frontend/src/pages/ForgotPassword.spec.js +++ b/frontend/src/pages/ForgotPassword.spec.js @@ -58,11 +58,11 @@ describe('ForgotPassword', () => { }) it('has the label "Email"', () => { - expect(form.find('label').text()).toEqual('Email') + expect(form.find('label').text()).toEqual('form.email') }) it('has the placeholder "Email"', () => { - expect(form.find('input').attributes('placeholder')).toEqual('Email') + expect(form.find('input').attributes('placeholder')).toEqual('form.email') }) it('has a submit button', () => { diff --git a/frontend/src/pages/Login.spec.js b/frontend/src/pages/Login.spec.js index 90e98cd44..14bf77aa6 100644 --- a/frontend/src/pages/Login.spec.js +++ b/frontend/src/pages/Login.spec.js @@ -76,7 +76,7 @@ describe('Login', () => { }) it('has an Email input field', () => { - expect(wrapper.find('input[placeholder="Email"]').exists()).toBe(true) + expect(wrapper.find('div[data-test="input-email"]').find('input').exists()).toBe(true) }) it('has an Password input field', () => { @@ -110,7 +110,10 @@ describe('Login', () => { describe('valid data', () => { beforeEach(async () => { jest.clearAllMocks() - await wrapper.find('input[placeholder="Email"]').setValue('user@example.org') + await wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('user@example.org') await wrapper.find('input[placeholder="form.password"]').setValue('1234') await flushPromises() apolloMutateMock.mockResolvedValue({ @@ -159,7 +162,10 @@ describe('Login', () => { code: 'some-code', } wrapper = Wrapper() - await wrapper.find('input[placeholder="Email"]').setValue('user@example.org') + await wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('user@example.org') await wrapper.find('input[placeholder="form.password"]').setValue('1234') await flushPromises() await wrapper.find('form').trigger('submit') @@ -180,7 +186,10 @@ describe('Login', () => { }) wrapper = Wrapper() jest.clearAllMocks() - await wrapper.find('input[placeholder="Email"]').setValue('user@example.org') + await wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('user@example.org') await wrapper.find('input[placeholder="form.password"]').setValue('1234') await flushPromises() await wrapper.find('form').trigger('submit') diff --git a/frontend/src/pages/Register.spec.js b/frontend/src/pages/Register.spec.js index 91e945c6a..f4d154058 100644 --- a/frontend/src/pages/Register.spec.js +++ b/frontend/src/pages/Register.spec.js @@ -65,7 +65,7 @@ describe('Register', () => { }) it('has email input fields', () => { - expect(wrapper.find('#Email-input-field').exists()).toBe(true) + expect(wrapper.find('div[data-test="input-email"]').find('input').exists()).toBe(true) }) it('has 1 checkbox input fields', () => { @@ -107,7 +107,10 @@ describe('Register', () => { wrapper.find('#registerLastname').setValue('Mustermann') }) it('has disabled submit button when missing input checked box', () => { - wrapper.find('#Email-input-field').setValue('max.mustermann@gradido.net') + wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('max.mustermann@gradido.net') expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') }) @@ -121,7 +124,10 @@ describe('Register', () => { beforeEach(() => { wrapper.find('#registerFirstname').setValue('Max') wrapper.find('#registerLastname').setValue('Mustermann') - wrapper.find('#Email-input-field').setValue('max.mustermann@gradido.net') + wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('max.mustermann@gradido.net') wrapper.find('#registerCheckbox').setChecked() }) @@ -211,7 +217,10 @@ describe('Register', () => { wrapper = Wrapper() wrapper.find('#registerFirstname').setValue('Max') wrapper.find('#registerLastname').setValue('Mustermann') - wrapper.find('#Email-input-field').setValue('max.mustermann@gradido.net') + wrapper + .find('div[data-test="input-email"]') + .find('input') + .setValue('max.mustermann@gradido.net') wrapper.find('#registerCheckbox').setChecked() await wrapper.find('form').trigger('submit') await flushPromises() From 11061239a255f90746c55093c942050ea7bb4319 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 10 Jan 2023 08:25:30 +0100 Subject: [PATCH 14/22] balanceGDT changes undone again --- frontend/src/layouts/DashboardLayout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue index 13c942dbc..e5bf394f2 100755 --- a/frontend/src/layouts/DashboardLayout.vue +++ b/frontend/src/layouts/DashboardLayout.vue @@ -177,7 +177,7 @@ export default { } = result this.GdtBalance = transactionList.balance.balanceGDT === null - ? 0 + ? null : Number(transactionList.balance.balanceGDT) this.transactions = transactionList.transactions this.balance = Number(transactionList.balance.balance) From ae5c5984b83307ec29c03a1e230870fe4c5940af Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 10 Jan 2023 10:06:58 +0100 Subject: [PATCH 15/22] change hide amounts to optional --- backend/src/graphql/arg/UpdateUserInfosArgs.ts | 8 ++++---- backend/src/graphql/resolver/UserResolver.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index 8ac3f40a2..b45539487 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -20,9 +20,9 @@ export default class UpdateUserInfosArgs { @Field({ nullable: true }) passwordNew?: string - @Field({ nullable: false }) - hideAmountGDD: boolean + @Field({ nullable: true }) + hideAmountGDD?: boolean - @Field({ nullable: false }) - hideAmountGDT: boolean + @Field({ nullable: true }) + hideAmountGDT?: boolean } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 8ce964c71..ed1bf3f47 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -618,9 +618,13 @@ export class UserResolver { } // Save hideAmountGDD value - userEntity.hideAmountGDD = hideAmountGDD + if (hideAmountGDD !== undefined) { + userEntity.hideAmountGDD = hideAmountGDD + } // Save hideAmountGDT value - userEntity.hideAmountGDT = hideAmountGDT + if (hideAmountGDT !== undefined) { + userEntity.hideAmountGDT = hideAmountGDT + } const queryRunner = getConnection().createQueryRunner() await queryRunner.connect() From b1398347291b06887de137cf8e47c197cb4b9ea0 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 10 Jan 2023 10:07:47 +0100 Subject: [PATCH 16/22] add methodes to update hide amounts --- .../Template/ContentHeader/GddAmount.vue | 26 ++++++++++++++++++- .../Template/ContentHeader/GdtAmount.vue | 26 ++++++++++++++++++- frontend/src/graphql/mutations.js | 4 +-- frontend/src/locales/de.json | 4 +++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Template/ContentHeader/GddAmount.vue b/frontend/src/components/Template/ContentHeader/GddAmount.vue index f8d04e883..1c774f3d7 100644 --- a/frontend/src/components/Template/ContentHeader/GddAmount.vue +++ b/frontend/src/components/Template/ContentHeader/GddAmount.vue @@ -39,7 +39,7 @@ @@ -47,6 +47,8 @@
diff --git a/frontend/src/components/Template/ContentHeader/GdtAmount.vue b/frontend/src/components/Template/ContentHeader/GdtAmount.vue index 6a2312e07..9216ff232 100644 --- a/frontend/src/components/Template/ContentHeader/GdtAmount.vue +++ b/frontend/src/components/Template/ContentHeader/GdtAmount.vue @@ -34,7 +34,7 @@
@@ -42,6 +42,8 @@
diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 8b0464244..95d7b0c39 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -31,8 +31,8 @@ export const updateUserInfos = gql` $password: String $passwordNew: String $locale: String - $hideAmountGDD: boolean! - $hideAmountGDT: boolean! + $hideAmountGDD: Boolean + $hideAmountGDT: Boolean ) { updateUserInfos( firstName: $firstName diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 52da80cc6..e34d11297 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -269,6 +269,10 @@ "warningText": "Bist du noch da?" }, "settings": { + "showAmountGDD": "Dein GDD Betrag ist sichtbar.", + "hideAmountGDD": "Dein GDD Betrag ist versteckt.", + "showAmountGDT": "Dein GDT Betrag ist sichtbar.", + "hideAmountGDT": "Dein GDT Betrag ist versteckt.", "language": { "changeLanguage": "Sprache ändern", "de": "Deutsch", From 427a0a6865e3f7978f7e0e03ac537c47214306f5 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 10:55:41 +0100 Subject: [PATCH 17/22] Change test of returned login datas. --- backend/src/graphql/resolver/UserResolver.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index b70dd1522..073bad04d 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -63,6 +63,7 @@ jest.mock('@/emails/sendEmailVariants', () => { }) /* + jest.mock('@/apis/KlicktippController', () => { return { __esModule: true, @@ -132,6 +133,8 @@ describe('UserResolver', () => { { id: expect.any(Number), gradidoID: expect.any(String), + hideAmountGDD: expect.any(Boolean), + hideAmountGDT: expect.any(Boolean), alias: null, emailContact: expect.any(UserContact), // 'peter@lustig.de', emailId: expect.any(Number), From d71a73ec3b48ade0370a259d1ea5b15680b576b9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 10:56:08 +0100 Subject: [PATCH 18/22] Add new mutation variables to the tests mutation in backend. --- backend/src/seeds/graphql/mutations.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index e5dc90a0e..2b4ed6656 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -31,6 +31,8 @@ export const updateUserInfos = gql` $password: String $passwordNew: String $locale: String + $hideAmountGDD: Boolean + $hideAmountGDT: Boolean ) { updateUserInfos( firstName: $firstName @@ -38,6 +40,8 @@ export const updateUserInfos = gql` password: $password passwordNew: $passwordNew language: $locale + hideAmountGDD: $hideAmountGDD + hideAmountGDT: $hideAmountGDT ) } ` From dded791586c67c23f84deededa89b8f78ac7a36b Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 11:54:44 +0100 Subject: [PATCH 19/22] Fix linting and locales --- frontend/src/locales/de.json | 6 +++--- frontend/src/locales/en.json | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index e34d11297..2eabd6ab5 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -269,9 +269,7 @@ "warningText": "Bist du noch da?" }, "settings": { - "showAmountGDD": "Dein GDD Betrag ist sichtbar.", "hideAmountGDD": "Dein GDD Betrag ist versteckt.", - "showAmountGDT": "Dein GDT Betrag ist sichtbar.", "hideAmountGDT": "Dein GDT Betrag ist versteckt.", "language": { "changeLanguage": "Sprache ändern", @@ -305,7 +303,9 @@ "text": "Speichere nun dein neues Passwort, mit dem du dich zukünftig in deinem Gradido-Konto anmelden kannst." }, "subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen." - } + }, + "showAmountGDD": "Dein GDD Betrag ist sichtbar.", + "showAmountGDT": "Dein GDT Betrag ist sichtbar." }, "signin": "Anmelden", "signup": "Registrieren", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 7837743e0..f90eef660 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -269,6 +269,8 @@ "warningText": "Are you still there?" }, "settings": { + "hideAmountGDD": "Your GDD amount is hidden.", + "hideAmountGDT": "Your GDT amount is hidden.", "language": { "changeLanguage": "Change language", "de": "Deutsch", @@ -301,7 +303,9 @@ "text": "Now save your new password, which you can use to log in to your Gradido account in the future." }, "subtitle": "If you have forgotten your password, you can reset it here." - } + }, + "showAmountGDD": "Your GDD amount is visible.", + "showAmountGDT": "Your GDT amount is visible." }, "signin": "Sign in", "signup": "Sign up", From 74c575882ae79827c180f024110610aa6b431d23 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 13:56:39 +0100 Subject: [PATCH 20/22] Tests on GddAmount --- .../Template/ContentHeader/GddAmount.spec.js | 96 ++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Template/ContentHeader/GddAmount.spec.js b/frontend/src/components/Template/ContentHeader/GddAmount.spec.js index fc7d65cc4..a335b0efb 100644 --- a/frontend/src/components/Template/ContentHeader/GddAmount.spec.js +++ b/frontend/src/components/Template/ContentHeader/GddAmount.spec.js @@ -1,20 +1,31 @@ import { mount } from '@vue/test-utils' import GddAmount from './GddAmount' +import { updateUserInfos } from '@/graphql/mutations' +import flushPromises from 'flush-promises' + +import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup' const localVue = global.localVue +const mockAPICall = jest.fn() +const storeCommitMock = jest.fn() + const state = { - language: 'en', + hideAmountGDD: false, } const mocks = { $store: { state, + commit: storeCommitMock, }, $i18n: { locale: 'en', }, $t: jest.fn((t) => t), + $apollo: { + mutate: mockAPICall, + }, } const propsData = { @@ -38,5 +49,88 @@ describe('GddAmount', () => { it('renders the component gdd-amount', () => { expect(wrapper.find('div.gdd-amount').exists()).toBe(true) }) + + describe('API throws exception', () => { + beforeEach(async () => { + mockAPICall.mockRejectedValue({ + message: 'Ouch', + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Ouch') + }) + }) + + describe('API call successful', () => { + beforeEach(async () => { + mockAPICall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('calls the API', () => { + expect(mockAPICall).toBeCalledWith( + expect.objectContaining({ + mutation: updateUserInfos, + variables: { + hideAmountGDD: true, + }, + }), + ) + }) + + it('commits hideAmountGDD to store', () => { + expect(storeCommitMock).toBeCalledWith('hideAmountGDD', true) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('settings.showAmountGDD') + }) + }) + }) + + describe.skip('second call to API', () => { + beforeEach(async () => { + mockAPICall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('calls the API', () => { + expect(mockAPICall).toBeCalledWith( + expect.objectContaining({ + mutation: updateUserInfos, + variables: { + hideAmountGDD: true, + }, + }), + ) + }) + + it('commits hideAmountGDD to store', () => { + expect(storeCommitMock).toBeCalledWith('hideAmountGDD', false) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('settings.hideAmountGDD') + }) }) }) From 01f054c1818ac1ab624e4a221cf6e01a9432b1e9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 13:56:52 +0100 Subject: [PATCH 21/22] Tests on GdtAmount --- .../Template/ContentHeader/GdtAmount.spec.js | 96 ++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js b/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js index 30ce85817..739a00676 100644 --- a/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js +++ b/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js @@ -1,19 +1,30 @@ import { mount } from '@vue/test-utils' import GdtAmount from './GdtAmount' +import { updateUserInfos } from '@/graphql/mutations' +import flushPromises from 'flush-promises' + +import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup' const localVue = global.localVue +const mockAPICall = jest.fn() +const storeCommitMock = jest.fn() + const state = { - language: 'en', + hideAmountGDT: false, } const mocks = { $store: { state, + commit: storeCommitMock, }, $i18n: { locale: 'en', }, + $apollo: { + mutate: mockAPICall, + }, $t: jest.fn((t) => t), $n: jest.fn((n) => n), } @@ -39,5 +50,88 @@ describe('GdtAmount', () => { it('renders the component gdt-amount', () => { expect(wrapper.find('div.gdt-amount').exists()).toBe(true) }) + + describe('API throws exception', () => { + beforeEach(async () => { + mockAPICall.mockRejectedValue({ + message: 'Ouch', + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Ouch') + }) + }) + + describe('API call successful', () => { + beforeEach(async () => { + mockAPICall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('calls the API', () => { + expect(mockAPICall).toBeCalledWith( + expect.objectContaining({ + mutation: updateUserInfos, + variables: { + hideAmountGDT: true, + }, + }), + ) + }) + + it('commits hideAmountGDT to store', () => { + expect(storeCommitMock).toBeCalledWith('hideAmountGDT', true) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('settings.showAmountGDT') + }) + }) + }) + + describe.skip('second call to API', () => { + beforeEach(async () => { + mockAPICall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + jest.clearAllMocks() + await wrapper.find('div.border-left svg').trigger('click') + await flushPromises() + }) + + it('calls the API', () => { + expect(mockAPICall).toBeCalledWith( + expect.objectContaining({ + mutation: updateUserInfos, + variables: { + hideAmountGDT: true, + }, + }), + ) + }) + + it('commits hideAmountGDT to store', () => { + expect(storeCommitMock).toBeCalledWith('hideAmountGDT', false) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('settings.hideAmountGDT') + }) }) }) From 676283449c4f518ca13392470c2a215d547db65b Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 10 Jan 2023 14:35:56 +0100 Subject: [PATCH 22/22] Fix 'second call to API' test of Gdt- and GddAmount --- .../src/components/Template/ContentHeader/GddAmount.spec.js | 5 +++-- .../src/components/Template/ContentHeader/GdtAmount.spec.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Template/ContentHeader/GddAmount.spec.js b/frontend/src/components/Template/ContentHeader/GddAmount.spec.js index a335b0efb..26967507b 100644 --- a/frontend/src/components/Template/ContentHeader/GddAmount.spec.js +++ b/frontend/src/components/Template/ContentHeader/GddAmount.spec.js @@ -100,7 +100,7 @@ describe('GddAmount', () => { }) }) - describe.skip('second call to API', () => { + describe('second call to API', () => { beforeEach(async () => { mockAPICall.mockResolvedValue({ data: { @@ -110,6 +110,7 @@ describe('GddAmount', () => { }, }) jest.clearAllMocks() + wrapper.vm.$store.state.hideAmountGDD = true await wrapper.find('div.border-left svg').trigger('click') await flushPromises() }) @@ -119,7 +120,7 @@ describe('GddAmount', () => { expect.objectContaining({ mutation: updateUserInfos, variables: { - hideAmountGDD: true, + hideAmountGDD: false, }, }), ) diff --git a/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js b/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js index 739a00676..58744cbfe 100644 --- a/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js +++ b/frontend/src/components/Template/ContentHeader/GdtAmount.spec.js @@ -101,7 +101,7 @@ describe('GdtAmount', () => { }) }) - describe.skip('second call to API', () => { + describe('second call to API', () => { beforeEach(async () => { mockAPICall.mockResolvedValue({ data: { @@ -111,6 +111,7 @@ describe('GdtAmount', () => { }, }) jest.clearAllMocks() + wrapper.vm.$store.state.hideAmountGDT = true await wrapper.find('div.border-left svg').trigger('click') await flushPromises() }) @@ -120,7 +121,7 @@ describe('GdtAmount', () => { expect.objectContaining({ mutation: updateUserInfos, variables: { - hideAmountGDT: true, + hideAmountGDT: false, }, }), )