From 97a857044feada2ffb188c267a63d2095703d6ab Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 10 Jun 2026 14:18:29 +0200 Subject: [PATCH] Be more permissive around handling gender data Previously, we required all gender data to be in the payload. That is not always the case. So we changed the behavior to accept either empty payloads or payloads with all four values. --- fixtures/anchorPlaysByGenderEmpty.json | 35 +++++++++++++++++++++++++ src/schema/anchor/playsByGender.json | 36 ++++++++++++++++++-------- tests/api_e2e/anchor.test.js | 11 ++++++++ 3 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 fixtures/anchorPlaysByGenderEmpty.json diff --git a/fixtures/anchorPlaysByGenderEmpty.json b/fixtures/anchorPlaysByGenderEmpty.json new file mode 100644 index 00000000..15365708 --- /dev/null +++ b/fixtures/anchorPlaysByGenderEmpty.json @@ -0,0 +1,35 @@ +{ + "provider": "anchor", + "version": 1, + "retrieved": "2023-05-05T16:20:56.696026", + "meta": { + "show": "123abcde", + "endpoint": "playsByGender" + }, + "range": { + "start": "2023-05-01", + "end": "2023-05-04" + }, + "data": { + "stationId": 98765432, + "kind": "playsByGender", + "parameters": { + "timeRange": [] + }, + "data": { + "rows": [], + "columnHeaders": [ + { + "name": "Gender", + "type": "string" + }, + { + "name": "Percent of Plays", + "type": "number" + } + ], + "translationMapping": {}, + "colors": {} + } + } +} diff --git a/src/schema/anchor/playsByGender.json b/src/schema/anchor/playsByGender.json index b0f7facd..9f8b0ab2 100644 --- a/src/schema/anchor/playsByGender.json +++ b/src/schema/anchor/playsByGender.json @@ -100,11 +100,18 @@ "type": "string" } }, - "required": [ - "Female", - "Male", - "Non-binary", - "Not specified" + "anyOf": [ + { + "maxProperties": 0 + }, + { + "required": [ + "Female", + "Male", + "Non-binary", + "Not specified" + ] + } ] }, "columnHeaders": { @@ -141,11 +148,18 @@ "type": "string" } }, - "required": [ - "Male", - "Female", - "Not specified", - "Non-binary" + "anyOf": [ + { + "maxProperties": 0 + }, + { + "required": [ + "Male", + "Female", + "Not specified", + "Non-binary" + ] + } ] } }, @@ -172,4 +186,4 @@ "meta", "data" ] -} \ No newline at end of file +} diff --git a/tests/api_e2e/anchor.test.js b/tests/api_e2e/anchor.test.js index 9125f521..618c1bed 100644 --- a/tests/api_e2e/anchor.test.js +++ b/tests/api_e2e/anchor.test.js @@ -11,6 +11,7 @@ const anchorPlaysByAgeRangePayload = require('../../fixtures/anchorPlaysByAgeRan const anchorPlaysByAppPayload = require('../../fixtures/anchorPlaysByApp.json') const anchorPlaysByDevicePayload = require('../../fixtures/anchorPlaysByDevice.json') const anchorPlaysByGenderPayload = require('../../fixtures/anchorPlaysByGender.json') +const anchorPlaysByGenderEmptyPayload = require('../../fixtures/anchorPlaysByGenderEmpty.json') const anchorPlaysByGeoPayload = require('../../fixtures/anchorPlaysByGeo.json') const anchorPodcastEpisodePayload = require('../../fixtures/anchorPodcastEpisode.json') const anchorTotalPlaysPayload = require('../../fixtures/anchorTotalPlays.json') @@ -170,6 +171,16 @@ describe('check Connector API with anchorPlaysByGenderPayload', () => { }) }) +describe('check Connector API with anchorPlaysByGenderEmptyPayload', () => { + it('should return status 200 when sending Anchor playsByGender payload with empty translationMapping and colors', async () => { + const response = await request(baseURL) + .post('/connector') + .set(auth) + .send(anchorPlaysByGenderEmptyPayload) + expect(response.statusCode).toBe(200) + }) +}) + describe('check Connector API with anchorPlaysByGeoPayload', () => { it('should return status 200 when sending proper Anchor payload', async () => { const response = await request(baseURL)