Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: <Select disabled> for type: string + enum schemas #5601

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/json-schema-components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class JsonSchema_string extends Component {
allowedValues={ enumValue }
value={ value }
allowEmptyValue={ !required }
disabled={disabled}
onChange={ this.onEnumChange }/>)
}

Expand Down
4 changes: 4 additions & 0 deletions test/e2e-cypress/tests/bugs/5452.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ describe("#5452: <Select /> crashing in Parameters", function() {
cy.visit("http://localhost:3230/?url=/documents/bugs/5452/openapi.yaml")
.get("#operations-default-get_endpoint")
.click()
.get(".try-out__btn")
.click()
.get(".parameters > tbody > tr > .parameters-col_description > select")
.select("")
.get(".parameters > tbody > tr > .parameters-col_description > select")
Expand All @@ -22,6 +24,8 @@ describe("#5452: <Select /> crashing in Parameters", function() {
cy.visit("http://localhost:3230/?url=/documents/bugs/5452/swagger.yaml")
.get("#operations-default-get_endpoint")
.click()
.get(".try-out__btn")
.click()
.get(".parameters > tbody > tr > .parameters-col_description > select")
.select("")
.get(".parameters > tbody > tr > .parameters-col_description > select")
Expand Down
21 changes: 21 additions & 0 deletions test/mocha/components/json-schema-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ describe("<JsonSchemaForm/>", function(){
expect(wrapper.find("select option").eq(2).text()).toEqual("two")
})

it("should render a string enum as disabled when JsonSchemaForm is disabled", function(){

let props = {
getComponent: getComponentStub,
value: "",
onChange: () => {},
keyName: "",
fn: {},
schema: {
type: "string",
enum: ["one", "two"]
},
disabled: true
}

let wrapper = render(<JsonSchemaForm {...props}/>)

expect(wrapper.find("select").attr("disabled")).toEqual("disabled")
})


it("should render the correct options for a required string enum parameter", function(){

let props = {
Expand Down