From c8b9de35d8b6bf0c070a72b36e0d543e33d15f9f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 13:08:57 +0100 Subject: [PATCH 1/7] eslint-plugin-jest --- backend/.eslintrc.js | 8 ++++++- backend/package.json | 1 + backend/yarn.lock | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 096e4d60a..5eafeffa3 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { node: true, }, parser: '@typescript-eslint/parser', - plugins: ['prettier', '@typescript-eslint', 'type-graphql'], + plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'], // add your custom rules here rules: { @@ -16,6 +16,12 @@ module.exports = { htmlWhitespaceSensitivity: 'ignore', }, ], + // jest + 'jest/no-disabled-tests': 'off', // TODO + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'error', + 'jest/prefer-to-have-length': 'warn', + 'jest/valid-expect': 'error', }, overrides: [ // only for ts files diff --git a/backend/package.json b/backend/package.json index dab5e50af..69cb26c93 100644 --- a/backend/package.json +++ b/backend/package.json @@ -62,6 +62,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jest": "^27.2.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-promise": "^5.1.0", diff --git a/backend/yarn.lock b/backend/yarn.lock index 3151557ab..7d896258f 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1239,6 +1239,14 @@ "@typescript-eslint/types" "5.53.0" "@typescript-eslint/visitor-keys" "5.53.0" +"@typescript-eslint/scope-manager@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.54.1.tgz#6d864b4915741c608a58ce9912edf5a02bb58735" + integrity sha512-zWKuGliXxvuxyM71UA/EcPxaviw39dB2504LqAmFDjmkpO8qNLHcmzlh6pbHs1h/7YQ9bnsO8CCcYCSA8sykUg== + dependencies: + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/visitor-keys" "5.54.1" + "@typescript-eslint/types@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" @@ -1249,6 +1257,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f" integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A== +"@typescript-eslint/types@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.54.1.tgz#29fbac29a716d0f08c62fe5de70c9b6735de215c" + integrity sha512-G9+1vVazrfAfbtmCapJX8jRo2E4MDXxgm/IMOF4oGh3kq7XuK3JRkOg6y2Qu1VsTRmWETyTkWt1wxy7X7/yLkw== + "@typescript-eslint/typescript-estree@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" @@ -1275,6 +1288,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.54.1.tgz#df7b6ae05fd8fef724a87afa7e2f57fa4a599be1" + integrity sha512-bjK5t+S6ffHnVwA0qRPTZrxKSaFYocwFIkZx5k7pvWfsB1I57pO/0M0Skatzzw1sCkjJ83AfGTL0oFIFiDX3bg== + dependencies: + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/visitor-keys" "5.54.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8" @@ -1289,6 +1315,20 @@ eslint-utils "^3.0.0" semver "^7.3.7" +"@typescript-eslint/utils@^5.10.0": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.54.1.tgz#7a3ee47409285387b9d4609ea7e1020d1797ec34" + integrity sha512-IY5dyQM8XD1zfDe5X8jegX6r2EVU5o/WJnLu/znLPWCBF7KNGC+adacXnt5jEYS9JixDcoccI6CvE4RCjHMzCQ== + dependencies: + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.54.1" + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/typescript-estree" "5.54.1" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + semver "^7.3.7" + "@typescript-eslint/visitor-keys@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" @@ -1305,6 +1345,14 @@ "@typescript-eslint/types" "5.53.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.54.1.tgz#d7a8a0f7181d6ac748f4d47b2306e0513b98bf8b" + integrity sha512-q8iSoHTgwCfgcRJ2l2x+xCbu8nBlRAlsQ33k24Adj8eoVBE0f8dUeI+bAa8F84Mv05UGbAx57g2zrRsYIooqQg== + dependencies: + "@typescript-eslint/types" "5.54.1" + eslint-visitor-keys "^3.3.0" + "@wry/equality@^0.1.2": version "0.1.11" resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.1.11.tgz#35cb156e4a96695aa81a9ecc4d03787bc17f1790" @@ -2714,6 +2762,13 @@ eslint-plugin-import@^2.23.4: resolve "^1.20.0" tsconfig-paths "^3.11.0" +eslint-plugin-jest@^27.2.1: + version "27.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz#b85b4adf41c682ea29f1f01c8b11ccc39b5c672c" + integrity sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-node@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d" From 04a87be90d7c8f3621fb3f89b82c75d9dea3ba6e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 13:09:35 +0100 Subject: [PATCH 2/7] fix eslint jest errors --- .../resolver/ContributionLinkResolver.test.ts | 20 +++--- .../ContributionMessageResolver.test.ts | 8 +-- .../resolver/ContributionResolver.test.ts | 72 +++++++++---------- .../resolver/TransactionLinkResolver.test.ts | 22 +++--- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 4563d2a6a..606bce109 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -266,7 +266,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "A Start-Date must be set"', () => { expect(logger.error).toBeCalledWith('A Start-Date must be set') }) @@ -287,7 +287,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "An End-Date must be set"', () => { expect(logger.error).toBeCalledWith('An End-Date must be set') }) @@ -311,7 +311,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of validFrom must before or equals the validTo"', () => { expect(logger.error).toBeCalledWith( `The value of validFrom must before or equals the validTo`, ) @@ -334,7 +334,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of name is too short"', () => { expect(logger.error).toBeCalledWith('The value of name is too short', 3) }) @@ -355,7 +355,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of name is too long"', () => { expect(logger.error).toBeCalledWith('The value of name is too long', 101) }) @@ -376,7 +376,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of memo is too short"', () => { expect(logger.error).toBeCalledWith('The value of memo is too short', 3) }) @@ -397,7 +397,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of memo is too long"', () => { expect(logger.error).toBeCalledWith('The value of memo is too long', 256) }) @@ -418,7 +418,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount must be a positiv value"', () => { expect(logger.error).toBeCalledWith('The amount must be a positiv value', new Decimal(0)) }) }) @@ -476,7 +476,7 @@ describe('Contribution Links', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Contribution Link not found"', () => { expect(logger.error).toBeCalledWith('Contribution Link not found', -1) }) @@ -546,7 +546,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution Link not found"', () => { expect(logger.error).toBeCalledWith('Contribution Link not found', -1) }) }) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 8b5c5a0a7..642844e31 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -113,7 +113,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), @@ -153,7 +153,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution', new Error('Admin can not answer on his own contribution'), @@ -251,7 +251,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), @@ -283,7 +283,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user', new Error('Can not send message to contribution of another user'), diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 274067ba0..cc7357e99 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -201,7 +201,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too short"', () => { expect(logger.error).toBeCalledWith('Memo text is too short', 4) }) @@ -219,7 +219,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too long"', () => { expect(logger.error).toBeCalledWith('Memo text is too long', 259) }) @@ -238,7 +238,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', expect.any(Date), @@ -261,7 +261,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "No information for available creations for the given date" again', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', expect.any(Date), @@ -336,7 +336,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too short"', () => { expect(logger.error).toBeCalledWith('Memo text is too short', 4) }) }) @@ -357,7 +357,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too long"', () => { expect(logger.error).toBeCalledWith('Memo text is too long', 259) }) }) @@ -382,7 +382,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -411,7 +411,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Can not update contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'Can not update contribution of another user', expect.any(Object), @@ -445,7 +445,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "An admin is not allowed to update an user contribution"', () => { expect(logger.error).toBeCalledWith( 'An admin is not allowed to update an user contribution', ) @@ -491,7 +491,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error found', () => { + it('logs the error "Contribution can not be updated due to status"', () => { expect(logger.error).toBeCalledWith( 'Contribution can not be updated due to status', ContributionStatus.DELETED, @@ -526,7 +526,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1019), @@ -553,7 +553,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Month of contribution can not be changed"', () => { expect(logger.error).toBeCalledWith('Month of contribution can not be changed') }) }) @@ -657,7 +657,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -701,7 +701,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) }) }) @@ -746,7 +746,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) }) }) @@ -791,7 +791,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) }) }) @@ -877,7 +877,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) }) }) @@ -907,7 +907,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Can not delete contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'Can not delete contribution of another user', expect.any(Contribution), @@ -981,7 +981,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "A confirmed contribution can not be deleted"', () => { expect(logger.error).toBeCalledWith( 'A confirmed contribution can not be deleted', expect.objectContaining({ contributionStatus: 'CONFIRMED' }), @@ -1846,7 +1846,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Could not find user"', () => { expect(logger.error).toBeCalledWith('Could not find user', 'some@fake.email') }) }) @@ -1873,7 +1873,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Cannot create contribution since the user was deleted"', () => { expect(logger.error).toBeCalledWith( 'Cannot create contribution since the user was deleted', expect.objectContaining({ @@ -1909,7 +1909,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Cannot create contribution since the users email is not activated"', () => { expect(logger.error).toBeCalledWith( 'Cannot create contribution since the users email is not activated', expect.objectContaining({ emailChecked: false }), @@ -1935,7 +1935,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "CreationDate is invalid"', () => { expect(logger.error).toBeCalledWith('CreationDate is invalid', 'invalid-date') }) }) @@ -1957,7 +1957,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', new Date(variables.creationDate), @@ -1982,7 +1982,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', new Date(variables.creationDate), @@ -2007,7 +2007,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(2000), @@ -2058,7 +2058,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1000), @@ -2097,7 +2097,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Could not find User"', () => { expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de') }) }) @@ -2123,7 +2123,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "User was deleted"', () => { expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk') }) }) @@ -2149,7 +2149,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2181,7 +2181,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "User of the pending contribution and send user does not correspond"', () => { expect(logger.error).toBeCalledWith( 'User of the pending contribution and send user does not correspond', ) @@ -2216,7 +2216,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1900), @@ -2326,7 +2326,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2466,7 +2466,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2500,7 +2500,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Moderator can not confirm own contribution"', () => { expect(logger.error).toBeCalledWith('Moderator can not confirm own contribution') }) }) @@ -2595,7 +2595,7 @@ describe('ContributionResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Contribution already confirmed"', () => { expect(logger.error).toBeCalledWith( 'Contribution already confirmed', expect.any(Number), diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fc5ca170a..c6b733d0d 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -94,7 +94,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('Amount must be a positive number')], }) }) - it('logs the error thrown', () => { + it('logs the error "Amount must be a positive number" - 0', () => { expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(0)) }) @@ -112,7 +112,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('Amount must be a positive number')], }) }) - it('logs the error thrown', () => { + it('logs the error "Amount must be a positive number" - -10', () => { expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(-10)) }) @@ -130,7 +130,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('User has not enough GDD')], }) }) - it('logs the error thrown', () => { + it('logs the error "User has not enough GDD"', () => { expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number)) }) }) @@ -180,7 +180,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "No contribution link found to given code"', () => { expect(logger.error).toBeCalledWith( 'No contribution link found to given code', 'CL-123456', @@ -224,7 +224,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link is not valid yet"', () => { expect(logger.error).toBeCalledWith('Contribution link is not valid yet', validFrom) expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -263,7 +263,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link has unknown cycle"', () => { expect(logger.error).toBeCalledWith('Contribution link has unknown cycle', 'INVALID') expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -302,7 +302,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link is no longer valid"', () => { expect(logger.error).toBeCalledWith('Contribution link is no longer valid', validTo) expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -394,7 +394,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error( @@ -451,7 +451,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error('Contribution link already redeemed today'), @@ -503,7 +503,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error('Contribution link already redeemed today'), @@ -620,7 +620,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Could not find requested User"', () => { expect(logger.error).toBeCalledWith('Could not find requested User', -1) }) }) From b6f903374e3b588b815634041f7c1ec129f24917 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 14:12:46 +0100 Subject: [PATCH 3/7] also match tsx files, fix semaphore lint ignore --- backend/.eslintrc.js | 3 ++- backend/src/graphql/resolver/semaphore.test.ts | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 5eafeffa3..bc2f0a43d 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -2,6 +2,7 @@ module.exports = { root: true, env: { node: true, + // jest: true, }, parser: '@typescript-eslint/parser', plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], @@ -26,7 +27,7 @@ module.exports = { overrides: [ // only for ts files { - files: ['*.ts'], + files: ['*.ts', '*.tsx'], extends: [ 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking', diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 70e3e5f96..1ce133fba 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -5,8 +5,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import Decimal from 'decimal.js-light' -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { logger } from '@test/testSetup' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' From 7345ebb386146269b3b206626cb725845f3d65ec Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 14:28:04 +0100 Subject: [PATCH 4/7] jest env not needed --- backend/.eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index bc2f0a43d..0085e695b 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -2,7 +2,6 @@ module.exports = { root: true, env: { node: true, - // jest: true, }, parser: '@typescript-eslint/parser', plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], From 193da5fd0f4d085dbc11c5a8b624f0f2382ac75e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:11:54 +0100 Subject: [PATCH 5/7] update config --- backend/.eslintrc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 0085e695b..6ce43ef35 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -17,10 +17,10 @@ module.exports = { }, ], // jest - 'jest/no-disabled-tests': 'off', // TODO + 'jest/no-disabled-tests': 'error', 'jest/no-focused-tests': 'error', 'jest/no-identical-title': 'error', - 'jest/prefer-to-have-length': 'warn', + 'jest/prefer-to-have-length': 'error', 'jest/valid-expect': 'error', }, overrides: [ From 62411198852240bb2029d55ab83e57334e6c7380 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:18:13 +0100 Subject: [PATCH 6/7] fix skip tests --- backend/src/emails/sendEmailTranslated.test.ts | 2 ++ backend/src/graphql/resolver/ContributionResolver.test.ts | 1 + backend/src/graphql/resolver/TransactionLinkResolver.test.ts | 1 + backend/src/graphql/resolver/UserResolver.test.ts | 1 + backend/src/util/decay.test.ts | 1 + 5 files changed, 6 insertions(+) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index f3c75a7a6..73edb79f3 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -102,10 +102,12 @@ describe('sendEmailTranslated', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests it.skip('calls "i18n.setLocale" with "en"', () => { expect(i18n.setLocale).toBeCalledWith('en') }) + // eslint-disable-next-line jest/no-disabled-tests it.skip('calls "i18n.__" for translation', () => { expect(i18n.__).toBeCalled() }) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index cc7357e99..a15c64e85 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2225,6 +2225,7 @@ describe('ContributionResolver', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests describe.skip('creation update is successful changing month', () => { // skipped as changing the month is currently disable it('returns update creation object', async () => { diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index c6b733d0d..35d3f42f6 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -759,6 +759,7 @@ describe('TransactionLinkResolver', () => { }) // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory + // eslint-disable-next-line jest/no-disabled-tests describe.skip('filter by redeemed', () => { it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index a57346583..083badc30 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -789,6 +789,7 @@ describe('UserResolver', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests describe.skip('user is in database but password is not set', () => { beforeAll(async () => { jest.clearAllMocks() diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index cf00ec851..0e7b02f56 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -16,6 +16,7 @@ describe('utils/decay', () => { expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444') }) // we get pretty close, but not exact here, skipping + // eslint-disable-next-line jest/no-disabled-tests it.skip('has correct forward calculation', () => { const amount = new Decimal(1.0).div( new Decimal('0.99999997803504048973201202316767079413460520837376'), From a3e135969d0f59d97e782a17c15f3e404ff03fa2 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 12:08:47 +0100 Subject: [PATCH 7/7] =?UTF-8?q?fix(frontend):=20FR=20change=20`````=20and?= =?UTF-8?q?=20``=C2=B4``=20to=20``'``?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/locales/fr.json | 68 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 102825acc..0ab1a62d4 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -23,7 +23,7 @@ "choose-another-community": "Choisissez une autre communauté", "community": "Communauté", "communityMember": "Vous etes un membre actif", - "continue-to-registration": "Continuez l´inscription", + "continue-to-registration": "Continuez l'inscription", "moderator": "Modérateur", "moderators": "Modérateurs", "myContributions": "Mes contributions", @@ -43,20 +43,20 @@ "deleted": "Supprimé", "denied": "supprimé", "in_progress": "Il y a une question du modérateur.", - "myContributionNoteList": "À tout moment vous pouvez éditer ou supprimer les données qui n´ont pas été confirmées.", + "myContributionNoteList": "À tout moment vous pouvez éditer ou supprimer les données qui n'ont pas été confirmées.", "pending": "Inscription en attente de validation" }, "date": "Contribution pour:", "delete": "Supprimer la contribution! Êtes-vous sûr?", "deleted": "La contribution a été supprimée! Mais elle restera visible.", "formText": { - "bringYourTalentsTo": "Apportez vos talents à la communauté! Votre participation bénévole sera récompensée de 20 GDD/heure jusqu´à un plafond de 1000 GDD/mois.", - "describeYourCommunity": "Décrivez votre activité/service à la communauté en mentionnant le nombre d´heures, et calculez le montant à raison de 20 GDD/heure! Après confirmation par l´un de nos collaborateurs, le montant sera crédité sur votre compte.", + "bringYourTalentsTo": "Apportez vos talents à la communauté! Votre participation bénévole sera récompensée de 20 GDD/heure jusqu'à un plafond de 1000 GDD/mois.", + "describeYourCommunity": "Décrivez votre activité/service à la communauté en mentionnant le nombre d'heures, et calculez le montant à raison de 20 GDD/heure! Après confirmation par l'un de nos collaborateurs, le montant sera crédité sur votre compte.", "maxGDDforMonth": "Vous pouvez seulement déclarer un montant maximum de (montant) GDD pour le mois sélectionné.", "openAmountForMonth": "Pour {monthAndYear}, vous pouvez encore déclarer {creation} GDD.", "yourContribution": "Votre contribution au bien commun" }, - "noDateSelected": "Choisissez n´importe quelle date du mois", + "noDateSelected": "Choisissez n'importe quelle date du mois", "selectDate": "Quand a été effectuée votre contribution?", "submit": "Soumettre", "submitted": "La contribution a été soumise.", @@ -70,7 +70,7 @@ "contributionText": "Texte de la contribution", "creation": "Création", "decay": { - "before_startblock_transaction": "Cette transaction n´est pas péremptoire.", + "before_startblock_transaction": "Cette transaction n'est pas péremptoire.", "calculation_decay": "Calcul de la décroissance", "calculation_total": "Calcul du montant total", "decay": "Décroissance", @@ -94,9 +94,9 @@ "email-already-sent": "Nous vous avons déjà envoyé un email il y a moins de 10 minutes.", "empty-transactionlist": "Il y a eu une erreur lors de la transmission du numéro de votre transaction.", "error": "Erreur!", - "no-account": "Malheureusement nous n´avons pas pu trouver de compte (actif) correspondant aux données transmises.", - "no-transactionlist": "Il y a malheureusement eu une erreur. Aucune transaction n´a été envoyée depuis l`serveur.", - "no-user": "Pas d`utilisateur pour cet identifiant.", + "no-account": "Malheureusement nous n'avons pas pu trouver de compte (actif) correspondant aux données transmises.", + "no-transactionlist": "Il y a malheureusement eu une erreur. Aucune transaction n'a été envoyée depuis l'serveur.", + "no-user": "Pas d'utilisateur pour cet identifiant.", "session-expired": "La session a expiré pour des raisons de sécurité.", "unknown-error": "Erreur inconnue: " }, @@ -131,7 +131,7 @@ "memo": "Note", "message": "Message", "new_balance": "Montant du solde après confirmation", - "no_gdd_available": "Vous n´avez pas de GDD à envoyer.", + "no_gdd_available": "Vous n'avez pas de GDD à envoyer.", "password": "Mot de passe", "passwordRepeat": "Répétez le mot de passe", "password_new": "Nouveau mot de passe", @@ -145,7 +145,7 @@ "sender": "Expéditeur", "send_check": "Confirmez la transaction. Veuillez revérifier toutes les données svp!", "send_now": "Envoyez maintenant", - "send_transaction_error": "Malheureusement, la transaction n´a pas pu être effectuée!", + "send_transaction_error": "Malheureusement, la transaction n'a pas pu être effectuée!", "send_transaction_success": "Votre transaction a été effectuée avec succès", "sorry": "Désolé", "thx": "Merci", @@ -155,8 +155,8 @@ "gddCreationTime": "Le champ {_field_} doit comprendre un nombre entre {min} et {max} avec un maximum de une décimale.", "gddSendAmount": "Le champ {_field_} doit comprendre un nombre entre {min} et {max} avec un maximum de deux chiffres après la virgule", "is-not": "Vous ne pouvez pas vous envoyer de Gradido à vous-même", - "usernmae-regex": "Le nom d´utilisateur doit commencer par une lettre, suivi d´au moins deux caractères alphanumériques.", - "usernmae-unique": "Ce nom d´utilisateur est déjà pris." + "usernmae-regex": "Le nom d'utilisateur doit commencer par une lettre, suivi d'au moins deux caractères alphanumériques.", + "usernmae-unique": "Ce nom d'utilisateur est déjà pris." }, "your_amount": "Votre montant" }, @@ -167,7 +167,7 @@ "copy-link": "Copier le lien", "copy-link-with-text": "Copier le lien et le texte", "created": "Le lien a été créé!", - "credit-your-gradido": "Pour l´accréditation du Gradido, cliquer sur le lien!", + "credit-your-gradido": "Pour l'accréditation du Gradido, cliquer sur le lien!", "delete-the-link": "Supprimer le lien?", "deleted": "Le lien a été supprimé!", "expiredOn": "A expiré le", @@ -177,13 +177,13 @@ "link-and-text-copied": "Le lien et votre message ont été copiés dans le presse-papier. Vous pouvez maintenant le joindre à un email ou à un message..", "link-copied": "Le lien a été copié dans le presse-papier. Vous pouvez désormais le coller dans votre email ou votre message.", "link-deleted": "Le lien a été supprimé le on {date}.", - "link-expired": "Le lien n´est plus valide. Sa validité a expiré le {date}.", + "link-expired": "Le lien n'est plus valide. Sa validité a expiré le {date}.", "link-hint": "Attention : tout le monde peut utiliser ce lien. Veuillez en prendre soin!", "link-overview": "Aperçu du lien", "links_count": "Liens actifs", "links_sum": "Ouvrir les liens et les QR codes", - "no-account": "Vous n´avez pas encore de compte Gradido?", - "no-redeem": "Vous n´êtes pas autorisé à percevoir votre propre lien!", + "no-account": "Vous n'avez pas encore de compte Gradido?", + "no-redeem": "Vous n'êtes pas autorisé à percevoir votre propre lien!", "not-copied": "Malheureusement votre appareil ne permet pas de copier! Veuillez copier le lien manuellement svp!", "redeem": "Encaisser", "redeemed": "Encaissé avec succès! Votre compte est crédité de {n} GDD.", @@ -191,8 +191,8 @@ "redeemed-title": "encaisser", "to-login": "Connexion", "to-register": "Enregistrer un nouveau compte.", - "validUntil": "Valide jusqu´au", - "validUntilDate": "Le lien est valide jusqu´au {date}." + "validUntil": "Valide jusqu'au", + "validUntilDate": "Le lien est valide jusqu'au {date}." }, "GDT": "GDT", "gdt": { @@ -208,7 +208,7 @@ "gdt-received": "Gradido Transform (GDT) perçu", "gdtKonto": "Compte GDT", "no-transactions": "Vous ne possédez pas encore Gradido Transform (GDT).", - "not-reachable": "Le Serveur GDT n´est pas accessible.", + "not-reachable": "Le Serveur GDT n'est pas accessible.", "publisher": "Un membre que vous avez référé a apporté un contribution", "raise": "Augmentation", "recruited-member": "Membre invité" @@ -226,15 +226,15 @@ "maxReached": "Max. atteint", "member": "Membre", "message": { - "activateEmail": "Votre compte n´a pas encore été activé. Veuillez vérifier vos emails et cliquer sur le lien d´activation ou faites la demande d´un nouveau lien en utilisant la page qui permet de générer un nouveau mot de passe.", + "activateEmail": "Votre compte n'a pas encore été activé. Veuillez vérifier vos emails et cliquer sur le lien d'activation ou faites la demande d'un nouveau lien en utilisant la page qui permet de générer un nouveau mot de passe.", "checkEmail": "Votre email a bien été vérifié. Vous pouvez vous enregistrer maintenant.", "email": "Nous vous avons envoyé un email.", "errorTitle": "Attention!", - "register": "Vous êtes enregistré maintenant, merci de vérifier votre boîte mail et cliquer sur le lien d´activation.", + "register": "Vous êtes enregistré maintenant, merci de vérifier votre boîte mail et cliquer sur le lien d'activation.", "reply": "Merci, ta réponse a été envoyée.", "reset": "Votre mot de passe a été modifié.", "title": "Merci!", - "unsetPassword": "Votre mot de passe n´a pas été accepté. Merci de le réinitialiser." + "unsetPassword": "Votre mot de passe n'a pas été accepté. Merci de le réinitialiser." }, "navigation": { "admin_area": "Partie administrative", @@ -262,7 +262,7 @@ "send_per_link": "Envoyer GDD via lien", "session": { "extend": "Rester connecter", - "lightText": "S´il n´apparaît aucune activité pendant plus de 10 minutes, la session expirera pour des raisons de sécurité.", + "lightText": "S'il n'apparaît aucune activité pendant plus de 10 minutes, la session expirera pour des raisons de sécurité.", "logoutIn": "Se déconnecter ", "warningText": "Êtes-vous toujours connecté?" }, @@ -285,12 +285,12 @@ "newsletter": { "newsletter": "Information par email", "newsletterFalse": "Vous ne recevrez aucune information par email.", - "newsletterTrue": "Vous recevrez de l´information par email." + "newsletterTrue": "Vous recevrez de l'information par email." }, "password": { "change-password": "Changer le mot de passe", "forgot_pwd": "Mot de passe oublié?", - "resend_subtitle": "Votre lien d´activation a expiré, vous pouvez en obtenir un nouveau ici.", + "resend_subtitle": "Votre lien d'activation a expiré, vous pouvez en obtenir un nouveau ici.", "reset": "Réinitialiser le mot de passe", "reset-password": { "text": "Entrez un nouveau mot de passe que vous utiliserez dans le futur pour vous connecter à votre compte Gradido.." @@ -305,21 +305,21 @@ "showAmountGDD": "Votre montant GDD est visible.", "showAmountGDT": "Votre montant GDT est visible." }, - "signin": "S´identifier", - "signup": "S´inscrire", + "signin": "S'identifier", + "signup": "S'inscrire", "site": { "forgotPassword": { - "heading": "Veuillez entrer l´adresse email sous laquelle vous êtes enregistré ici svp." + "heading": "Veuillez entrer l'adresse email sous laquelle vous êtes enregistré ici svp." }, "resetPassword": { - "heading": "Entrez votre mot de passe et répétez l´action svp." + "heading": "Entrez votre mot de passe et répétez l'action svp." }, "signup": { - "agree": "J´accepte le politique de confidentialité .", + "agree": "J'accepte le politique de confidentialité .", "dont_match": "Les mots de passe ne correspondent pas.", "lowercase": "Une lettre minuscule est requise.", "minimum": "8 caractères minimum.", - "no-whitespace": "Pas d´espace ni d´onglet", + "no-whitespace": "Pas d'espace ni d'onglet", "one_number": "Un chiffre requis.", "special-char": "Un caractère spécial requis (e.g. _ or ä)", "uppercase": "Une lettre majuscule requise." @@ -339,8 +339,8 @@ }, "transaction": { "lastTransactions": "Dernières transactions", - "nullTransactions": "Vous n´avez pas encore de transaction effectuée sur votre compte.", - "receiverDeleted": "Le compte du destinataire n´existe plus", + "nullTransactions": "Vous n'avez pas encore de transaction effectuée sur votre compte.", + "receiverDeleted": "Le compte du destinataire n'existe plus", "receiverNotFound": "Destinataire inconnu", "show_all": "Voir toutes les {count} transactions." },