diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index e71fbffa3..ca19f03c4 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -62,7 +62,7 @@ describe('CreateInvitationCode', () => { name: 'Inviter', email: 'inviter@example.org', password: '1234', - termsAndConditionsAgreedVersion: '0.0.1', + termsAndConditionsAgreedVersion: null, }) authenticatedUser = await user.toJson() }) @@ -352,8 +352,7 @@ describe('SignupVerification', () => { name: 'John Doe', password: '123', email: 'john@example.org', - termsAndConditionsAgreedVersion: null, - termsAndConditionsAgreedAt: null, + termsAndConditionsAgreedVersion: '0.1.0', } }) @@ -446,6 +445,16 @@ describe('SignupVerification', () => { expect(emails).toHaveLength(1) }) + it('updates termsAndConditionsAgreedVersion', async () => { + await expect(mutate({ mutation, variables })).resolves.toMatchObject({ + data: { + SignupVerification: expect.objectContaining({ + termsAndConditionsAgreedVersion: '0.1.0', + }), + }, + }) + }) + it('updates termsAndConditionsAgreedAt', async () => { await expect(mutate({ mutation, variables })).resolves.toMatchObject({ data: { @@ -456,6 +465,18 @@ describe('SignupVerification', () => { }) }) + it('rejects if version of terms and conditions is missing', async () => { + variables = { ...variables, termsAndConditionsAgreedVersion: null } + await expect(mutate({ mutation, variables })).resolves.toMatchObject({ + errors: [ + { + message: + 'Variable "$termsAndConditionsAgreedVersion" of non-null type "String!" must not be null.', + }, + ], + }) + }) + it('rejects if version of terms and conditions has wrong format', async () => { variables = { ...variables, termsAndConditionsAgreedVersion: 'invalid version format' } await expect(mutate({ mutation, variables })).resolves.toMatchObject({ diff --git a/backend/src/schema/types/type/EmailAddress.gql b/backend/src/schema/types/type/EmailAddress.gql index 7501a3e8c..4bf8ff724 100644 --- a/backend/src/schema/types/type/EmailAddress.gql +++ b/backend/src/schema/types/type/EmailAddress.gql @@ -18,7 +18,6 @@ type Mutation { avatarUpload: Upload locationName: String about: String - termsAndConditionsAgreedVersion: String - termsAndConditionsAgreedAt: String + termsAndConditionsAgreedVersion: String! ): User }