-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/// <reference types="cypress" /> | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
||
it.only('submits the terms forms', () => { | ||
cy.visit('cypress/terms.html') | ||
cy.get('#agreed') | ||
.if('not.checked') | ||
.click() | ||
.else() | ||
.log('The user already agreed') | ||
cy.get('button#submit').click() | ||
}) | ||
|
||
it('submits the terms forms using cy.then', () => { | ||
cy.visit('cypress/terms.html') | ||
cy.get('#agreed').then(($input) => { | ||
if ($input.is(':checked')) { | ||
cy.log('The user already agreed') | ||
} else { | ||
cy.wrap($input).click() | ||
} | ||
}) | ||
cy.get('button#submit').click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<html> | ||
<head> | ||
<style> | ||
button { | ||
margin-top: 1rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<input type="checkbox" id="agreed" /> | ||
<span>I agree to the terms & conditions.</span> | ||
</div> | ||
<button id="submit" disabled>Submit</button> | ||
<script> | ||
document.getElementById('agreed').addEventListener('change', (e) => { | ||
document.getElementById('submit').disabled = !e.target.checked | ||
}) | ||
|
||
if (Math.random() < 0.5) { | ||
console.log('checked = true') | ||
// in 50% of the cases, the checkbox is checked | ||
// in other cases, the checkbox is unchecked | ||
document.getElementById('agreed').checked = true | ||
document.getElementById('submit').disabled = false | ||
} else { | ||
console.log('checked = false') | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["cypress"] | ||
} | ||
} |