Skip to content

Commit e1aa12b

Browse files
committed
feat(ux): add cypress tests for displaying an upload button
1 parent 69d93fa commit e1aa12b

File tree

2 files changed

+219
-0
lines changed

2 files changed

+219
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
openapi: 3.0.0
2+
info:
3+
title: "Request body file upload"
4+
description: |-
5+
This document has examples for examining the `schema` or content type for request bodies requiring a file upload
6+
* `application/octect-stream` content type (no matter what schema format)
7+
* `audio/*` content type (no matter what schema format)
8+
* `image/*` content type (no matter what schema format)
9+
* `video/*` content type (no matter what schema format)
10+
* schema format is `base64` (no matter what content type)
11+
* schema format is `binary` (no matter what content type)
12+
version: "1.0.0"
13+
paths:
14+
/upload-application-octet-stream:
15+
post:
16+
operationId: uploadApplicationOctetStream
17+
requestBody:
18+
content:
19+
application/octet-stream:
20+
schema:
21+
type: string
22+
responses:
23+
'200':
24+
description: successful operation
25+
content:
26+
text/plain:
27+
schema:
28+
type: string
29+
/upload-image-png:
30+
post:
31+
operationId: uploadImagePng
32+
requestBody:
33+
content:
34+
image/png:
35+
schema:
36+
type: string
37+
responses:
38+
'200':
39+
description: successful operation
40+
content:
41+
text/plain:
42+
schema:
43+
type: string
44+
/upload-audio-wav:
45+
post:
46+
operationId: uploadAudioWav
47+
requestBody:
48+
content:
49+
audio/wav:
50+
schema:
51+
type: string
52+
responses:
53+
'200':
54+
description: successful operation
55+
content:
56+
text/plain:
57+
schema:
58+
type: string
59+
/upload-video-mpeg:
60+
post:
61+
operationId: uploadVideoMpeg
62+
requestBody:
63+
content:
64+
video/mpeg:
65+
schema:
66+
type: string
67+
responses:
68+
'200':
69+
description: successful operation
70+
content:
71+
text/plain:
72+
schema:
73+
type: string
74+
/upload-schema-format-binary:
75+
post:
76+
operationId: uploadSchemaFormatBinary
77+
requestBody:
78+
content:
79+
application/x-custom:
80+
schema:
81+
type: string
82+
format: binary
83+
responses:
84+
'200':
85+
description: successful operation
86+
content:
87+
text/plain:
88+
schema:
89+
type: string
90+
/upload-schema-format-base64:
91+
post:
92+
operationId: uploadSchemaFormatBase64
93+
requestBody:
94+
content:
95+
application/x-custom:
96+
schema:
97+
type: string
98+
format: base64
99+
responses:
100+
'200':
101+
description: successful operation
102+
content:
103+
text/plain:
104+
schema:
105+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* @prettier
3+
*/
4+
5+
describe("OpenAPI 3.0 Request Body upload file button", () => {
6+
describe("application/octet-stream", () => {
7+
it("should display description with the correct content type", () => {
8+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
9+
.get("#operations-default-uploadApplicationOctetStream")
10+
.click()
11+
.get(".opblock-section-request-body .opblock-description-wrapper i")
12+
.should("have.text", "Example values are not available for application/octet-stream media types.")
13+
})
14+
it("should display a file upload button", () => {
15+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
16+
.get("#operations-default-uploadApplicationOctetStream")
17+
.click()
18+
.get(".try-out__btn")
19+
.click()
20+
.get(".opblock-section-request-body .opblock-description-wrapper input")
21+
.should("have.prop", "type", "file")
22+
})
23+
})
24+
describe("image/png", () => {
25+
it("should display description with the correct content type", () => {
26+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
27+
.get("#operations-default-uploadImagePng")
28+
.click()
29+
.get(".opblock-section-request-body .opblock-description-wrapper i")
30+
.should("have.text", "Example values are not available for image/png media types.")
31+
})
32+
it("should display a file upload button", () => {
33+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
34+
.get("#operations-default-uploadApplicationOctetStream")
35+
.click()
36+
.get(".try-out__btn")
37+
.click()
38+
.get(".opblock-section-request-body .opblock-description-wrapper input")
39+
.should("have.prop", "type", "file")
40+
})
41+
})
42+
describe("audio/wav", () => {
43+
it("should display description with the correct content type", () => {
44+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
45+
.get("#operations-default-uploadAudioWav")
46+
.click()
47+
.get(".opblock-section-request-body .opblock-description-wrapper i")
48+
.should("have.text", "Example values are not available for audio/wav media types.")
49+
})
50+
it("should display a file upload button", () => {
51+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
52+
.get("#operations-default-uploadApplicationOctetStream")
53+
.click()
54+
.get(".try-out__btn")
55+
.click()
56+
.get(".opblock-section-request-body .opblock-description-wrapper input")
57+
.should("have.prop", "type", "file")
58+
})
59+
})
60+
describe("video/mpeg", () => {
61+
it("should display description with the correct content type", () => {
62+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
63+
.get("#operations-default-uploadVideoMpeg")
64+
.click()
65+
.get(".opblock-section-request-body .opblock-description-wrapper i")
66+
.should("have.text", "Example values are not available for video/mpeg media types.")
67+
})
68+
it("should display a file upload button", () => {
69+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
70+
.get("#operations-default-uploadApplicationOctetStream")
71+
.click()
72+
.get(".try-out__btn")
73+
.click()
74+
.get(".opblock-section-request-body .opblock-description-wrapper input")
75+
.should("have.prop", "type", "file")
76+
})
77+
})
78+
describe("schema format binary", () => {
79+
it("should display description with the correct content type", () => {
80+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
81+
.get("#operations-default-uploadSchemaFormatBinary")
82+
.click()
83+
.get(".opblock-section-request-body .opblock-description-wrapper i")
84+
.should("have.text", "Example values are not available for application/x-custom media types.")
85+
})
86+
it("should display a file upload button", () => {
87+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
88+
.get("#operations-default-uploadSchemaFormatBinary")
89+
.click()
90+
.get(".try-out__btn")
91+
.click()
92+
.get(".opblock-section-request-body .opblock-description-wrapper input")
93+
.should("have.prop", "type", "file")
94+
})
95+
})
96+
describe("schema format base64", () => {
97+
it("should display description with the correct content type", () => {
98+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
99+
.get("#operations-default-uploadSchemaFormatBase64")
100+
.click()
101+
.get(".opblock-section-request-body .opblock-description-wrapper i")
102+
.should("have.text", "Example values are not available for application/x-custom media types.")
103+
})
104+
it("should display a file upload button", () => {
105+
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
106+
.get("#operations-default-uploadSchemaFormatBinary")
107+
.click()
108+
.get(".try-out__btn")
109+
.click()
110+
.get(".opblock-section-request-body .opblock-description-wrapper input")
111+
.should("have.prop", "type", "file")
112+
})
113+
})
114+
})

0 commit comments

Comments
 (0)