Skip to content

Commit 67e54b2

Browse files
authored
test: optional field to overwrite content type is rendered for multipart body (#742)
1 parent c81443b commit 67e54b2

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

demo/apis.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
"models/streetlights/streetlights.yaml": "ASYNC 2.0",
3232
"models/visual-tests-raml/visual-tests-raml.raml": "RAML 1.0",
3333
"models/representative-service/representative-service.yaml": "OAS 3.0",
34-
"models/APIC-763/APIC-763.raml": "RAML 1.0"
34+
"models/APIC-763/APIC-763.raml": "RAML 1.0",
35+
"models/multipart-api/multipart-api.raml": "RAML 1.0"
3536
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#%RAML 1.0
2+
title: Social Determinants of Health
3+
version: v1
4+
protocols:
5+
- HTTP
6+
- HTTPS
7+
/sdoh:
8+
post:
9+
headers:
10+
clientId:
11+
example: Example
12+
type: string
13+
clientSecret:
14+
example: Example
15+
type: string
16+
body:
17+
multipart/form-data:
18+
properties:
19+
file:
20+
fileTypes:
21+
- "*/*"
22+
- text/plain
23+
responses:
24+
"200":
25+
body:
26+
application/json:
27+
type: object
28+
"201": {}
29+
securedBy: []

test/api-console-request.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,4 +778,43 @@ describe('API Console request', () => {
778778
});
779779
});
780780
});
781+
782+
[
783+
new ApiDescribe('Regular model'),
784+
new ApiDescribe('Compact model', true)
785+
].forEach(({ label, compact }) => {
786+
describe(label, () => {
787+
let element;
788+
let amf;
789+
790+
describe('Multipart payload', () => {
791+
before(async () => {
792+
amf = await AmfLoader.load({ compact, fileName: 'multipart-api' });
793+
});
794+
795+
beforeEach(async () => {
796+
element = await amfFixture(amf);
797+
await navigationSelectEndpointMethod(element, '/sdoh', 'post');
798+
// @ts-ignore
799+
(await documentationTryItButton(element)).click();
800+
await aTimeout(50);
801+
});
802+
803+
it('should render request panel with optional field to overwrite content type', () => {
804+
const requestBody = requestBodySection(element);
805+
assert.exists(requestBody);
806+
807+
const multipartPayload = requestBody.shadowRoot.querySelector('multipart-payload-editor');
808+
assert.exists(multipartPayload);
809+
810+
const multipartFileForm = multipartPayload.shadowRoot.querySelector('multipart-file-form-item');
811+
assert.exists(multipartFileForm);
812+
813+
const inputLabel = multipartFileForm.shadowRoot.querySelector('anypoint-input').querySelector('label');
814+
assert.exists(inputLabel);
815+
assert.equal(inputLabel.innerText, 'Content type (Optional)');
816+
});
817+
});
818+
});
819+
});
781820
});

0 commit comments

Comments
 (0)