schema-form.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. /**
  2. * @prettier
  3. */
  4. describe("OpenAPI 3.0 Additional JsonSchemaForm in a Parameter", () => {
  5. describe("incomplete API definition with missing schema key or schema value(s)", () => {
  6. describe("parameter exists as global", () => {
  7. it("should render when parameter exists as global, but missing schema key", () => {
  8. cy.visit(
  9. "/?url=/documents/features/schema-form-missing-values.yaml"
  10. )
  11. .get("#operations-default-get_case_one_no_schema")
  12. .click()
  13. .get(".opblock-description .renderedMarkdown p")
  14. .should("have.text", "sf")
  15. })
  16. it("should render when parameter exists as global, but missing all schema values", () => {
  17. cy.visit(
  18. "/?url=/documents/features/schema-form-missing-values.yaml"
  19. )
  20. .get("#operations-default-get_case_one_no_type_or_format")
  21. .click()
  22. .get(".opblock-description .renderedMarkdown p")
  23. .should("have.text", "sf")
  24. })
  25. it("should render when parameter exists as global, schema key exists, but missing schema values: format", () => {
  26. cy.visit(
  27. "/?url=/documents/features/schema-form-missing-values.yaml"
  28. )
  29. .get("#operations-default-get_case_one_format_only_no_type")
  30. .click()
  31. .get(".opblock-description .renderedMarkdown p")
  32. .should("have.text", "sf")
  33. })
  34. it("should render when parameter exists as global, schema key exists, but missing schema value: type", () => {
  35. cy.visit(
  36. "/?url=/documents/features/schema-form-missing-values.yaml"
  37. )
  38. .get("#operations-default-get_case_one_type_only_no_format")
  39. .click()
  40. .get(".opblock-description .renderedMarkdown p")
  41. .should("have.text", "sf")
  42. })
  43. })
  44. describe("parameter exists in method", () => {
  45. it("should render when parameter exists in method, but missing schema key", () => {
  46. cy.visit(
  47. "/?url=/documents/features/schema-form-missing-values.yaml"
  48. )
  49. .get("#operations-default-get_case_two_no_schema")
  50. .click()
  51. .get(".opblock-description .renderedMarkdown p")
  52. .should("have.text", "sf")
  53. })
  54. it("should render when parameter exists in method, schema key exists, but missing all schema values", () => {
  55. cy.visit(
  56. "/?url=/documents/features/schema-form-missing-values.yaml"
  57. )
  58. .get("#operations-default-get_case_two_no_type_or_format")
  59. .click()
  60. .get(".opblock-description .renderedMarkdown p")
  61. .should("have.text", "sf")
  62. })
  63. it("should render when parameter exists in method, schema key exists, but missing schema value: format", () => {
  64. cy.visit(
  65. "/?url=/documents/features/schema-form-missing-values.yaml"
  66. )
  67. .get("#operations-default-get_case_one_type_only_no_format")
  68. .click()
  69. .get(".opblock-description .renderedMarkdown p")
  70. .should("have.text", "sf")
  71. })
  72. it("should render when parameter exists in method, schema key exists, but missing schema value: type", () => {
  73. cy.visit(
  74. "/?url=/documents/features/schema-form-missing-values.yaml"
  75. )
  76. .get("#operations-default-get_case_one_format_only_no_type")
  77. .click()
  78. .get(".opblock-description .renderedMarkdown p")
  79. .should("have.text", "sf")
  80. })
  81. })
  82. })
  83. describe("/Array", () => {
  84. describe("in a Parameter", () => {
  85. it("should allow modification of values in Try-It-Out", () => {
  86. cy.visit(
  87. "/?url=/documents/features/multiple-examples-core.openapi.yaml"
  88. )
  89. .get("#operations-default-post_Array")
  90. .click()
  91. // Expand Try It Out
  92. .get(".try-out__btn")
  93. .click()
  94. .get(".parameters-col_description .examples-select > select")
  95. .select("ArrayExampleB")
  96. // Add a new item
  97. .get(".json-schema-form-item-add")
  98. .click()
  99. .get(".json-schema-form-item:last-of-type > input")
  100. .type("5")
  101. // Assert against the input fields
  102. .get(".json-schema-form-item > input")
  103. .then(inputs => {
  104. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  105. "1",
  106. "2",
  107. "3",
  108. "4",
  109. "5",
  110. ])
  111. })
  112. .get(".parameters-col_description .examples-select > select")
  113. .find(":selected")
  114. .should("have.text", "[Modified value]")
  115. })
  116. it("should allow removal of added value in Try-It-Out", () => {
  117. cy.visit(
  118. "/?url=/documents/features/multiple-examples-core.openapi.yaml"
  119. )
  120. .get("#operations-default-post_Array")
  121. .click()
  122. // Expand Try It Out
  123. .get(".try-out__btn")
  124. .click()
  125. .get(".parameters-col_description .examples-select > select")
  126. .select("ArrayExampleB")
  127. // Add a new item
  128. .get(".json-schema-form-item-add")
  129. .click()
  130. .get(".json-schema-form-item:last-of-type > input")
  131. .type("5")
  132. // Assert against the input fields
  133. .get(".json-schema-form-item > input")
  134. .then(inputs => {
  135. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  136. "1",
  137. "2",
  138. "3",
  139. "4",
  140. "5",
  141. ])
  142. })
  143. .get(".parameters-col_description .examples-select > select")
  144. .find(":selected")
  145. .should("have.text", "[Modified value]")
  146. // Remove the last item that was just added
  147. .get(".json-schema-form-item:last-of-type > .json-schema-form-item-remove")
  148. .click()
  149. .get(".json-schema-form-item > input")
  150. .then(inputs => {
  151. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  152. "1",
  153. "2",
  154. "3",
  155. "4",
  156. ])
  157. })
  158. })
  159. it("should allow removal of nth of values in Try-It-Out", () => {
  160. cy.visit(
  161. "/?url=/documents/features/multiple-examples-core.openapi.yaml"
  162. )
  163. .get("#operations-default-post_Array")
  164. .click()
  165. // Expand Try It Out
  166. .get(".try-out__btn")
  167. .click()
  168. .get(".parameters-col_description .examples-select > select")
  169. .select("ArrayExampleB")
  170. // Add a new item
  171. .get(".json-schema-form-item-add")
  172. .click()
  173. .get(".json-schema-form-item:last-of-type > input")
  174. .type("5")
  175. // Assert against the input fields
  176. .get(".json-schema-form-item > input")
  177. .then(inputs => {
  178. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  179. "1",
  180. "2",
  181. "3",
  182. "4",
  183. "5",
  184. ])
  185. })
  186. .get(".parameters-col_description .examples-select > select")
  187. .find(":selected")
  188. .should("have.text", "[Modified value]")
  189. // Remove the second item in list
  190. .get(".json-schema-form-item:nth-child(2) > .json-schema-form-item-remove")
  191. .click()
  192. .get(".json-schema-form-item > input")
  193. .then(inputs => {
  194. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  195. "1",
  196. "3",
  197. "4",
  198. "5"
  199. ])
  200. })
  201. })
  202. it("should allow execution of operation in Try-It-Out", () => {
  203. cy.visit(
  204. "/?url=/documents/features/multiple-examples-core.openapi.yaml"
  205. )
  206. .get("#operations-default-post_Array")
  207. .click()
  208. // Expand Try It Out
  209. .get(".try-out__btn")
  210. .click()
  211. .get(".parameters-col_description .examples-select > select")
  212. .select("ArrayExampleB")
  213. // Execute
  214. .get(".execute.opblock-control__btn")
  215. .click()
  216. // Expect new element to be visible after Execute
  217. .get(".btn-clear.opblock-control__btn")
  218. .should("have.text", "Clear")
  219. })
  220. it("should add empty item and allow execution of operation in Try-It-Out", () => {
  221. cy.visit(
  222. "/?url=/documents/features/multiple-examples-core.openapi.yaml"
  223. )
  224. .get("#operations-default-post_Array")
  225. .click()
  226. // Expand Try It Out
  227. .get(".try-out__btn")
  228. .click()
  229. .get(".parameters-col_description .examples-select > select")
  230. .select("ArrayExampleB")
  231. // Add a new item
  232. .get(".json-schema-form-item-add")
  233. .click()
  234. // Execute without prior typing a value
  235. .get(".execute.opblock-control__btn")
  236. .click()
  237. // Expect new element to be visible after Execute
  238. .get(".btn-clear.opblock-control__btn")
  239. .should("have.text", "Clear")
  240. })
  241. })
  242. })
  243. describe("Petstore", () => {
  244. describe("/pet/findByStatus", () => {
  245. it("should render the operation, execute with default value", () => {
  246. cy.visit(
  247. "/?url=/documents/features/schema-form-core.yaml"
  248. )
  249. .get("#operations-default-findPetsByStatus")
  250. .click()
  251. // Expand operation
  252. .get(".opblock-title span")
  253. .should("have.text", "Parameters")
  254. // Expand Try It Out
  255. .get(".try-out__btn")
  256. .click()
  257. // Execute
  258. .get(".execute.opblock-control__btn")
  259. .click()
  260. // Expect new element to be visible after Execute
  261. .get(".btn-clear.opblock-control__btn")
  262. .should("have.text", "Clear")
  263. // Compare Request URL
  264. .get(".request-url pre.microlight")
  265. .should("contain.text", "available")
  266. })
  267. it("should render the operation, modify value, and execute with modfied value", () => {
  268. cy.visit(
  269. "/?url=/documents/features/schema-form-core.yaml"
  270. )
  271. .get("#operations-default-findPetsByStatus")
  272. .click()
  273. // Expand operation
  274. .get(".opblock-title span")
  275. .should("have.text", "Parameters")
  276. // Expand Try It Out
  277. .get(".try-out__btn")
  278. .click()
  279. // Select
  280. .get(".parameters-col_description > select")
  281. .select("pending")
  282. // Execute
  283. .get(".execute.opblock-control__btn")
  284. .click()
  285. // Expect new element to be visible after Execute
  286. .get(".btn-clear.opblock-control__btn")
  287. .should("have.text", "Clear")
  288. // Compare Request URL
  289. .get(".request-url pre.microlight")
  290. .should("contain.text", "pending")
  291. })
  292. })
  293. describe("/pet/findByTags", () => {
  294. it("should allow modification of values in Try-It-Out", () => {
  295. cy.visit(
  296. "/?url=/documents/features/schema-form-core.yaml"
  297. )
  298. .get("#operations-pet-findPetsByTags")
  299. .click()
  300. // Expand Try It Out
  301. .get(".try-out__btn")
  302. .click()
  303. // Add a new item
  304. .get(".json-schema-form-item-add")
  305. .click()
  306. .get(".json-schema-form-item > input")
  307. .type("{selectall}spotted")
  308. // Assert against the input fields
  309. .get(".json-schema-form-item > input")
  310. .then(inputs => {
  311. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  312. "spotted",
  313. ])
  314. })
  315. })
  316. it("should allow removal of added value in Try-It-Out", () => {
  317. cy.visit(
  318. "/?url=/documents/features/schema-form-core.yaml"
  319. )
  320. .get("#operations-pet-findPetsByTags")
  321. .click()
  322. // Expand Try It Out
  323. .get(".try-out__btn")
  324. .click()
  325. // Add a new item
  326. .get(".json-schema-form-item-add")
  327. .click()
  328. .get(".json-schema-form-item:last-of-type > input")
  329. .type("{selectall}spotted")
  330. // Assert against the input fields
  331. .get(".json-schema-form-item > input")
  332. .then(inputs => {
  333. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  334. "spotted",
  335. ])
  336. })
  337. // Remove the last item that was just added
  338. .get(".json-schema-form-item:last-of-type > .json-schema-form-item-remove")
  339. .click()
  340. .get(".json-schema-form-item > input")
  341. .should("not.exist")
  342. })
  343. it("should allow removal of nth of values in Try-It-Out", () => {
  344. cy.visit(
  345. "/?url=/documents/features/schema-form-core.yaml"
  346. )
  347. .get("#operations-pet-findPetsByTags")
  348. .click()
  349. // Expand Try It Out
  350. .get(".try-out__btn")
  351. .click()
  352. // Add a new item
  353. .get(".json-schema-form-item-add")
  354. .click()
  355. .get(".json-schema-form-item:last-of-type > input")
  356. .type("{selectall}spotted")
  357. // Assert against the input fields
  358. .get(".json-schema-form-item > input")
  359. .then(inputs => {
  360. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  361. "spotted",
  362. ])
  363. })
  364. // Add a 2nd new item
  365. .get(".json-schema-form-item-add")
  366. .click()
  367. .get(".json-schema-form-item:last-of-type > input")
  368. .type("{selectall}large")
  369. // Assert against the input fields
  370. .get(".json-schema-form-item > input")
  371. .then(inputs => {
  372. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  373. "spotted",
  374. "large"
  375. ])
  376. })
  377. // Add a 3rd new item
  378. .get(".json-schema-form-item-add")
  379. .click()
  380. .get(".json-schema-form-item:last-of-type > input")
  381. .type("{selectall}puppy")
  382. // Assert against the input fields
  383. .get(".json-schema-form-item > input")
  384. .then(inputs => {
  385. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  386. "spotted",
  387. "large",
  388. "puppy"
  389. ])
  390. })
  391. // Remove the second item in list
  392. .get(".json-schema-form-item:nth-child(2) > .json-schema-form-item-remove")
  393. .click()
  394. .get(".json-schema-form-item > input")
  395. .then(inputs => {
  396. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  397. "spotted",
  398. "puppy"
  399. ])
  400. })
  401. })
  402. it("should allow execution of operation without modifications in Try-It-Out (debounce)", () => {
  403. cy.visit(
  404. "/?url=/documents/features/schema-form-core.yaml"
  405. )
  406. .get("#operations-pet-findPetsByTags")
  407. .click()
  408. // Expand Try It Out
  409. .get(".try-out__btn")
  410. .click()
  411. // Execute
  412. .get(".execute.opblock-control__btn")
  413. .click()
  414. // Expect new element to be visible after Execute
  415. .get(".btn-clear.opblock-control__btn")
  416. .should("have.text", "Clear")
  417. // Compare Request URL
  418. .get(".request-url pre.microlight")
  419. .should("contain.text", "findByTags")
  420. })
  421. it("should add empty item and allow execution of operation in Try-It-Out (debounce)", () => {
  422. cy.visit(
  423. "/?url=/documents/features/schema-form-core.yaml"
  424. )
  425. .get("#operations-pet-findPetsByTags")
  426. .click()
  427. // Expand Try It Out
  428. .get(".try-out__btn")
  429. .click()
  430. // Add a new item
  431. .get(".json-schema-form-item-add")
  432. .click()
  433. // Execute without prior typing a value
  434. .get(".execute.opblock-control__btn")
  435. .click()
  436. // Expect new element to be visible after Execute
  437. .get(".btn-clear.opblock-control__btn")
  438. .should("have.text", "Clear")
  439. // Compare Request URL
  440. .get(".request-url pre.microlight")
  441. .should("contain.text", "findByTags")
  442. })
  443. it("should add modified item and allow execution of operation in Try-It-Out", () => {
  444. cy.visit(
  445. "/?url=/documents/features/schema-form-core.yaml"
  446. )
  447. .get("#operations-pet-findPetsByTags")
  448. .click()
  449. // Expand Try It Out
  450. .get(".try-out__btn")
  451. .click()
  452. // Add a new item
  453. .get(".json-schema-form-item-add")
  454. .click()
  455. .get(".json-schema-form-item > input")
  456. .type("{selectall}spotted")
  457. // Assert against the input fields
  458. .get(".json-schema-form-item > input")
  459. .then(inputs => {
  460. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  461. "spotted",
  462. ])
  463. })
  464. // Execute
  465. .get(".execute.opblock-control__btn")
  466. .click()
  467. // Expect new element to be visible after Execute
  468. .get(".btn-clear.opblock-control__btn")
  469. .should("have.text", "Clear")
  470. // Compare Request URL
  471. .get(".request-url pre.microlight")
  472. .should("contain.text", "spotted")
  473. })
  474. it("should add 3 modified items, remove the middle child, and allow execution of operation Try-It-Out", () => {
  475. cy.visit(
  476. "/?url=/documents/features/schema-form-core.yaml"
  477. )
  478. .get("#operations-pet-findPetsByTags")
  479. .click()
  480. // Expand Try It Out
  481. .get(".try-out__btn")
  482. .click()
  483. // Add a new item
  484. .get(".json-schema-form-item-add")
  485. .click()
  486. .get(".json-schema-form-item:last-of-type > input")
  487. .type("{selectall}spotted")
  488. // Assert against the input fields
  489. .get(".json-schema-form-item > input")
  490. .then(inputs => {
  491. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  492. "spotted",
  493. ])
  494. })
  495. // Add a 2nd new item
  496. .get(".json-schema-form-item-add")
  497. .click()
  498. .get(".json-schema-form-item:last-of-type > input")
  499. .type("{selectall}large")
  500. // Assert against the input fields
  501. .get(".json-schema-form-item > input")
  502. .then(inputs => {
  503. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  504. "spotted",
  505. "large"
  506. ])
  507. })
  508. // Add a 3rd new item
  509. .get(".json-schema-form-item-add")
  510. .click()
  511. .get(".json-schema-form-item:last-of-type > input")
  512. .type("{selectall}puppy")
  513. // Assert against the input fields
  514. .get(".json-schema-form-item > input")
  515. .then(inputs => {
  516. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  517. "spotted",
  518. "large",
  519. "puppy"
  520. ])
  521. })
  522. // Remove the second item in list
  523. .get(".json-schema-form-item:nth-child(2) > .json-schema-form-item-remove")
  524. .click()
  525. .get(".json-schema-form-item > input")
  526. .then(inputs => {
  527. expect(inputs.map((i, el) => el.value).toArray()).to.deep.equal([
  528. "spotted",
  529. "puppy"
  530. ])
  531. })
  532. // Execute
  533. .get(".execute.opblock-control__btn")
  534. .click()
  535. // Expect new element to be visible after Execute
  536. .get(".btn-clear.opblock-control__btn")
  537. .should("have.text", "Clear")
  538. // Compare Request URL
  539. .get(".request-url pre.microlight")
  540. .should("contain.text", "tags=spotted&tags=puppy")
  541. .should("not.have.text", "large")
  542. })
  543. })
  544. describe("/petOwner/{petOwnerId}", () => {
  545. // This is a (GET) debounce test for schema type: string
  546. it("should render the operation, and allow execute of operation with empty value (debounce)", () => {
  547. cy.visit(
  548. "/?url=/documents/features/schema-form-core.yaml"
  549. )
  550. .get("#operations-petOwner-getPetOwnerById")
  551. .click()
  552. // Expand operation
  553. .get(".opblock-title span")
  554. .should("have.text", "Parameters")
  555. // Expand Try It Out
  556. .get(".try-out__btn")
  557. .click()
  558. // Execute
  559. .get(".execute.opblock-control__btn")
  560. .click()
  561. // Expect new element to be visible after Execute
  562. .get(".btn-clear.opblock-control__btn")
  563. .should("have.text", "Clear")
  564. // Compare Request URL
  565. .get(".request-url pre.microlight")
  566. .should("contain.text", "petOwner")
  567. })
  568. it("should render the operation, and input field, and allow execute of operation", () => {
  569. cy.visit(
  570. "/?url=/documents/features/schema-form-core.yaml"
  571. )
  572. .get("#operations-petOwner-getPetOwnerById")
  573. .click()
  574. // Expand operation
  575. .get(".opblock-title span")
  576. .should("have.text", "Parameters")
  577. // Expand Try It Out
  578. .get(".try-out__btn")
  579. .click()
  580. .get(".parameters-col_description > input")
  581. .type("123")
  582. // Execute
  583. .get(".execute.opblock-control__btn")
  584. .click()
  585. // Expect new element to be visible after Execute
  586. .get(".btn-clear.opblock-control__btn")
  587. .should("have.text", "Clear")
  588. // Compare Request URL
  589. .get(".request-url pre.microlight")
  590. .should("contain.text", "petOwner")
  591. .should("contain.text", "123")
  592. })
  593. })
  594. describe("/petOwner/listOfServiceTrainer", () => {
  595. it("should allow execution of operation with value=true in Try-It-Out", () => {
  596. cy.visit(
  597. "/?url=/documents/features/schema-form-core.yaml"
  598. )
  599. .get("#operations-petOwner-listOfServiceTrainer")
  600. .click()
  601. // Expand Try It Out
  602. .get(".try-out__btn")
  603. .click()
  604. // add 1st item
  605. .get(".json-schema-form-item-add")
  606. .click()
  607. .get(".json-schema-form-item > select")
  608. .select("true")
  609. // Execute
  610. .get(".execute.opblock-control__btn")
  611. .click()
  612. // Expect new element to be visible after Execute
  613. .get(".btn-clear.opblock-control__btn")
  614. .should("have.text", "Clear")
  615. // Compare Request URL
  616. .get(".request-url pre.microlight")
  617. .should("contain.text", "tags=true")
  618. })
  619. it("should allow execution of operation with value=false in Try-It-Out", () => {
  620. cy.visit(
  621. "/?url=/documents/features/schema-form-core.yaml"
  622. )
  623. .get("#operations-petOwner-listOfServiceTrainer")
  624. .click()
  625. // Expand Try It Out
  626. .get(".try-out__btn")
  627. .click()
  628. // add 1st item
  629. .get(".json-schema-form-item-add")
  630. .click()
  631. .get(".json-schema-form-item > select")
  632. .select("false")
  633. // Execute
  634. .get(".execute.opblock-control__btn")
  635. .click()
  636. // Expect new element to be visible after Execute
  637. .get(".btn-clear.opblock-control__btn")
  638. .should("have.text", "Clear")
  639. // Compare Request URL
  640. .get(".request-url pre.microlight")
  641. .should("contain.text", "tags=false")
  642. })
  643. it("should allow execution of operation with value=true&value=false in Try-It-Out", () => {
  644. cy.visit(
  645. "/?url=/documents/features/schema-form-core.yaml"
  646. )
  647. .get("#operations-petOwner-listOfServiceTrainer")
  648. .click()
  649. // Expand Try It Out
  650. .get(".try-out__btn")
  651. .click()
  652. // add 1st item
  653. .get(".json-schema-form-item-add")
  654. .click()
  655. .get(".json-schema-form-item > select")
  656. .select("true")
  657. // add 2nd item
  658. .get(".json-schema-form-item-add")
  659. .click()
  660. .get(".json-schema-form-item:last-of-type > select")
  661. .select("false")
  662. // Execute
  663. .get(".execute.opblock-control__btn")
  664. .click()
  665. // Expect new element to be visible after Execute
  666. .get(".btn-clear.opblock-control__btn")
  667. .should("have.text", "Clear")
  668. // Compare Request URL
  669. .get(".request-url pre.microlight")
  670. .should("contain.text", "tags=true&tags=false")
  671. })
  672. it("should allow execution of operation with value=false after removing value=true in Try-It-Out", () => {
  673. cy.visit(
  674. "/?url=/documents/features/schema-form-core.yaml"
  675. )
  676. .get("#operations-petOwner-listOfServiceTrainer")
  677. .click()
  678. // Expand Try It Out
  679. .get(".try-out__btn")
  680. .click()
  681. // add 1st item
  682. .get(".json-schema-form-item-add")
  683. .click()
  684. .get(".json-schema-form-item > select")
  685. .select("true")
  686. // add 2nd item
  687. .get(".json-schema-form-item-add")
  688. .click()
  689. .get(".json-schema-form-item:last-of-type > select")
  690. .select("false")
  691. // remove 1st item
  692. .get(".json-schema-form-item:nth-child(1) > .json-schema-form-item-remove")
  693. .click()
  694. // Execute
  695. .get(".execute.opblock-control__btn")
  696. .click()
  697. // Expect new element to be visible after Execute
  698. .get(".btn-clear.opblock-control__btn")
  699. .should("have.text", "Clear")
  700. // Compare Request URL
  701. .get(".request-url pre.microlight")
  702. .should("contain.text", "tags=false")
  703. })
  704. it("should allow execution of operation with value=(empty) in Try-It-Out", () => {
  705. cy.visit(
  706. "/?url=/documents/features/schema-form-core.yaml"
  707. )
  708. .get("#operations-petOwner-listOfServiceTrainer")
  709. .click()
  710. // Expand Try It Out
  711. .get(".try-out__btn")
  712. .click()
  713. // Execute
  714. .get(".execute.opblock-control__btn")
  715. .click()
  716. // Expect new element to be visible after Execute
  717. .get(".btn-clear.opblock-control__btn")
  718. .should("have.text", "Clear")
  719. // Compare Request URL
  720. .get(".request-url pre.microlight")
  721. .should("contain.text", "listOfServiceTrainer")
  722. })
  723. })
  724. describe("/petOwner/findByPreference", () => {
  725. it("should allow execution of operation with value=(empty) in Try-It-Out", () => {
  726. cy.visit(
  727. "/?url=/documents/features/schema-form-core.yaml"
  728. )
  729. .get("#operations-petOwner-findByPreference")
  730. .click()
  731. // Expand Try It Out
  732. .get(".try-out__btn")
  733. .click()
  734. // Execute
  735. .get(".execute.opblock-control__btn")
  736. .click()
  737. // Expect new element to be visible after Execute
  738. .get(".btn-clear.opblock-control__btn")
  739. .should("have.text", "Clear")
  740. // Compare Request URL
  741. .get(".request-url pre.microlight")
  742. .should("contain.text", "findByPreference")
  743. })
  744. it("should allow execution of operation with selected value in Try-It-Out", () => {
  745. cy.visit(
  746. "/?url=/documents/features/schema-form-core.yaml"
  747. )
  748. .get("#operations-petOwner-findByPreference")
  749. .click()
  750. // Expand Try It Out
  751. .get(".try-out__btn")
  752. .click()
  753. // Select
  754. .get(".parameters-col_description > select")
  755. .select("dog")
  756. // Execute
  757. .get(".execute.opblock-control__btn")
  758. .click()
  759. // Expect new element to be visible after Execute
  760. .get(".btn-clear.opblock-control__btn")
  761. .should("have.text", "Clear")
  762. // Compare Request URL
  763. .get(".request-url pre.microlight")
  764. .should("contain.text", "findByPreference")
  765. .should("contain.text", "dog")
  766. })
  767. it("should allow execution of operation with multiple selected values in Try-It-Out", () => {
  768. cy.visit(
  769. "/?url=/documents/features/schema-form-core.yaml"
  770. )
  771. .get("#operations-petOwner-findByPreference")
  772. .click()
  773. // Expand Try It Out
  774. .get(".try-out__btn")
  775. .click()
  776. // Select
  777. .get(".parameters-col_description > select")
  778. .select(["dog", "cat"])
  779. // Execute
  780. .get(".execute.opblock-control__btn")
  781. .click()
  782. // Expect new element to be visible after Execute
  783. .get(".btn-clear.opblock-control__btn")
  784. .should("have.text", "Clear")
  785. // Compare Request URL
  786. .get(".request-url pre.microlight")
  787. .should("contain.text", "findByPreference")
  788. .should("contain.text", "dog")
  789. .should("contain.text", "cat")
  790. })
  791. })
  792. describe("/petOwner/createWithList", () => {
  793. it("should allow execution of operation with default text in textArea in Try-It-Out", () => {
  794. cy.visit(
  795. "/?url=/documents/features/schema-form-core.yaml"
  796. )
  797. .get("#operations-petOwner-petOwnerCreateWithList")
  798. .click()
  799. // Expand Try It Out
  800. .get(".try-out__btn")
  801. .click()
  802. // Execute
  803. .get(".execute.opblock-control__btn")
  804. .click()
  805. // Expect new element to be visible after Execute
  806. .get(".btn-clear.opblock-control__btn")
  807. .should("have.text", "Clear")
  808. // Compare Request URL
  809. .get(".request-url pre.microlight")
  810. .should("contain.text", "createWithList")
  811. })
  812. it("should allow execution of operation with cleared textArea in Try-It-Out", () => {
  813. cy.visit(
  814. "/?url=/documents/features/schema-form-core.yaml"
  815. )
  816. .get("#operations-petOwner-petOwnerCreateWithList")
  817. .click()
  818. // Expand Try It Out
  819. .get(".try-out__btn")
  820. .click()
  821. .get(".body-param__text")
  822. .clear()
  823. // Execute
  824. .get(".execute.opblock-control__btn")
  825. .click()
  826. // Expect new element to be visible after Execute
  827. .get(".btn-clear.opblock-control__btn")
  828. .should("have.text", "Clear")
  829. // Compare Request URL
  830. .get(".request-url pre.microlight")
  831. .should("contain.text", "createWithList")
  832. })
  833. it("should allow execution of operation with modified textArea in Try-It-Out", () => {
  834. cy.visit(
  835. "/?url=/documents/features/schema-form-core.yaml"
  836. )
  837. .get("#operations-petOwner-petOwnerCreateWithList")
  838. .click()
  839. // Expand Try It Out
  840. .get(".try-out__btn")
  841. .click()
  842. .get(".body-param__text")
  843. .clear()
  844. // note: adding this much type adds 6+ seconds to test
  845. .type(`[
  846. {
  847. "id": 10,
  848. "petId": 201,
  849. "petOwnerFirstName": "John",
  850. },
  851. {
  852. "id": 11,
  853. "petId": 201,
  854. "petOwnerFirstName": "Jane",
  855. }
  856. ]`
  857. )
  858. .should("contain.text", "Jane")
  859. .should("contain.text", "201")
  860. // Execute
  861. .get(".execute.opblock-control__btn")
  862. .click()
  863. // Expect new element to be visible after Execute
  864. .get(".btn-clear.opblock-control__btn")
  865. .should("have.text", "Clear")
  866. // Compare Request URL
  867. .get(".request-url pre.microlight")
  868. .should("contain.text", "createWithList")
  869. // Compare Curl
  870. .get(".curl")
  871. .should("contain.text", "Jane")
  872. .should("contain.text", "201")
  873. })
  874. })
  875. })
  876. })