Skip to content

Commit

Permalink
test(cypress): modularize cypress features
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 30, 2024
1 parent 6cf4eaa commit c15059a
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
Feature: Cypress example
Scenario: Click and see text
Given I visit "https://example.cypress.io/"
Then I see text "Kitchen Sink"
And I do not see text "cy.get()"
When I click on text "get"
Then I see text "cy.get()"

Feature: Cypress actions
Scenario: See button, heading, link, and label
Given I visit "https://example.cypress.io/commands/actions"
Then I see heading "Actions"
Expand All @@ -32,12 +25,6 @@ Feature: Cypress example
When I click on label "Email address"
And I type "test@example.com"

Scenario: Hidden link
Given I visit "https://example.cypress.io/"
When I find link by text "Cypress.io"
And I set attribute "style" to "visibility: hidden"
Then I do not see link "Cypress.io"

Scenario: Force click
Given I visit "https://example.cypress.io/commands/actions"
Then I click on button "I'm being covered"
Expand Down Expand Up @@ -123,39 +110,12 @@ Feature: Cypress example
And I find input by label text "Password"
Then I see value ""

Scenario: Placeholder
Given I visit "https://example.cypress.io/commands/querying"
When I find elements by placeholder text "Name"
Then I count 1 element
When I find element by placeholder text "Name"
Then I count 1 element
When I find inputs by placeholder text "Name"
Then I count 1 element
When I find input by placeholder text "Name"
Then I count 1 element

Scenario: Test ID
Given I visit "https://example.cypress.io/commands/querying"
Then I see test ID "test-example"
And I do not see test ID "test-invalid"
When I find elements by test ID "test-example"
Then I count 1 element
When I find element by test ID "test-example"
Then I count 1 element
And I click on test ID "test-example"

Scenario: Blur
Given I visit "https://example.cypress.io/commands/actions"
And I find element by text "Full Name"
And I type "About to blur"
And I blur

Scenario: Hidden text
Given I visit "https://example.cypress.io/cypress-api"
Then I do not see visible text "I'm hiding!"
When I find element by text "I'm hiding!"
Then I see element is not visible

Scenario: Scroll window
Given I visit "https://example.cypress.io/commands/actions"
And I scroll window to 0px and 500px
Expand Down Expand Up @@ -203,39 +163,6 @@ Feature: Cypress example
And I click 150px and 185px
And I click 170px and 165px

Scenario: Get nth element
Given I visit "https://example.cypress.io/commands/aliasing"
When I find buttons by text "Change"
And I get first element
And I click "top-right"
Then I find buttons by text "Changed"
And I count 1 element
When I find buttons by text "Change"
And I get 2nd element
And I click "top"
Then I find buttons by text "Changed"
And I count 2 elements
When I find buttons by text "Change"
And I get 3rd element
And I click "bottom-right"
Then I find buttons by text "Changed"
And I count 3 elements
When I find buttons by text "Change"
And I get last element
And I click "bottom-left"
Then I find buttons by text "Changed"
And I count 4 elements
When I find links by text "cypress"
And I get 1st element
And I click "center"

Scenario: Count elements length
Given I visit "https://example.cypress.io/commands/aliasing"
When I find buttons by text "Get Comment"
Then I count 1 element
When I find buttons by text "Change"
Then I count 4 elements

Scenario: Find and set input value
Given I visit "https://example.cypress.io/commands/actions"
When I double-click on text "Double click to edit"
Expand Down Expand Up @@ -265,15 +192,6 @@ Feature: Cypress example
And I click on title ""
Then I see heading "Popover"

Scenario: Focus on element
Given I visit "https://example.cypress.io/commands/traversal"
When I get element by display value "Submit"
And I focus
And I get focused element
Then I see element has attribute "type"
And I get focused element
And I see element attribute "type" equals "submit"

Scenario: Find and submit form
Given I visit "https://example.cypress.io/commands/actions"
When I find form
Expand All @@ -287,114 +205,3 @@ Feature: Cypress example
And I find closest element "form"
And I submit
Then I see text "Your form has been submitted!"

Scenario: Form with textarea
Given I visit "https://example.cypress.io/commands/misc"
When I find form
And I get children
And I get last element
And I click
And I type "children"
Then I see textarea value "children"
And I see textarea value contains "child"

Scenario: Assert input value
Given I visit "https://example.cypress.io/commands/misc"
When I find element by label text "Name"
And I type "John Smith"
Then I see input value "John Smith"
And I see input value contains "John"
When I find input by label text "Name"
Then I see value "John Smith"

Scenario: Timers
Given I visit "https://example.cypress.io/commands/spies-stubs-clocks"
When I use fake timers
And I set system time to 1234567890000
And I click on text "Click for current time!"
Then I see text "1234567890"
When I reload the page
And I set system time to "2020-02-02"
And I click on text "Click for current time!"
Then I see text "1580601600"
When I advance timers by 300 milliseconds
And I advance timers by 1 millisecond
And I advance timers by 3 seconds
And I advance timers by 1 second
And I use real timers
And I click on text "Click for current time!"
Then I do not see text "15806016000"

Scenario: Intercept network requests
Given I visit "https://example.cypress.io/commands/network-requests"
When I intercept URL "/comments/1" and stub body '{"body":"Test 1"}'
And I click on button "Get Comment"
Then I see text "Test 1"
When I intercept URL "/comments/1"
| auth | {"username":"user","password":"pass"} |
| body | {"body":"Test 2"} |
| headers | {"X-Requested-With":"exampleClient"} |
| hostname | localhost |
| https | true |
| method | GET |
| middleware | false |
| path | /api/commands/intercept?foo=bar |
| pathname | /api/commands/intercept |
| port | 8080 |
| query | {"foo":"bar"} |
| resourceType | fetch |
| times | 1 |
And I click on button "Get Comment"
Then I see text "Test 2"

Scenario: Set environment variable
Given I visit "https://example.cypress.io/cypress-api"
When I set environment variable "api_server" to "http://localhost:8888/v2/"

Scenario: Cookie
Given I visit "https://example.cypress.io/commands/cookies"
When I set cookie "name" to "value"
Then I see cookie "name"
When I clear cookie "name"
Then I do not see cookie "name"
When I set cookie "foo" to "bar"
Then I see cookie "foo" has value "bar"
When I clear cookies
Then I do not see cookie "foo"
When I click on button "Set Cookie"
Then I see cookie "token" contains value "123"
When I clear all cookies
Then I do not see cookie "test"

Scenario: Local storage
Given I visit "https://example.cypress.io/commands/storage"
When I click on button "Populate localStorage and sessionStorage"
Then I see local storage item "prop1"
And I see local storage item "prop1" equals "red"
And I see local storage item "prop3" contains "gen"
When I clear local storage "prop1"
Then I do not see local storage item "prop1"
When I clear local storage
Then I do not see local storage item "prop2"
When I set local storage item "foo" to "bar"
Then I see local storage item "foo" equals "bar"
When I clear all local storage
Then I do not see local storage item "foo"

Scenario: Session storage
Given I visit "https://example.cypress.io/commands/storage"
When I click on button "Populate localStorage and sessionStorage"
Then I see session storage item "prop5"
And I see session storage item "prop5" equals "yellow"
And I see session storage item "prop4" contains "cy"
When I clear session storage
Then I do not see local storage item "prop5"

Scenario: Role
Given I visit "https://example.cypress.io/commands/querying"
When I find elements by role "button"
Then I see element exists
When I find element by role "button"
Then I see element is visible
And I see role "button"
And I do not see role "tooltip"
33 changes: 33 additions & 0 deletions cypress/e2e/cypress/example/commands/aliasing.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: Cypress aliasing
Scenario: Get nth element
Given I visit "https://example.cypress.io/commands/aliasing"
When I find buttons by text "Change"
And I get first element
And I click "top-right"
Then I find buttons by text "Changed"
And I count 1 element
When I find buttons by text "Change"
And I get 2nd element
And I click "top"
Then I find buttons by text "Changed"
And I count 2 elements
When I find buttons by text "Change"
And I get 3rd element
And I click "bottom-right"
Then I find buttons by text "Changed"
And I count 3 elements
When I find buttons by text "Change"
And I get last element
And I click "bottom-left"
Then I find buttons by text "Changed"
And I count 4 elements
When I find links by text "cypress"
And I get 1st element
And I click "center"

Scenario: Count elements length
Given I visit "https://example.cypress.io/commands/aliasing"
When I find buttons by text "Get Comment"
Then I count 1 element
When I find buttons by text "Change"
Then I count 4 elements
15 changes: 15 additions & 0 deletions cypress/e2e/cypress/example/commands/cookies.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: Cypress cookies
Scenario: Cookie
Given I visit "https://example.cypress.io/commands/cookies"
When I set cookie "name" to "value"
Then I see cookie "name"
When I clear cookie "name"
Then I do not see cookie "name"
When I set cookie "foo" to "bar"
Then I see cookie "foo" has value "bar"
When I clear cookies
Then I do not see cookie "foo"
When I click on button "Set Cookie"
Then I see cookie "token" contains value "123"
When I clear all cookies
Then I do not see cookie "test"
19 changes: 19 additions & 0 deletions cypress/e2e/cypress/example/commands/misc.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Cypress misc
Scenario: Form with textarea
Given I visit "https://example.cypress.io/commands/misc"
When I find form
And I get children
And I get last element
And I click
And I type "children"
Then I see textarea value "children"
And I see textarea value contains "child"

Scenario: Assert input value
Given I visit "https://example.cypress.io/commands/misc"
When I find element by label text "Name"
And I type "John Smith"
Then I see input value "John Smith"
And I see input value contains "John"
When I find input by label text "Name"
Then I see value "John Smith"
22 changes: 22 additions & 0 deletions cypress/e2e/cypress/example/commands/network-requests.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Feature: Cypress network requests
Scenario: Intercept network requests
Given I visit "https://example.cypress.io/commands/network-requests"
When I intercept URL "/comments/1" and stub body '{"body":"Test 1"}'
And I click on button "Get Comment"
Then I see text "Test 1"
When I intercept URL "/comments/1"
| auth | {"username":"user","password":"pass"} |
| body | {"body":"Test 2"} |
| headers | {"X-Requested-With":"exampleClient"} |
| hostname | localhost |
| https | true |
| method | GET |
| middleware | false |
| path | /api/commands/intercept?foo=bar |
| pathname | /api/commands/intercept |
| port | 8080 |
| query | {"foo":"bar"} |
| resourceType | fetch |
| times | 1 |
And I click on button "Get Comment"
Then I see text "Test 2"
30 changes: 30 additions & 0 deletions cypress/e2e/cypress/example/commands/querying.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Cypress querying
Scenario: Placeholder
Given I visit "https://example.cypress.io/commands/querying"
When I find elements by placeholder text "Name"
Then I count 1 element
When I find element by placeholder text "Name"
Then I count 1 element
When I find inputs by placeholder text "Name"
Then I count 1 element
When I find input by placeholder text "Name"
Then I count 1 element

Scenario: Test ID
Given I visit "https://example.cypress.io/commands/querying"
Then I see test ID "test-example"
And I do not see test ID "test-invalid"
When I find elements by test ID "test-example"
Then I count 1 element
When I find element by test ID "test-example"
Then I count 1 element
And I click on test ID "test-example"

Scenario: Role
Given I visit "https://example.cypress.io/commands/querying"
When I find elements by role "button"
Then I see element exists
When I find element by role "button"
Then I see element is visible
And I see role "button"
And I do not see role "tooltip"
18 changes: 18 additions & 0 deletions cypress/e2e/cypress/example/commands/spies-stubs-clocks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Cypress spies, stubs, clocks
Scenario: Timers
Given I visit "https://example.cypress.io/commands/spies-stubs-clocks"
When I use fake timers
And I set system time to 1234567890000
And I click on text "Click for current time!"
Then I see text "1234567890"
When I reload the page
And I set system time to "2020-02-02"
And I click on text "Click for current time!"
Then I see text "1580601600"
When I advance timers by 300 milliseconds
And I advance timers by 1 millisecond
And I advance timers by 3 seconds
And I advance timers by 1 second
And I use real timers
And I click on text "Click for current time!"
Then I do not see text "15806016000"
Loading

0 comments on commit c15059a

Please sign in to comment.