This commit is contained in:
2024-05-24 15:27:07 +03:00
parent 17df2ce6a9
commit fc1da2c238
643 changed files with 110185 additions and 231 deletions

View File

@ -0,0 +1,433 @@
describe("feature: OpenAPI 3 allowEmptyValue", function () {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/allow-empty-value.openapi.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock", 10000)
done()
})
afterEach(function (client, done) {
done()
})
describe("regular parameters", function () {
it("should set and unset an integer value", function (client) {
const inputSelector = `tr[data-param-name="int"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a string value", function (client) {
const inputSelector = `tr[data-param-name="str"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a number value", function (client) {
const inputSelector = `tr[data-param-name="num"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a boolean value", function (client) {
const inputSelector = `tr[data-param-name="bool"] select`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} [value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} [value=""]`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset an array value", function (client) {
const inputSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} .json-schema-form-item-add`)
.setValue(`${inputSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} .json-schema-form-item-remove`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
})
describe("allowEmptyValue parameters", function () {
describe("normal behavior", function () {
it("should set and unset an integer value", function (client) {
const inputSelector = `tr[data-param-name="int"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a string value", function (client) {
const inputSelector = `tr[data-param-name="str"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a number value", function (client) {
const inputSelector = `tr[data-param-name="num"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a boolean value", function (client) {
const inputSelector = `tr[data-param-name="bool"] select`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} [value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} [value=""]`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset an array value", function (client) {
const inputSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} .json-schema-form-item-add`)
.setValue(`${inputSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} .json-schema-form-item-remove`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
})
describe("send empty initial value behavior", function () {
it("should send an empty integer value", function (client) {
const paramSelector = `tr[data-param-name="int"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?int="`)
})
it("should send an empty string value", function (client) {
const paramSelector = `tr[data-param-name="str"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?str="`)
})
it("should send an empty number value", function (client) {
const paramSelector = `tr[data-param-name="num"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?num="`)
})
it("should send an empty boolean value", function (client) {
const paramSelector = `tr[data-param-name="bool"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?bool="`)
})
it("should send an empty array value", function (client) {
const paramSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?arr="`)
})
})
describe("modify and send empty behavior", function () {
it("should set, unset and send an empty integer value", function (client) {
const paramSelector = `tr[data-param-name="int"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?int="`)
})
it("should set, unset and send an empty string value", function (client) {
const paramSelector = `tr[data-param-name="str"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?str="`)
})
it("should set, unset and send an empty number value", function (client) {
const paramSelector = `tr[data-param-name="num"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?num="`)
})
it("should set, unset and send an empty boolean value", function (client) {
const paramSelector = `tr[data-param-name="bool"]`
const inputSelector = `${paramSelector} select`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} option[value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.click(`${inputSelector} option[value=""]`)
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?bool="`)
})
it("should set, unset and send an empty array value", function (client) {
const paramSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${paramSelector} .json-schema-form-item-add`)
.setValue(`${paramSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${paramSelector} .json-schema-form-item-remove`)
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?arr="`)
})
})
})
})

View File

@ -0,0 +1,433 @@
describe("feature: Swagger 2 allowEmptyValue", function () {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/allow-empty-value.swagger.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock", 10000)
done()
})
afterEach(function (client, done) {
done()
})
describe("regular parameters", function () {
it("should set and unset an integer value", function (client) {
const inputSelector = `tr[data-param-name="int"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a string value", function (client) {
const inputSelector = `tr[data-param-name="str"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a number value", function (client) {
const inputSelector = `tr[data-param-name="num"] input`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset a boolean value", function (client) {
const inputSelector = `tr[data-param-name="bool"] select`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} [value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} [value=""]`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
it("should set and unset an array value", function (client) {
const inputSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_regularParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} .json-schema-form-item-add`)
.setValue(`${inputSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} .json-schema-form-item-remove`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/regularParams"`)
})
})
describe("allowEmptyValue parameters", function () {
describe("normal behavior", function () {
it("should set and unset an integer value", function (client) {
const inputSelector = `tr[data-param-name="int"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a string value", function (client) {
const inputSelector = `tr[data-param-name="str"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a number value", function (client) {
const inputSelector = `tr[data-param-name="num"] input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset a boolean value", function (client) {
const inputSelector = `tr[data-param-name="bool"] select`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} [value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} [value=""]`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
it("should set and unset an array value", function (client) {
const inputSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} .json-schema-form-item-add`)
.setValue(`${inputSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${inputSelector} .json-schema-form-item-remove`)
.pause(200)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams"`)
})
})
describe("send empty inital value behavior", function () {
it("should send an empty integer value", function (client) {
const paramSelector = `tr[data-param-name="int"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?int="`)
})
it("should send an empty string value", function (client) {
const paramSelector = `tr[data-param-name="str"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?str="`)
})
it("should send an empty number value", function (client) {
const paramSelector = `tr[data-param-name="num"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?num="`)
})
it("should send an empty boolean value", function (client) {
const paramSelector = `tr[data-param-name="bool"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?bool="`)
})
it("should send an empty array value", function (client) {
const paramSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // tick "send empty value" box and execute
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?arr="`)
})
})
describe("modify and send empty behavior", function () {
it("should set, unset and send an empty integer value", function (client) {
const paramSelector = `tr[data-param-name="int"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?int="`)
})
it("should set, unset and send an empty string value", function (client) {
const paramSelector = `tr[data-param-name="str"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?str="`)
})
it("should set, unset and send an empty number value", function (client) {
const paramSelector = `tr[data-param-name="num"]`
const inputSelector = `${paramSelector} input`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.setValue(inputSelector, "123")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.setValue(inputSelector, "\u0008\u0008\u0008") // backspaces
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?num="`)
})
it("should set, unset and send an empty boolean value", function (client) {
const paramSelector = `tr[data-param-name="bool"]`
const inputSelector = `${paramSelector} select`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${inputSelector} option[value="true"]`)
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, click "send empty", execute again, assert
.click(`${inputSelector} option[value=""]`)
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?bool="`)
})
it("should set, unset and send an empty array value", function (client) {
const paramSelector = `tr[data-param-name="arr"]`
client // open try-it-out
.click("#operations-default-get_emptyValueParams")
.waitForElementVisible("button.btn.try-out__btn", 5000)
.click("button.btn.try-out__btn")
.pause(200)
client // set parameter, to ensure an initial value is set
.click(`${paramSelector} .json-schema-form-item-add`)
.setValue(`${paramSelector} input`, "asdf")
.click("button.btn.execute.opblock-control__btn")
.pause(200)
client // remove initial value, execute again
.click(`${paramSelector} .json-schema-form-item-remove`)
.pause(400)
.click(`${paramSelector} .parameter__empty_value_toggle input`)
.click("button.btn.execute.opblock-control__btn")
.expect.element("textarea.curl").text
.to.contain(`GET "http://localhost:3230/emptyValueParams?arr="`)
})
})
})
})

View File

@ -0,0 +1,240 @@
const dedent = require("dedent")
describe("feature: `example` field support", function () {
describe("Swagger 2", function() {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.swagger.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock", 10000)
.click("#operations-default-put_one")
.waitForElementVisible("#operations-default-put_one.is-open", 5000)
done()
})
afterEach(function (client, done) {
done()
})
// Parameters
// Supports complex root `example` values in Schema objects for bodies
// Supports nested `example` values in Schema objects for bodies
describe("primitive parameters", function() {
it("should respect a primitive x-example value", function (client) {
client
.click("button.try-out__btn")
.assert.value(
`tr[data-param-name="ValidParam"] input[type="text"]`,
`12345`
)
})
it("should ignore a primitive example value", function (client) {
client
.click("button.try-out__btn")
.assert.value(
`tr[data-param-name="NotValidParam"] input[type="text"]`,
``
)
})
})
describe("object parameters", function() {
it("should correctly consider property-level schema examples", function(client) {
client.assert.containsText(`div[data-param-name="body"] pre`,
dedent(`
{
"one": "hello!",
"two": {
"uno": "wow!",
"dos": "hey there!"
}
}
`)
)
})
it("should correctly consider root schema-level schema examples", function(client) {
client.assert.containsText(`div[data-param-name="body2"] pre`,
dedent(`
{
"foo": "hey",
"bar": 123
}
`)
)
})
it("should correctly consider nested schema-level schema examples", function(client) {
client.assert.containsText(`div[data-param-name="body3"] pre`,
dedent(`
{
"one": {
"uno": "woohoo!",
"dos": "amazing!"
}
}
`)
)
})
})
describe("responses", function() {
it("should correctly consider schema-level examples", function (client) {
client.assert.containsText(`tr.response[data-code="201"] pre`,
dedent(`
{
"code": 201,
"payload": [
{
"id": 1,
"code": "AE2",
"name": "Yono"
}
]
}
`)
)
})
it("should correctly consider property-level examples", function (client) {
client.assert.containsText(`tr.response[data-code="202"] pre`,
dedent(`
{
"code": 202,
"payload": [
{
"id": 1,
"code": "AE2",
"name": "Yono"
}
]
}
`)
)
})
})
})
describe("OpenAPI 3.0", function() {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.openapi.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock-summary-description", 10000)
.click("#operations-agent-editAgent")
.waitForElementVisible("#operations-agent-editAgent.is-open", 5000)
done()
})
describe("parameters", function() {
it("should respect a primitive example value", function(client) {
client
.click("button.try-out__btn")
.assert.value(
`div.parameters-container > div > table > tbody > tr > td.col.parameters-col_description > input[type="text"]`,
`12345`
)
})
})
describe("request bodies", function() {
it("should correctly consider media type-level examples", function (client) {
client
.click(`select.content-type option[value="application/json_media-type-level"]`)
.assert.containsText(`pre.body-param__example`,
dedent(`
{
"code": "AE1",
"name": "Andrew"
}
`)
)
})
it("should correctly consider schema-level examples", function (client) {
client
.click(`select.content-type option[value="application/json_schema-level"]`)
.assert.containsText(`pre.body-param__example`,
dedent(`
{
"code": "AE1",
"name": "Andrew"
}
`)
)
})
it("should correctly consider property-level examples", function (client) {
client
.click(`select.content-type option[value="application/json_property-level"]`)
.assert.containsText(`pre.body-param__example`,
dedent(`
{
"code": "AE1",
"name": "Andrew"
}
`)
)
})
})
describe("responses", function() {
it("should correctly consider media type-level examples", function (client) {
client.assert.containsText(`tr.response[data-code="200"] pre`,
dedent(`
{
"code": 200,
"payload": [
{
"id": 1,
"code": "AE2",
"name": "Yono"
}
]
}
`)
)
})
it("should correctly consider schema-level examples", function (client) {
client.assert.containsText(`tr.response[data-code="201"] pre`,
dedent(`
{
"code": 201,
"payload": [
{
"id": 1,
"code": "AE2",
"name": "Yono"
}
]
}
`)
)
})
it("should correctly consider property-level examples", function (client) {
client.assert.containsText(`tr.response[data-code="202"] pre`,
dedent(`
{
"code": 202,
"payload": [
{
"id": 1,
"code": "AE2",
"name": "Yono"
}
]
}
`)
)
})
})
})
})

View File

@ -0,0 +1,58 @@
describe("parameter enum rendering", function () {
describe("swagger 2.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.waitForElementVisible(".download-url-input", 10000)
.pause(1000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/features/parameter-enum-rendering.swagger.yaml")
.click("button.download-url-button")
.pause(1000)
done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's enums and defaults when viewing that parameter", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/report")
.click(".opblock")
.waitForElementVisible(".opblock.is-open", 5000)
.pause(500)
.assert.containsText("div.parameter__enum", "today, yesterday, lastweek")
.assert.containsText("div.parameter__default", "today")
client.end()
})
})
describe("openapi 3.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.waitForElementVisible(".download-url-input", 10000)
.pause(1000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/features/parameter-enum-rendering.openapi.yaml")
.click("button.download-url-button")
.pause(1000)
done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's enums and defaults when viewing that parameter", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/report")
.click(".opblock")
.waitForElementVisible(".opblock.is-open", 5000)
.pause(500)
.assert.containsText("div.parameter__enum", "today, yesterday, lastweek")
.assert.containsText("div.parameter__default", "today")
client.end()
})
})
})

View File

@ -0,0 +1,64 @@
describe("parameter example rendering", function () {
describe("swagger 2.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.swagger.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock", 10000)
.click("#operations-default-put_one")
.waitForElementVisible("#operations-default-put_one.is-open", 5000)
done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's example when viewing that parameter", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/one")
.click(".opblock")
.waitForElementVisible(".opblock.is-open", 5000)
.pause(500)
.assert.containsText(`tr[data-param-name="ValidParam"]`, `12345`)
client.end()
})
})
describe("openapi 3.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.openapi.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock-summary-description", 10000)
.click("#operations-agent-editAgent")
.waitForElementVisible("#operations-agent-editAgent.is-open", 5000)
done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's example when viewing that parameter", function (client) {
it("should respect a primitive example value", function(client) {
client
.assert.value(
`div.parameters-container > div > table > tbody > tr > td.col.parameters-col_description > input[type="text"]`,
`12345`
)
client.end()
})
})
})
})