From 67e54b26da03a07b39c7d1af6b63f989ac7c6664 Mon Sep 17 00:00:00 2001 From: Carolina Wright Date: Tue, 25 Jan 2022 10:51:10 -0300 Subject: [PATCH] test: optional field to overwrite content type is rendered for multipart body (#742) --- demo/apis.json | 3 +- demo/models/multipart-api/multipart-api.raml | 29 +++++++++++++++ test/api-console-request.test.js | 39 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 demo/models/multipart-api/multipart-api.raml diff --git a/demo/apis.json b/demo/apis.json index 3f5b6e0d3..8a6d69dd8 100644 --- a/demo/apis.json +++ b/demo/apis.json @@ -31,5 +31,6 @@ "models/streetlights/streetlights.yaml": "ASYNC 2.0", "models/visual-tests-raml/visual-tests-raml.raml": "RAML 1.0", "models/representative-service/representative-service.yaml": "OAS 3.0", - "models/APIC-763/APIC-763.raml": "RAML 1.0" + "models/APIC-763/APIC-763.raml": "RAML 1.0", + "models/multipart-api/multipart-api.raml": "RAML 1.0" } diff --git a/demo/models/multipart-api/multipart-api.raml b/demo/models/multipart-api/multipart-api.raml new file mode 100644 index 000000000..e2358c62e --- /dev/null +++ b/demo/models/multipart-api/multipart-api.raml @@ -0,0 +1,29 @@ +#%RAML 1.0 +title: Social Determinants of Health +version: v1 +protocols: + - HTTP + - HTTPS +/sdoh: + post: + headers: + clientId: + example: Example + type: string + clientSecret: + example: Example + type: string + body: + multipart/form-data: + properties: + file: + fileTypes: + - "*/*" + - text/plain + responses: + "200": + body: + application/json: + type: object + "201": {} + securedBy: [] \ No newline at end of file diff --git a/test/api-console-request.test.js b/test/api-console-request.test.js index bfcc26a65..523ce47d8 100644 --- a/test/api-console-request.test.js +++ b/test/api-console-request.test.js @@ -778,4 +778,43 @@ describe('API Console request', () => { }); }); }); + + [ + new ApiDescribe('Regular model'), + new ApiDescribe('Compact model', true) + ].forEach(({ label, compact }) => { + describe(label, () => { + let element; + let amf; + + describe('Multipart payload', () => { + before(async () => { + amf = await AmfLoader.load({ compact, fileName: 'multipart-api' }); + }); + + beforeEach(async () => { + element = await amfFixture(amf); + await navigationSelectEndpointMethod(element, '/sdoh', 'post'); + // @ts-ignore + (await documentationTryItButton(element)).click(); + await aTimeout(50); + }); + + it('should render request panel with optional field to overwrite content type', () => { + const requestBody = requestBodySection(element); + assert.exists(requestBody); + + const multipartPayload = requestBody.shadowRoot.querySelector('multipart-payload-editor'); + assert.exists(multipartPayload); + + const multipartFileForm = multipartPayload.shadowRoot.querySelector('multipart-file-form-item'); + assert.exists(multipartFileForm); + + const inputLabel = multipartFileForm.shadowRoot.querySelector('anypoint-input').querySelector('label'); + assert.exists(inputLabel); + assert.equal(inputLabel.innerText, 'Content type (Optional)'); + }); + }); + }); + }); });