Skip to content

Commit

Permalink
bug: remove clearValidation from onTryoutClick
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lai committed May 6, 2020
1 parent 5eb23cd commit 9dfb308
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/core/components/execute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export default class Execute extends Component {
this.props.onExecute()
}
specActions.execute( { operation, path, method } )
} else {
// deferred by 40ms, to give element class change time to settle.
specActions.clearValidateParams( [path, method] )
setTimeout(() => {
specActions.validateParams([path, method])
}, 40)
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/core/containers/OperationContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export default class OperationContainer extends PureComponent {
}

onTryoutClick =() => {
let { specActions, path, method } = this.props
this.setState({tryItOutEnabled: !this.state.tryItOutEnabled})
specActions.clearValidateParams([path, method])
}

onExecute = () => {
Expand Down
32 changes: 32 additions & 0 deletions test/e2e-cypress/tests/bugs/5070.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe("#5070: Required field not highlighted on click of Execute button (second time)", () => {
it("should not clear error class=invalid on input field (Swagger)", () => {
cy
.visit("/?url=/documents/petstore.swagger.yaml")
.get("#operations-pet-getPetById")
.click()
// Expand Try It Out
.get(".try-out__btn")
.click()
// Execute without user input
.get(".execute.opblock-control__btn")
.click()
.get(".parameters-col_description input")
.should($el => {
expect($el).to.have.length(1)
const className = $el[0].className
expect(className).to.match(/invalid/i)
})
// Cancel Try It Out
.get(".cancel")
.click()
// Expand Try It Out (Again)
.get(".try-out__btn")
.click()
.get(".parameters-col_description input")
.should($el => {
expect($el).to.have.length(1)
const className = $el[0].className
expect(className).to.match(/invalid/i)
})
})
})

0 comments on commit 9dfb308

Please sign in to comment.