From 97dad41b27c3d486c530cc50a41f87878b271f73 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Oct 2019 15:01:07 +0200 Subject: [PATCH 01/14] Set language will be saved in the database of the user during registration --- backend/src/models/User.js | 4 ++++ backend/src/schema/types/type/EmailAddress.gql | 1 + backend/src/schema/types/type/User.gql | 3 +++ backend/src/seed/factories/users.js | 1 + webapp/components/Registration/CreateUserAccount.spec.js | 1 + webapp/components/Registration/CreateUserAccount.vue | 3 ++- webapp/graphql/Registration.js | 2 ++ 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/src/models/User.js b/backend/src/models/User.js index 86900c3ae..55dc95609 100644 --- a/backend/src/models/User.js +++ b/backend/src/models/User.js @@ -108,5 +108,9 @@ module.exports = { allowEmbedIframes: { type: 'boolean', default: false, + }, + language: { + type: 'string', + allow: [null], }, } diff --git a/backend/src/schema/types/type/EmailAddress.gql b/backend/src/schema/types/type/EmailAddress.gql index 1748139bd..f338e019f 100644 --- a/backend/src/schema/types/type/EmailAddress.gql +++ b/backend/src/schema/types/type/EmailAddress.gql @@ -19,6 +19,7 @@ type Mutation { locationName: String about: String termsAndConditionsAgreedVersion: String! + language: String ): User AddEmailAddress(email: String!): EmailAddress VerifyEmailAddress( diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index d9084dd90..51a507670 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -29,6 +29,8 @@ type User { allowEmbedIframes: Boolean + language: String + friends: [User]! @relation(name: "FRIENDS", direction: "BOTH") friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)") @@ -169,6 +171,7 @@ type Mutation { termsAndConditionsAgreedVersion: String termsAndConditionsAgreedAt: String allowEmbedIframes: Boolean + language: String ): User DeleteUser(id: ID!, resource: [Deletable]): User diff --git a/backend/src/seed/factories/users.js b/backend/src/seed/factories/users.js index b65be795d..70d626c62 100644 --- a/backend/src/seed/factories/users.js +++ b/backend/src/seed/factories/users.js @@ -17,6 +17,7 @@ export default function create() { termsAndConditionsAgreedVersion: '0.0.1', termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z', allowEmbedIframes: false, + language: 'en', } defaults.slug = slugify(defaults.name, { lower: true }) args = { diff --git a/webapp/components/Registration/CreateUserAccount.spec.js b/webapp/components/Registration/CreateUserAccount.spec.js index 3bea5a975..5909d616c 100644 --- a/webapp/components/Registration/CreateUserAccount.spec.js +++ b/webapp/components/Registration/CreateUserAccount.spec.js @@ -85,6 +85,7 @@ describe('CreateUserAccount', () => { nonce: '666777', password: 'hellopassword', termsAndConditionsAgreedVersion: '0.0.2', + language: 'en', }, }) expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) diff --git a/webapp/components/Registration/CreateUserAccount.vue b/webapp/components/Registration/CreateUserAccount.vue index 7fc64a545..745278fa3 100644 --- a/webapp/components/Registration/CreateUserAccount.vue +++ b/webapp/components/Registration/CreateUserAccount.vue @@ -154,10 +154,11 @@ export default { const { name, password, about } = this.formData const { email, nonce } = this const termsAndConditionsAgreedVersion = VERSION + const language = this.$i18n.locale() try { await this.$apollo.mutate({ mutation: SignupVerificationMutation, - variables: { name, password, about, email, nonce, termsAndConditionsAgreedVersion }, + variables: { name, password, about, email, nonce, termsAndConditionsAgreedVersion, language }, }) this.response = 'success' setTimeout(() => { diff --git a/webapp/graphql/Registration.js b/webapp/graphql/Registration.js index 4a24f626a..eab2b94be 100644 --- a/webapp/graphql/Registration.js +++ b/webapp/graphql/Registration.js @@ -7,6 +7,7 @@ export const SignupVerificationMutation = gql` $password: String! $about: String $termsAndConditionsAgreedVersion: String! + $language: String ) { SignupVerification( nonce: $nonce @@ -15,6 +16,7 @@ export const SignupVerificationMutation = gql` password: $password about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion + language: $language ) { id name From dd2efad9374abdbdb00fb64ee17674f6c6a924f2 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Oct 2019 15:02:17 +0200 Subject: [PATCH 02/14] fix lint --- backend/src/models/User.js | 2 +- webapp/components/Registration/CreateUserAccount.vue | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/models/User.js b/backend/src/models/User.js index 55dc95609..3096e4b54 100644 --- a/backend/src/models/User.js +++ b/backend/src/models/User.js @@ -108,7 +108,7 @@ module.exports = { allowEmbedIframes: { type: 'boolean', default: false, - }, + }, language: { type: 'string', allow: [null], diff --git a/webapp/components/Registration/CreateUserAccount.vue b/webapp/components/Registration/CreateUserAccount.vue index 745278fa3..c17302343 100644 --- a/webapp/components/Registration/CreateUserAccount.vue +++ b/webapp/components/Registration/CreateUserAccount.vue @@ -158,7 +158,15 @@ export default { try { await this.$apollo.mutate({ mutation: SignupVerificationMutation, - variables: { name, password, about, email, nonce, termsAndConditionsAgreedVersion, language }, + variables: { + name, + password, + about, + email, + nonce, + termsAndConditionsAgreedVersion, + language, + }, }) this.response = 'success' setTimeout(() => { From 54465c04a3e0f6183278e67b5ffa0671c64b1e15 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 17 Oct 2019 08:26:15 +0200 Subject: [PATCH 03/14] Fix Jest tests --- .../src/schema/resolvers/registration.spec.js | 6 +++- .../Registration/CreateUserAccount.spec.js | 15 ++++++---- .../Registration/CreateUserAccount.vue | 28 ++++++++++--------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index 0f3af5a8d..29116ef70 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -290,7 +290,8 @@ describe('Signup', () => { it('throws AuthorizationError', async () => { await expect(mutate({ mutation, variables })).resolves.toMatchObject({ - errors: [{ message: 'Not Authorised!' }], + // errors: [{ message: 'Not Authorised!' }], + errors: undefined, }) }) @@ -381,6 +382,7 @@ describe('SignupVerification', () => { $nonce: String! $about: String $termsAndConditionsAgreedVersion: String! + $language: String ) { SignupVerification( name: $name @@ -389,6 +391,7 @@ describe('SignupVerification', () => { nonce: $nonce about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion + language: $language ) { id termsAndConditionsAgreedVersion @@ -405,6 +408,7 @@ describe('SignupVerification', () => { password: '123', email: 'john@example.org', termsAndConditionsAgreedVersion: '0.1.0', + language: 'en', } }) diff --git a/webapp/components/Registration/CreateUserAccount.spec.js b/webapp/components/Registration/CreateUserAccount.spec.js index 5909d616c..6f7abbca8 100644 --- a/webapp/components/Registration/CreateUserAccount.spec.js +++ b/webapp/components/Registration/CreateUserAccount.spec.js @@ -24,6 +24,9 @@ describe('CreateUserAccount', () => { loading: false, mutate: jest.fn(), }, + $i18n: { + locale: () => 'en', + }, } propsData = {} stubs = { @@ -69,12 +72,6 @@ describe('CreateUserAccount', () => { } }) - it('calls CreateUserAccount graphql mutation', async () => { - await action() - const expected = expect.objectContaining({ mutation: SignupVerificationMutation }) - expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) - }) - it('delivers data to backend', async () => { await action() const expected = expect.objectContaining({ @@ -91,6 +88,12 @@ describe('CreateUserAccount', () => { expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) }) + it('calls CreateUserAccount graphql mutation', async () => { + await action() + const expected = expect.objectContaining({ mutation: SignupVerificationMutation }) + expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) + }) + describe('in case mutation resolves', () => { beforeEach(() => { mocks.$apollo.mutate = jest.fn().mockResolvedValue({ diff --git a/webapp/components/Registration/CreateUserAccount.vue b/webapp/components/Registration/CreateUserAccount.vue index c17302343..b8b20d146 100644 --- a/webapp/components/Registration/CreateUserAccount.vue +++ b/webapp/components/Registration/CreateUserAccount.vue @@ -70,22 +70,24 @@ :checked="termsAndConditionsConfirmed" /> -

- -

-

- -

+ + + + + + + + Date: Thu, 17 Oct 2019 09:44:26 +0200 Subject: [PATCH 04/14] remove change --- backend/src/schema/resolvers/registration.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index 29116ef70..180950f94 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -290,8 +290,7 @@ describe('Signup', () => { it('throws AuthorizationError', async () => { await expect(mutate({ mutation, variables })).resolves.toMatchObject({ - // errors: [{ message: 'Not Authorised!' }], - errors: undefined, + errors: [{ message: 'Not Authorised!' }], }) }) From 18fe54e09535012bd4a95c815fef52abf2848982 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 11:49:14 +0200 Subject: [PATCH 05/14] Update Registration.js change language to locale --- webapp/graphql/Registration.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/graphql/Registration.js b/webapp/graphql/Registration.js index eab2b94be..30996e9ee 100644 --- a/webapp/graphql/Registration.js +++ b/webapp/graphql/Registration.js @@ -7,7 +7,7 @@ export const SignupVerificationMutation = gql` $password: String! $about: String $termsAndConditionsAgreedVersion: String! - $language: String + $locale: String ) { SignupVerification( nonce: $nonce @@ -16,7 +16,7 @@ export const SignupVerificationMutation = gql` password: $password about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion - language: $language + language: $locale ) { id name From bfb392302303930dcada35cce98c1094c7d94d29 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 11:50:42 +0200 Subject: [PATCH 06/14] locale change language to locale --- webapp/components/Registration/CreateUserAccount.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/components/Registration/CreateUserAccount.vue b/webapp/components/Registration/CreateUserAccount.vue index b8b20d146..00466a2d3 100644 --- a/webapp/components/Registration/CreateUserAccount.vue +++ b/webapp/components/Registration/CreateUserAccount.vue @@ -156,7 +156,7 @@ export default { const { name, password, about } = this.formData const { email, nonce } = this const termsAndConditionsAgreedVersion = VERSION - const language = this.$i18n.locale() + const locale = this.$i18n.locale() try { await this.$apollo.mutate({ mutation: SignupVerificationMutation, @@ -167,7 +167,7 @@ export default { email, nonce, termsAndConditionsAgreedVersion, - language, + locale, }, }) this.response = 'success' From 0b5c1f831df76f9626e464fa509f094ef19df279 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 11:52:48 +0200 Subject: [PATCH 07/14] locale change language to locale --- webapp/components/Registration/CreateUserAccount.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/components/Registration/CreateUserAccount.spec.js b/webapp/components/Registration/CreateUserAccount.spec.js index 6f7abbca8..fb9bf00f8 100644 --- a/webapp/components/Registration/CreateUserAccount.spec.js +++ b/webapp/components/Registration/CreateUserAccount.spec.js @@ -82,7 +82,7 @@ describe('CreateUserAccount', () => { nonce: '666777', password: 'hellopassword', termsAndConditionsAgreedVersion: '0.0.2', - language: 'en', + locale: 'en', }, }) expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) From 3346048e3eb64d796b90d6f6df61e51f9be27704 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 11:53:29 +0200 Subject: [PATCH 08/14] locale change language to locale --- backend/src/seed/factories/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/seed/factories/users.js b/backend/src/seed/factories/users.js index 70d626c62..99e2681c9 100644 --- a/backend/src/seed/factories/users.js +++ b/backend/src/seed/factories/users.js @@ -17,7 +17,7 @@ export default function create() { termsAndConditionsAgreedVersion: '0.0.1', termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z', allowEmbedIframes: false, - language: 'en', + locale: 'en', } defaults.slug = slugify(defaults.name, { lower: true }) args = { From 6d1bf2c3e8ec67036c3208c5f81dce8fa63018af Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:10:44 +0200 Subject: [PATCH 09/14] locale change language to locale --- backend/src/schema/types/type/EmailAddress.gql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/schema/types/type/EmailAddress.gql b/backend/src/schema/types/type/EmailAddress.gql index f338e019f..99e309602 100644 --- a/backend/src/schema/types/type/EmailAddress.gql +++ b/backend/src/schema/types/type/EmailAddress.gql @@ -19,7 +19,7 @@ type Mutation { locationName: String about: String termsAndConditionsAgreedVersion: String! - language: String + locale: String ): User AddEmailAddress(email: String!): EmailAddress VerifyEmailAddress( From 713feb4347e2f2439006cf2f4b7dea986535f8a9 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:13:01 +0200 Subject: [PATCH 10/14] locale change language to locale --- backend/src/schema/resolvers/registration.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index 180950f94..e79a107e8 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -381,7 +381,7 @@ describe('SignupVerification', () => { $nonce: String! $about: String $termsAndConditionsAgreedVersion: String! - $language: String + $locale: String ) { SignupVerification( name: $name @@ -390,7 +390,7 @@ describe('SignupVerification', () => { nonce: $nonce about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion - language: $language + locale: $language ) { id termsAndConditionsAgreedVersion @@ -407,7 +407,7 @@ describe('SignupVerification', () => { password: '123', email: 'john@example.org', termsAndConditionsAgreedVersion: '0.1.0', - language: 'en', + locale: 'en', } }) From abaa9b775984e358d4867d848226656d3201e37c Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:14:11 +0200 Subject: [PATCH 11/14] locale change language to locale --- backend/src/models/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/models/User.js b/backend/src/models/User.js index 3096e4b54..ece678a1f 100644 --- a/backend/src/models/User.js +++ b/backend/src/models/User.js @@ -109,7 +109,7 @@ module.exports = { type: 'boolean', default: false, }, - language: { + locale: { type: 'string', allow: [null], }, From a6108f6a002a5c6041da50114aacfa1e8d437253 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:15:21 +0200 Subject: [PATCH 12/14] locale change language to locale --- backend/src/schema/types/type/User.gql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 51a507670..1f46dc6cd 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -29,7 +29,7 @@ type User { allowEmbedIframes: Boolean - language: String + locale: String friends: [User]! @relation(name: "FRIENDS", direction: "BOTH") friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)") @@ -171,7 +171,7 @@ type Mutation { termsAndConditionsAgreedVersion: String termsAndConditionsAgreedAt: String allowEmbedIframes: Boolean - language: String + locale: String ): User DeleteUser(id: ID!, resource: [Deletable]): User From 1fce840efb69419999bfc1890f70c7a59c86d62c Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:16:32 +0200 Subject: [PATCH 13/14] locale change language to locale --- webapp/graphql/Registration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/graphql/Registration.js b/webapp/graphql/Registration.js index 30996e9ee..873c855db 100644 --- a/webapp/graphql/Registration.js +++ b/webapp/graphql/Registration.js @@ -16,7 +16,7 @@ export const SignupVerificationMutation = gql` password: $password about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion - language: $locale + locale: $locale ) { id name From f6e87b87ff96e71b75950436cfef650d0fb5143e Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 18 Oct 2019 12:54:55 +0200 Subject: [PATCH 14/14] locale change language to locale --- backend/src/schema/resolvers/registration.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index e79a107e8..c2b83324d 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -390,7 +390,7 @@ describe('SignupVerification', () => { nonce: $nonce about: $about termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion - locale: $language + locale: $locale ) { id termsAndConditionsAgreedVersion