From f344142e3e1aaa2802e6a1d5b9b02f9387623567 Mon Sep 17 00:00:00 2001 From: Manuel Ruck Date: Mon, 1 Jul 2024 20:31:43 +0200 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=A7=AA=20is=20not=20allowed=20to?= =?UTF-8?q?=20update=20notification=20settings=20without=20device=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Ruck --- src/graphql/resolvers/Device.integ.ts | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/graphql/resolvers/Device.integ.ts b/src/graphql/resolvers/Device.integ.ts index ac80a4a..c12d903 100644 --- a/src/graphql/resolvers/Device.integ.ts +++ b/src/graphql/resolvers/Device.integ.ts @@ -82,6 +82,7 @@ describe('Device GraphQL API', () => { expect(data.updateNotificationSettings.voteTOP100Pushs).toBeTruthy(); expect(data.updateNotificationSettings.outcomePushs).toBeTruthy(); }); + it('get updated notification settings', async () => { const response = await axios.post( GRAPHQL_API_URL, @@ -116,6 +117,45 @@ describe('Device GraphQL API', () => { expect(data.notificationSettings.voteTOP100Pushs).toBeTruthy(); expect(data.notificationSettings.outcomePushs).toBeTruthy(); }); + + it('is not allowed to update notification settings without device hash', async () => { + const response = await axios.post( + GRAPHQL_API_URL, + { + query: ` + mutation UpdateNotificationSettings($enabled: Boolean!, $conferenceWeekPushs: Boolean!, $voteConferenceWeekPushs: Boolean!, $voteTOP100Pushs: Boolean!, $outcomePushs: Boolean!) { + updateNotificationSettings(enabled: $enabled, conferenceWeekPushs: $conferenceWeekPushs, voteConferenceWeekPushs: $voteConferenceWeekPushs, voteTOP100Pushs: $voteTOP100Pushs, outcomePushs: $outcomePushs) { + enabled + conferenceWeekPushs + voteConferenceWeekPushs + voteTOP100Pushs + outcomePushs + } + } + `, + variables: { + enabled: true, + conferenceWeekPushs: true, + voteConferenceWeekPushs: true, + voteTOP100Pushs: true, + outcomePushs: true, + }, + }, + { + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + const error = response.data.errors.find((e) => e.path.includes('updateNotificationSettings')); + if (error) { + expect(error.message).toBe('Not Authorised!'); + expect(response.data.notificationSettings).toBeUndefined(); + } else { + expect(true).toBeFalsy(); + } + }); }); describe('verify device', () => {