diff --git a/lib/generate-report.js b/lib/generate-report.js index 13f44dcc..4c395ca9 100755 --- a/lib/generate-report.js +++ b/lib/generate-report.js @@ -406,22 +406,20 @@ function generateReport(options) { scenario.steps.forEach((step) => { if (step.embeddings !== undefined) { step.attachments = []; - step.embeddings.forEach((embedding, embeddingIndex) => { /* Decode Base64 for Text-ish attachements */ - if( - embedding.mime_type === 'application/json' || - embedding.mime_type === 'text/html' || - embedding.mime_type === 'text/plain' + if( + embedding.mime_type === 'text/html' || + embedding.mime_type === 'text/plain' ) { - embedding.data = Buffer.from(embedding.data.toString(), 'base64') - } - + embedding.data = Buffer.from(embedding.data.toString(), 'base64') + } /* istanbul ignore else */ if ( embedding.mime_type === 'application/json' || (embedding.media && embedding.media.type === 'application/json') ) { + embedding.data = Buffer.from(embedding.data, 'base64').toString() step.json = (step.json ? step.json : []).concat([ typeof embedding.data === 'string' ? JSON.parse(embedding.data) diff --git a/test/unit/data/custom-metadata-json/multiple_different_attachements.json b/test/unit/data/custom-metadata-json/multiple_different_attachements.json index 08a7e5ab..5f4ebc62 100644 --- a/test/unit/data/custom-metadata-json/multiple_different_attachements.json +++ b/test/unit/data/custom-metadata-json/multiple_different_attachements.json @@ -53,13 +53,13 @@ }, "embeddings": [ { - "data": "{\"some\":\"json\"}", + "data": "eyJzb21lIjoianNvbiJ9", "media": { "type": "application/json" } }, { - "data": "{\"other\":\"json\"}", + "data": "eyJvdGhlciI6Impzb24ifQ==", "media": { "type": "application/json" } @@ -71,13 +71,13 @@ } }, { - "data": "{\"yet another json\":5}", + "data": "eyJ5ZXQgYW5vdGhlciBqc29uIjo1fQ==", "media": { "type": "application/json" } }, { - "data": 0, + "data": "MA==", "media": { "type": "application/json" } diff --git a/test/unit/data/custom-metadata-json/undefined_scenarios_specified_v3.json b/test/unit/data/custom-metadata-json/undefined_scenarios_specified_v3.json index 6e4f8cc6..aab62f67 100644 --- a/test/unit/data/custom-metadata-json/undefined_scenarios_specified_v3.json +++ b/test/unit/data/custom-metadata-json/undefined_scenarios_specified_v3.json @@ -131,13 +131,13 @@ }, "embeddings": [ { - "data": "{\"some\":\"json\"}", + "data": "eyJzb21lIjoianNvbiJ9", "media": { "type": "application/json" } }, { - "data": "{\"other\":\"json\"}", + "data": "eyJvdGhlciI6Impzb24ifQ==", "media": { "type": "application/json" } @@ -149,7 +149,7 @@ } }, { - "data": "{\"yet another json\":5}", + "data": "eyJ5ZXQgYW5vdGhlciBqc29uIjo1fQ==", "media": { "type": "application/json" } diff --git a/test/unit/data/json/before-and-after-hook.json b/test/unit/data/json/before-and-after-hook.json index 10434284..e1229018 100644 --- a/test/unit/data/json/before-and-after-hook.json +++ b/test/unit/data/json/before-and-after-hook.json @@ -83,9 +83,7 @@ "mime_type": "text/plain" }, { - "data": { - "json-string": true - }, + "data": "eyJqc29uLXN0cmluZyI6IHRydWV9", "mime_type": "application/json" } ] diff --git a/test/unit/data/json/embeddings.json b/test/unit/data/json/embeddings.json index d6642c98..9fdccb8b 100644 --- a/test/unit/data/json/embeddings.json +++ b/test/unit/data/json/embeddings.json @@ -28,7 +28,7 @@ }, "embeddings": [ { - "data": "[{\"data\":{\"x\":\"1\",\"y\":\"1\",\"url\":\"http://url.com\"},\"event\":\"start\",\"show\":1,\"id\":50},{\"data\":{\"x\":\"2\",\"y\":\"3\",\"url\":\"http://example.com\"},\"event\":\"stop\",\"show\":2,\"id\":51}]", + "data": "W3siZGF0YSI6eyJ4IjoiMSIsInkiOiIxIiwidXJsIjoiaHR0cDovL3VybC5jb20ifSwiZXZlbnQiOiJzdGFydCIsInNob3ciOjEsImlkIjo1MH0seyJkYXRhIjp7IngiOiIyIiwieSI6IjMiLCJ1cmwiOiJodHRwOi8vZXhhbXBsZS5jb20ifSwiZXZlbnQiOiJzdG9wIiwic2hvdyI6MiwiaWQiOjUxfV0=", "mime_type": "application/json" }, { diff --git a/test/unit/data/output/merged-output.json b/test/unit/data/output/merged-output.json index 657c35cf..06059062 100644 --- a/test/unit/data/output/merged-output.json +++ b/test/unit/data/output/merged-output.json @@ -1090,9 +1090,7 @@ "mime_type": "text/plain" }, { - "data": { - "json-string": true - }, + "data": "eyJqc29uLXN0cmluZyI6IHRydWV9", "mime_type": "application/json" } ] @@ -1265,7 +1263,7 @@ }, "embeddings": [ { - "data": "[{\"data\":{\"x\":\"1\",\"y\":\"1\",\"url\":\"http://url.com\"},\"event\":\"start\",\"show\":1,\"id\":50},{\"data\":{\"x\":\"2\",\"y\":\"3\",\"url\":\"http://example.com\"},\"event\":\"stop\",\"show\":2,\"id\":51}]", + "data": "W3siZGF0YSI6eyJ4IjoiMSIsInkiOiIxIiwidXJsIjoiaHR0cDovL3VybC5jb20ifSwiZXZlbnQiOiJzdGFydCIsInNob3ciOjEsImlkIjo1MH0seyJkYXRhIjp7IngiOiIyIiwieSI6IjMiLCJ1cmwiOiJodHRwOi8vZXhhbXBsZS5jb20ifSwiZXZlbnQiOiJzdG9wIiwic2hvdyI6MiwiaWQiOjUxfV0=", "mime_type": "application/json" }, {