From 92c9dcf0d2b6192e87ec0b7c1671f1d43ab59bbd Mon Sep 17 00:00:00 2001 From: Tim Lai Date: Wed, 6 May 2020 14:07:22 -0700 Subject: [PATCH] bug: remove clearValidation from onTryoutClick (#5955) --- src/core/components/execute.jsx | 6 ++++ src/core/containers/OperationContainer.jsx | 2 -- test/e2e-cypress/tests/bugs/5070.js | 32 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/e2e-cypress/tests/bugs/5070.js diff --git a/src/core/components/execute.jsx b/src/core/components/execute.jsx index 23546ad622f..d9e8b4f462f 100644 --- a/src/core/components/execute.jsx +++ b/src/core/components/execute.jsx @@ -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) } } diff --git a/src/core/containers/OperationContainer.jsx b/src/core/containers/OperationContainer.jsx index a2ae9ccefb6..4cf009c0987 100644 --- a/src/core/containers/OperationContainer.jsx +++ b/src/core/containers/OperationContainer.jsx @@ -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 = () => { diff --git a/test/e2e-cypress/tests/bugs/5070.js b/test/e2e-cypress/tests/bugs/5070.js new file mode 100644 index 00000000000..a27ed782afa --- /dev/null +++ b/test/e2e-cypress/tests/bugs/5070.js @@ -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) + }) + }) +})