diff --git a/src/core/json-schema-components.jsx b/src/core/json-schema-components.jsx
index 7d75df1c5f8..3147383cccd 100644
--- a/src/core/json-schema-components.jsx
+++ b/src/core/json-schema-components.jsx
@@ -158,9 +158,7 @@ export class JsonSchema_array extends PureComponent {
addItem = () => {
let newValue = valueOrEmptyList(this.state.value)
this.setState(() => ({
- value: newValue.push(getSampleSchema(this.state.schema.get("items"), false, {
- includeWriteOnly: true
- }))
+ value: newValue.push(null)
}), this.onChange)
}
@@ -211,6 +209,10 @@ export class JsonSchema_array extends PureComponent {
}
const Button = getComponent("Button")
+ const sampleSchema = getSampleSchema(this.state.schema.get("items"), false, {
+ includeWriteOnly: true
+ })
+
return (
{shouldRenderValue ?
@@ -236,6 +238,7 @@ export class JsonSchema_array extends PureComponent {
onChange={(val) => this.onItemChange(val, i)}
disabled={disabled}
errors={itemErrors}
+ description={sampleSchema}
/>
:
{
+ describe("String array parameter", () => {
+ it("should render button add only if no value", () => {
+ cy
+ .visit("/?url=/documents/features/edit-parameters/string-array-parameter.yaml")
+ .get(".opblock-summary-control")
+ .click()
+ .get(".try-out__btn")
+ .click()
+ .get(".json-schema-array")
+ .should("have.length", 1)
+ .find(".json-schema-form-item-add")
+ .should("be.visible")
+ })
+ it("should render an input if clicking on add button", () => {
+ cy
+ .visit("/?url=/documents/features/edit-parameters/string-array-parameter.yaml")
+ .get(".opblock-summary-control")
+ .click()
+ .get(".try-out__btn")
+ .click()
+
+ cy
+ .get(".json-schema-array")
+ .find(".json-schema-form-item-add")
+ .should("be.visible")
+ .click()
+ .get(".json-schema-array")
+ .children()
+ .should('have.length', 2)
+ })
+
+ it("should render an input with a placeholder if clicking on add button", () => {
+ cy
+ .visit("/?url=/documents/features/edit-parameters/string-array-parameter.yaml")
+ .get(".opblock-summary-control")
+ .click()
+ .get(".try-out__btn")
+ .click()
+ .get(".json-schema-array")
+ .children()
+
+ cy
+ .get(".json-schema-array")
+ .find(".json-schema-form-item-add")
+ .should("be.visible")
+ .click()
+
+ cy
+ .get(".json-schema-array input")
+ .should("have.attr", "placeholder")
+ .and('match', /string/)
+ })
+ })
+})