Skip to content

Commit

Permalink
test: optional field to overwrite content type is rendered for multip…
Browse files Browse the repository at this point in the history
…art body (#742)
  • Loading branch information
carowright authored Jan 25, 2022
1 parent c81443b commit 67e54b2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
3 changes: 2 additions & 1 deletion demo/apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
29 changes: 29 additions & 0 deletions demo/models/multipart-api/multipart-api.raml
Original file line number Diff line number Diff line change
@@ -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: []
39 changes: 39 additions & 0 deletions test/api-console-request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
});
});
});
});
});

0 comments on commit 67e54b2

Please sign in to comment.