Skip to content

Commit

Permalink
chore: Revert submit validation (#15302)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Mar 3, 2021
1 parent e76edd7 commit fb593be
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 63 deletions.
21 changes: 0 additions & 21 deletions packages/driver/cypress/fixtures/dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -654,27 +654,6 @@
Cross domain iframe:<br>
<iframe id="iframe-cross-domain" src="http://localhost:3501/fixtures/generic.html"></iframe>
</div>

<form id="form-validation" action="/action_page.php">
<div>
<label for="item">Item:</label>
<input id="item" type="text" name="item" required />
</div>

<div>
<label for="quantity">Quantity (between 1 and 5):</label>
<input
type="number"
id="quantity"
name="quantity"
min="1"
max="5"
required
/>
</div>

<input type="submit" />
</form>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,6 @@ describe('src/cy/commands/actions/submit', () => {

cy.get('form:first').submit().should('have.class', 'submitted')
})

// https://github.com/cypress-io/cypress/issues/14911
it('should throw an error when form validation failed', function (done) {
cy.on('fail', (err) => {
expect(err.message).to.include('2 inputs')
expect(err.message).to.include('Please fill out this field.')

done()
})

cy.get('#form-validation').within(() => {
cy.get('input[type=submit]').click()
cy.root().submit()
})
})
})

describe('.log', () => {
Expand Down
20 changes: 0 additions & 20 deletions packages/driver/src/cy/commands/actions/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,6 @@ module.exports = (Commands, Cypress, cy) => {
})
}

// Validate form.
// @see https://github.com/cypress-io/cypress/issues/14911
if (!form.checkValidity()) {
const elements = form.querySelectorAll(':invalid')
const failures = _.map(elements, (el) => {
const element = $dom.stringify(el)
const message = el.validationMessage

return ` - \`${element}\`: ${message}`
})

$errUtils.throwErrByPath('submit.failed_validation', {
onFail: options._log,
args: {
failures: failures.join('\n'),
suffix: failures.length ? `${failures.length} inputs` : 'input',
},
})
}

// calling the native submit method will not actually trigger
// a submit event, so we need to dispatch this manually so
// native event listeners and jquery can bind to it
Expand Down
8 changes: 1 addition & 7 deletions packages/driver/src/cypress/error_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ module.exports = {
reached_redirection_limit ({ href, limit }) {
return stripIndent`\
The application redirected to \`${href}\` more than ${limit} times. Please check if it's an intended behavior.
If so, increase \`redirectionLimit\` value in configuration.`
},
},
Expand Down Expand Up @@ -1542,12 +1542,6 @@ module.exports = {
message: `${cmd('submit')} can only be called on a \`<form>\`. Your subject {{word}} a: \`{{node}}\``,
docsUrl: 'https://on.cypress.io/submit',
},
failed_validation: {
message: stripIndent`\
Form validation failed for the following {{suffix}}:
{{failures}}`,
docsUrl: 'https://on.cypress.io/submit',
},
},

task: {
Expand Down

0 comments on commit fb593be

Please sign in to comment.