cypress-on-rails 1.10.1 → 1.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +63 -0
  3. data/.gitignore +5 -1
  4. data/CHANGELOG.md +65 -2
  5. data/README.md +261 -62
  6. data/cypress-on-rails.gemspec +1 -0
  7. data/docs/authentication.md +12 -10
  8. data/docs/factory_bot_associations.md +109 -0
  9. data/lib/cypress-on-rails.rb +2 -2
  10. data/lib/cypress_on_rails/command_executor.rb +9 -5
  11. data/lib/cypress_on_rails/configuration.rb +17 -2
  12. data/lib/cypress_on_rails/middleware.rb +15 -16
  13. data/lib/cypress_on_rails/middleware_config.rb +17 -0
  14. data/lib/cypress_on_rails/railtie.rb +5 -1
  15. data/lib/cypress_on_rails/smart_factory_wrapper.rb +49 -14
  16. data/lib/cypress_on_rails/vcr_middleware.rb +73 -0
  17. data/lib/cypress_on_rails/version.rb +1 -1
  18. data/lib/generators/cypress_on_rails/install_generator.rb +48 -30
  19. data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +3 -1
  20. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/advance_factory_bot_spec.js → e2e/rails_examples/advance_factory_bot.cy.js} +1 -1
  21. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/other_spec.js → e2e/rails_examples/other.cy.js} +1 -1
  22. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_factory_bot_spec.js → e2e/rails_examples/using_factory_bot.cy.js} +1 -1
  23. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_fixtures_spec.js → e2e/rails_examples/using_fixtures.cy.js} +1 -1
  24. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_scenarios_spec.js → e2e/rails_examples/using_scenarios.cy.js} +1 -1
  25. data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js +24 -0
  26. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/{index.js → index.js.erb} +1 -0
  27. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +9 -7
  28. data/lib/generators/cypress_on_rails/templates/spec/cypress.config.js +9 -0
  29. data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/clean.rb +8 -0
  30. data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/log_fail.rb +2 -0
  31. data/lib/generators/cypress_on_rails/templates/spec/{cypress/cypress_helper.rb → e2e/e2e_helper.rb.erb} +6 -1
  32. data/lib/generators/cypress_on_rails/templates/spec/playwright/e2e/rails_examples/using_scenarios.spec.js +12 -0
  33. data/lib/generators/cypress_on_rails/templates/spec/playwright/support/index.js.erb +21 -0
  34. data/lib/generators/cypress_on_rails/templates/spec/playwright/support/on-rails.js +37 -0
  35. data/lib/generators/cypress_on_rails/templates/spec/playwright.config.js +79 -0
  36. data/lib/generators/cypress_on_rails/update_generator.rb +14 -3
  37. data/plugin/.gitignore +1 -0
  38. data/plugin/cypress/plugins/index.js +4 -0
  39. data/plugin/package.json +31 -0
  40. data/plugin/support/index.js +37 -0
  41. data/spec/cypress_on_rails/command_executor_spec.rb +1 -1
  42. data/spec/cypress_on_rails/configuration_spec.rb +6 -3
  43. data/spec/cypress_on_rails/middleware_spec.rb +24 -22
  44. data/spec/cypress_on_rails/smart_factory_wrapper_spec.rb +33 -1
  45. data/spec/cypress_on_rails/vcr_middleware_spec.rb +119 -0
  46. data/specs_e2e/cypress.config.js +10 -0
  47. data/specs_e2e/playwright.config.js +79 -0
  48. data/{spec/integrations → specs_e2e}/rails_3_2/.gitignore +1 -1
  49. data/specs_e2e/rails_3_2/.ruby_version +1 -0
  50. data/{spec/integrations → specs_e2e}/rails_3_2/Gemfile +1 -1
  51. data/{spec/integrations → specs_e2e}/rails_3_2/test.sh +17 -11
  52. data/{spec/integrations → specs_e2e}/rails_4_2/.gitignore +3 -2
  53. data/{spec/integrations → specs_e2e}/rails_4_2/Gemfile +3 -1
  54. data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +10 -0
  55. data/{spec/integrations → specs_e2e}/rails_4_2/app/models/post.rb +3 -1
  56. data/specs_e2e/rails_4_2/app/views/using_vcr/index.html.erb +6 -0
  57. data/specs_e2e/rails_4_2/app/views/using_vcr/record_cats.html.erb +7 -0
  58. data/{spec/integrations → specs_e2e}/rails_4_2/config/routes.rb +5 -0
  59. data/specs_e2e/rails_4_2/package.json +10 -0
  60. data/specs_e2e/rails_4_2/test.sh +44 -0
  61. data/{spec/integrations → specs_e2e}/rails_5_2/.gitignore +1 -1
  62. data/{spec/integrations → specs_e2e}/rails_5_2/Gemfile +1 -1
  63. data/specs_e2e/rails_5_2/app/assets/javascripts/posts.js +2 -0
  64. data/specs_e2e/rails_5_2/app/assets/stylesheets/posts.css +4 -0
  65. data/specs_e2e/rails_5_2/test.sh +48 -0
  66. metadata +190 -177
  67. data/.travis.yml +0 -39
  68. data/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json +0 -5
  69. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js +0 -272
  70. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/aliasing.spec.js +0 -42
  71. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/assertions.spec.js +0 -63
  72. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/connectors.spec.js +0 -55
  73. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cookies.spec.js +0 -78
  74. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js +0 -211
  75. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/files.spec.js +0 -86
  76. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/local_storage.spec.js +0 -52
  77. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/location.spec.js +0 -32
  78. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/misc.spec.js +0 -68
  79. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/navigation.spec.js +0 -54
  80. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/network_requests.spec.js +0 -108
  81. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/querying.spec.js +0 -65
  82. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/spies_stubs_clocks.spec.js +0 -62
  83. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/traversal.spec.js +0 -121
  84. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/utilities.spec.js +0 -89
  85. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/viewport.spec.js +0 -59
  86. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/waiting.spec.js +0 -34
  87. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/window.spec.js +0 -22
  88. data/lib/generators/cypress_on_rails/templates/spec/cypress.json +0 -4
  89. data/spec/integrations/cypress.json +0 -5
  90. data/spec/integrations/rails_4_2/test.sh +0 -38
  91. data/spec/integrations/rails_5_2/test.sh +0 -41
  92. data/spec/integrations/rails_5_2/tmp/.keep +0 -0
  93. data/spec/integrations/rails_5_2/vendor/.keep +0 -0
  94. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/activerecord_fixtures.rb +0 -0
  95. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/eval.rb +0 -0
  96. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/factory_bot.rb +0 -0
  97. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/scenarios/basic.rb +0 -0
  98. /data/spec/cypress_on_rails/command_executor/{cypress_helper.rb → e2e_helper.rb} +0 -0
  99. /data/{spec/integrations → specs_e2e}/rails_3_2/README.rdoc +0 -0
  100. /data/{spec/integrations → specs_e2e}/rails_3_2/Rakefile +0 -0
  101. /data/{spec/integrations → specs_e2e}/rails_3_2/app/assets/stylesheets/application.css +0 -0
  102. /data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/application_controller.rb +0 -0
  103. /data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/welcome_controller.rb +0 -0
  104. /data/{spec/integrations → specs_e2e}/rails_3_2/app/helpers/application_helper.rb +0 -0
  105. /data/{spec/integrations → specs_e2e}/rails_3_2/app/models/post.rb +0 -0
  106. /data/{spec/integrations → specs_e2e}/rails_3_2/app/views/layouts/application.html.erb +0 -0
  107. /data/{spec/integrations → specs_e2e}/rails_3_2/app/views/welcome/index.html.erb +0 -0
  108. /data/{spec/integrations → specs_e2e}/rails_3_2/bin/rails +0 -0
  109. /data/{spec/integrations → specs_e2e}/rails_3_2/config/application.rb +0 -0
  110. /data/{spec/integrations → specs_e2e}/rails_3_2/config/boot.rb +0 -0
  111. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environment.rb +0 -0
  112. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/development.rb +0 -0
  113. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/production.rb +0 -0
  114. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/test.rb +0 -0
  115. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/backtrace_silencers.rb +0 -0
  116. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/inflections.rb +0 -0
  117. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/mime_types.rb +0 -0
  118. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/secret_token.rb +0 -0
  119. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/session_store.rb +0 -0
  120. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/wrap_parameters.rb +0 -0
  121. /data/{spec/integrations → specs_e2e}/rails_3_2/config/locales/en.yml +0 -0
  122. /data/{spec/integrations → specs_e2e}/rails_3_2/config/routes.rb +0 -0
  123. /data/{spec/integrations → specs_e2e}/rails_3_2/config.ru +0 -0
  124. /data/{spec/integrations → specs_e2e}/rails_3_2/log/.keep +0 -0
  125. /data/{spec/integrations → specs_e2e}/rails_3_2/public/404.html +0 -0
  126. /data/{spec/integrations → specs_e2e}/rails_3_2/public/422.html +0 -0
  127. /data/{spec/integrations → specs_e2e}/rails_3_2/public/500.html +0 -0
  128. /data/{spec/integrations → specs_e2e}/rails_3_2/public/favicon.ico +0 -0
  129. /data/{spec/integrations → specs_e2e}/rails_3_2/public/robots.txt +0 -0
  130. /data/{spec/integrations → specs_e2e}/rails_3_2/tmp/.keep +0 -0
  131. /data/{spec/integrations → specs_e2e}/rails_3_2/vendor/.gitkeep +0 -0
  132. /data/{spec/integrations → specs_e2e}/rails_4_2/README.rdoc +0 -0
  133. /data/{spec/integrations → specs_e2e}/rails_4_2/Rakefile +0 -0
  134. /data/{spec/integrations/rails_5_2/app/assets/javascripts/posts.js → specs_e2e/rails_4_2/app/assets/javascripts/using_vcr.js} +0 -0
  135. /data/{spec/integrations/rails_5_2/app/assets/stylesheets/posts.css → specs_e2e/rails_4_2/app/assets/stylesheets/using_vcr.css} +0 -0
  136. /data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/application_controller.rb +0 -0
  137. /data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/welcome_controller.rb +0 -0
  138. /data/{spec/integrations → specs_e2e}/rails_4_2/app/views/layouts/application.html.erb +0 -0
  139. /data/{spec/integrations → specs_e2e}/rails_4_2/app/views/welcome/index.html.erb +0 -0
  140. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/bundle +0 -0
  141. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/rails +0 -0
  142. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/rake +0 -0
  143. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/setup +0 -0
  144. /data/{spec/integrations → specs_e2e}/rails_4_2/config/application.rb +0 -0
  145. /data/{spec/integrations → specs_e2e}/rails_4_2/config/boot.rb +0 -0
  146. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environment.rb +0 -0
  147. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/development.rb +0 -0
  148. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/production.rb +0 -0
  149. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/test.rb +0 -0
  150. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/backtrace_silencers.rb +0 -0
  151. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/cookies_serializer.rb +0 -0
  152. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/filter_parameter_logging.rb +0 -0
  153. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/inflections.rb +0 -0
  154. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/mime_types.rb +0 -0
  155. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/session_store.rb +0 -0
  156. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/to_time_preserves_timezone.rb +0 -0
  157. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/wrap_parameters.rb +0 -0
  158. /data/{spec/integrations → specs_e2e}/rails_4_2/config/locales/en.yml +0 -0
  159. /data/{spec/integrations → specs_e2e}/rails_4_2/config/secrets.yml +0 -0
  160. /data/{spec/integrations → specs_e2e}/rails_4_2/config.ru +0 -0
  161. /data/{spec/integrations → specs_e2e}/rails_4_2/public/404.html +0 -0
  162. /data/{spec/integrations → specs_e2e}/rails_4_2/public/422.html +0 -0
  163. /data/{spec/integrations → specs_e2e}/rails_4_2/public/500.html +0 -0
  164. /data/{spec/integrations → specs_e2e}/rails_4_2/public/favicon.ico +0 -0
  165. /data/{spec/integrations → specs_e2e}/rails_4_2/public/robots.txt +0 -0
  166. /data/{spec/integrations/rails_4_2/log → specs_e2e/rails_4_2/spec}/.keep +0 -0
  167. /data/{spec/integrations/rails_4_2/spec → specs_e2e/rails_4_2/vendor}/.keep +0 -0
  168. /data/{spec/integrations → specs_e2e}/rails_5_2/README.md +0 -0
  169. /data/{spec/integrations → specs_e2e}/rails_5_2/Rakefile +0 -0
  170. /data/{spec/integrations → specs_e2e}/rails_5_2/app/assets/stylesheets/scaffold.css +0 -0
  171. /data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/application_controller.rb +0 -0
  172. /data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/posts_controller.rb +0 -0
  173. /data/{spec/integrations → specs_e2e}/rails_5_2/app/helpers/posts_helper.rb +0 -0
  174. /data/{spec/integrations → specs_e2e}/rails_5_2/app/jobs/application_job.rb +0 -0
  175. /data/{spec/integrations → specs_e2e}/rails_5_2/app/models/application_record.rb +0 -0
  176. /data/{spec/integrations → specs_e2e}/rails_5_2/app/models/post.rb +0 -0
  177. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/layouts/application.html.erb +0 -0
  178. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/_form.html.erb +0 -0
  179. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/edit.html.erb +0 -0
  180. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/index.html.erb +0 -0
  181. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/new.html.erb +0 -0
  182. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/show.html.erb +0 -0
  183. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/welcome/index.html.erb +0 -0
  184. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/bundle +0 -0
  185. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/rails +0 -0
  186. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/rake +0 -0
  187. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/setup +0 -0
  188. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/update +0 -0
  189. /data/{spec/integrations → specs_e2e}/rails_5_2/config/application.rb +0 -0
  190. /data/{spec/integrations → specs_e2e}/rails_5_2/config/boot.rb +0 -0
  191. /data/{spec/integrations → specs_e2e}/rails_5_2/config/credentials.yml.enc +0 -0
  192. /data/{spec/integrations → specs_e2e}/rails_5_2/config/database.yml +0 -0
  193. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environment.rb +0 -0
  194. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/development.rb +0 -0
  195. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/production.rb +0 -0
  196. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/test.rb +0 -0
  197. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/application_controller_renderer.rb +0 -0
  198. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/backtrace_silencers.rb +0 -0
  199. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/content_security_policy.rb +0 -0
  200. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/cookies_serializer.rb +0 -0
  201. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/filter_parameter_logging.rb +0 -0
  202. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/inflections.rb +0 -0
  203. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/mime_types.rb +0 -0
  204. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/wrap_parameters.rb +0 -0
  205. /data/{spec/integrations → specs_e2e}/rails_5_2/config/locales/en.yml +0 -0
  206. /data/{spec/integrations → specs_e2e}/rails_5_2/config/master.key +0 -0
  207. /data/{spec/integrations → specs_e2e}/rails_5_2/config/routes.rb +0 -0
  208. /data/{spec/integrations → specs_e2e}/rails_5_2/config.ru +0 -0
  209. /data/{spec/integrations → specs_e2e}/rails_5_2/db/migrate/20180621085832_create_posts.rb +0 -0
  210. /data/{spec/integrations → specs_e2e}/rails_5_2/public/404.html +0 -0
  211. /data/{spec/integrations → specs_e2e}/rails_5_2/public/422.html +0 -0
  212. /data/{spec/integrations → specs_e2e}/rails_5_2/public/500.html +0 -0
  213. /data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon-precomposed.png +0 -0
  214. /data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon.png +0 -0
  215. /data/{spec/integrations → specs_e2e}/rails_5_2/public/favicon.ico +0 -0
  216. /data/{spec/integrations → specs_e2e}/rails_5_2/public/robots.txt +0 -0
  217. /data/{spec/integrations → specs_e2e}/rails_5_2/test/controllers/posts_controller_test.rb +0 -0
  218. /data/{spec/integrations → specs_e2e}/rails_5_2/test/cypress_fixtures/posts.yml +0 -0
  219. /data/{spec/integrations → specs_e2e}/rails_5_2/test/fixtures/posts.yml +0 -0
  220. /data/{spec/integrations → specs_e2e}/rails_5_2/test/models/post_test.rb +0 -0
  221. /data/{spec/integrations/rails_4_2 → specs_e2e/rails_5_2}/vendor/.keep +0 -0
  222. /data/{spec/integrations/rails_5_2/log/.keep → tmp/pids/.gitkeep} +0 -0
@@ -1,272 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Actions', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/actions')
6
- })
7
-
8
- // https://on.cypress.io/interacting-with-elements
9
-
10
- it('.type() - type into a DOM element', () => {
11
- // https://on.cypress.io/type
12
- cy.get('.action-email')
13
- .type('fake@email.com').should('have.value', 'fake@email.com')
14
-
15
- // .type() with special character sequences
16
- .type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
17
- .type('{del}{selectall}{backspace}')
18
-
19
- // .type() with key modifiers
20
- .type('{alt}{option}') //these are equivalent
21
- .type('{ctrl}{control}') //these are equivalent
22
- .type('{meta}{command}{cmd}') //these are equivalent
23
- .type('{shift}')
24
-
25
- // Delay each keypress by 0.1 sec
26
- .type('slow.typing@email.com', { delay: 100 })
27
- .should('have.value', 'slow.typing@email.com')
28
-
29
- cy.get('.action-disabled')
30
- // Ignore error checking prior to type
31
- // like whether the input is visible or disabled
32
- .type('disabled error checking', { force: true })
33
- .should('have.value', 'disabled error checking')
34
- })
35
-
36
- it('.focus() - focus on a DOM element', () => {
37
- // https://on.cypress.io/focus
38
- cy.get('.action-focus').focus()
39
- .should('have.class', 'focus')
40
- .prev().should('have.attr', 'style', 'color: orange;')
41
- })
42
-
43
- it('.blur() - blur off a DOM element', () => {
44
- // https://on.cypress.io/blur
45
- cy.get('.action-blur').type('About to blur').blur()
46
- .should('have.class', 'error')
47
- .prev().should('have.attr', 'style', 'color: red;')
48
- })
49
-
50
- it('.clear() - clears an input or textarea element', () => {
51
- // https://on.cypress.io/clear
52
- cy.get('.action-clear').type('Clear this text')
53
- .should('have.value', 'Clear this text')
54
- .clear()
55
- .should('have.value', '')
56
- })
57
-
58
- it('.submit() - submit a form', () => {
59
- // https://on.cypress.io/submit
60
- cy.get('.action-form')
61
- .find('[type="text"]').type('HALFOFF')
62
- cy.get('.action-form').submit()
63
- .next().should('contain', 'Your form has been submitted!')
64
- })
65
-
66
- it('.click() - click on a DOM element', () => {
67
- // https://on.cypress.io/click
68
- cy.get('.action-btn').click()
69
-
70
- // You can click on 9 specific positions of an element:
71
- // -----------------------------------
72
- // | topLeft top topRight |
73
- // | |
74
- // | |
75
- // | |
76
- // | left center right |
77
- // | |
78
- // | |
79
- // | |
80
- // | bottomLeft bottom bottomRight |
81
- // -----------------------------------
82
-
83
- // clicking in the center of the element is the default
84
- cy.get('#action-canvas').click()
85
-
86
- cy.get('#action-canvas').click('topLeft')
87
- cy.get('#action-canvas').click('top')
88
- cy.get('#action-canvas').click('topRight')
89
- cy.get('#action-canvas').click('left')
90
- cy.get('#action-canvas').click('right')
91
- cy.get('#action-canvas').click('bottomLeft')
92
- cy.get('#action-canvas').click('bottom')
93
- cy.get('#action-canvas').click('bottomRight')
94
-
95
- // .click() accepts an x and y coordinate
96
- // that controls where the click occurs :)
97
-
98
- cy.get('#action-canvas')
99
- .click(80, 75) // click 80px on x coord and 75px on y coord
100
- .click(170, 75)
101
- .click(80, 165)
102
- .click(100, 185)
103
- .click(125, 190)
104
- .click(150, 185)
105
- .click(170, 165)
106
-
107
- // click multiple elements by passing multiple: true
108
- cy.get('.action-labels>.label').click({ multiple: true })
109
-
110
- // Ignore error checking prior to clicking
111
- cy.get('.action-opacity>.btn').click({ force: true })
112
- })
113
-
114
- it('.dblclick() - double click on a DOM element', () => {
115
- // https://on.cypress.io/dblclick
116
-
117
- // Our app has a listener on 'dblclick' event in our 'scripts.js'
118
- // that hides the div and shows an input on double click
119
- cy.get('.action-div').dblclick().should('not.be.visible')
120
- cy.get('.action-input-hidden').should('be.visible')
121
- })
122
-
123
- it('.check() - check a checkbox or radio element', () => {
124
- // https://on.cypress.io/check
125
-
126
- // By default, .check() will check all
127
- // matching checkbox or radio elements in succession, one after another
128
- cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]')
129
- .check().should('be.checked')
130
-
131
- cy.get('.action-radios [type="radio"]').not('[disabled]')
132
- .check().should('be.checked')
133
-
134
- // .check() accepts a value argument
135
- cy.get('.action-radios [type="radio"]')
136
- .check('radio1').should('be.checked')
137
-
138
- // .check() accepts an array of values
139
- cy.get('.action-multiple-checkboxes [type="checkbox"]')
140
- .check(['checkbox1', 'checkbox2']).should('be.checked')
141
-
142
- // Ignore error checking prior to checking
143
- cy.get('.action-checkboxes [disabled]')
144
- .check({ force: true }).should('be.checked')
145
-
146
- cy.get('.action-radios [type="radio"]')
147
- .check('radio3', { force: true }).should('be.checked')
148
- })
149
-
150
- it('.uncheck() - uncheck a checkbox element', () => {
151
- // https://on.cypress.io/uncheck
152
-
153
- // By default, .uncheck() will uncheck all matching
154
- // checkbox elements in succession, one after another
155
- cy.get('.action-check [type="checkbox"]')
156
- .not('[disabled]')
157
- .uncheck().should('not.be.checked')
158
-
159
- // .uncheck() accepts a value argument
160
- cy.get('.action-check [type="checkbox"]')
161
- .check('checkbox1')
162
- .uncheck('checkbox1').should('not.be.checked')
163
-
164
- // .uncheck() accepts an array of values
165
- cy.get('.action-check [type="checkbox"]')
166
- .check(['checkbox1', 'checkbox3'])
167
- .uncheck(['checkbox1', 'checkbox3']).should('not.be.checked')
168
-
169
- // Ignore error checking prior to unchecking
170
- cy.get('.action-check [disabled]')
171
- .uncheck({ force: true }).should('not.be.checked')
172
- })
173
-
174
- it('.select() - select an option in a <select> element', () => {
175
- // https://on.cypress.io/select
176
-
177
- // Select option(s) with matching text content
178
- cy.get('.action-select').select('apples')
179
-
180
- cy.get('.action-select-multiple')
181
- .select(['apples', 'oranges', 'bananas'])
182
-
183
- // Select option(s) with matching value
184
- cy.get('.action-select').select('fr-bananas')
185
-
186
- cy.get('.action-select-multiple')
187
- .select(['fr-apples', 'fr-oranges', 'fr-bananas'])
188
- })
189
-
190
- it('.scrollIntoView() - scroll an element into view', () => {
191
- // https://on.cypress.io/scrollintoview
192
-
193
- // normally all of these buttons are hidden,
194
- // because they're not within
195
- // the viewable area of their parent
196
- // (we need to scroll to see them)
197
- cy.get('#scroll-horizontal button')
198
- .should('not.be.visible')
199
-
200
- // scroll the button into view, as if the user had scrolled
201
- cy.get('#scroll-horizontal button').scrollIntoView()
202
- .should('be.visible')
203
-
204
- cy.get('#scroll-vertical button')
205
- .should('not.be.visible')
206
-
207
- // Cypress handles the scroll direction needed
208
- cy.get('#scroll-vertical button').scrollIntoView()
209
- .should('be.visible')
210
-
211
- cy.get('#scroll-both button')
212
- .should('not.be.visible')
213
-
214
- // Cypress knows to scroll to the right and down
215
- cy.get('#scroll-both button').scrollIntoView()
216
- .should('be.visible')
217
- })
218
-
219
- it('cy.scrollTo() - scroll the window or element to a position', () => {
220
-
221
- // https://on.cypress.io/scrollTo
222
-
223
- // You can scroll to 9 specific positions of an element:
224
- // -----------------------------------
225
- // | topLeft top topRight |
226
- // | |
227
- // | |
228
- // | |
229
- // | left center right |
230
- // | |
231
- // | |
232
- // | |
233
- // | bottomLeft bottom bottomRight |
234
- // -----------------------------------
235
-
236
- // if you chain .scrollTo() off of cy, we will
237
- // scroll the entire window
238
- cy.scrollTo('bottom')
239
-
240
- cy.get('#scrollable-horizontal').scrollTo('right')
241
-
242
- // or you can scroll to a specific coordinate:
243
- // (x axis, y axis) in pixels
244
- cy.get('#scrollable-vertical').scrollTo(250, 250)
245
-
246
- // or you can scroll to a specific percentage
247
- // of the (width, height) of the element
248
- cy.get('#scrollable-both').scrollTo('75%', '25%')
249
-
250
- // control the easing of the scroll (default is 'swing')
251
- cy.get('#scrollable-vertical').scrollTo('center', { easing: 'linear' })
252
-
253
- // control the duration of the scroll (in ms)
254
- cy.get('#scrollable-both').scrollTo('center', { duration: 2000 })
255
- })
256
-
257
- it('.trigger() - trigger an event on a DOM element', () => {
258
- // https://on.cypress.io/trigger
259
-
260
- // To interact with a range input (slider)
261
- // we need to set its value & trigger the
262
- // event to signal it changed
263
-
264
- // Here, we invoke jQuery's val() method to set
265
- // the value and trigger the 'change' event
266
- cy.get('.trigger-input-range')
267
- .invoke('val', 25)
268
- .trigger('change')
269
- .get('input[type=range]').siblings('p')
270
- .should('have.text', '25')
271
- })
272
- })
@@ -1,42 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Aliasing', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/aliasing')
6
- })
7
-
8
- it('.as() - alias a DOM element for later use', () => {
9
- // https://on.cypress.io/as
10
-
11
- // Alias a DOM element for use later
12
- // We don't have to traverse to the element
13
- // later in our code, we reference it with @
14
-
15
- cy.get('.as-table').find('tbody>tr')
16
- .first().find('td').first()
17
- .find('button').as('firstBtn')
18
-
19
- // when we reference the alias, we place an
20
- // @ in front of its name
21
- cy.get('@firstBtn').click()
22
-
23
- cy.get('@firstBtn')
24
- .should('have.class', 'btn-success')
25
- .and('contain', 'Changed')
26
- })
27
-
28
- it('.as() - alias a route for later use', () => {
29
-
30
- // Alias the route to wait for its response
31
- cy.server()
32
- cy.route('GET', 'comments/*').as('getComment')
33
-
34
- // we have code that gets a comment when
35
- // the button is clicked in scripts.js
36
- cy.get('.network-btn').click()
37
-
38
- // https://on.cypress.io/wait
39
- cy.wait('@getComment').its('status').should('eq', 200)
40
-
41
- })
42
- })
@@ -1,63 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Assertions', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/assertions')
6
- })
7
-
8
- describe('Implicit Assertions', () => {
9
-
10
- it('.should() - make an assertion about the current subject', () => {
11
- // https://on.cypress.io/should
12
- cy.get('.assertion-table')
13
- .find('tbody tr:last').should('have.class', 'success')
14
- })
15
-
16
- it('.and() - chain multiple assertions together', () => {
17
- // https://on.cypress.io/and
18
- cy.get('.assertions-link')
19
- .should('have.class', 'active')
20
- .and('have.attr', 'href')
21
- .and('include', 'cypress.io')
22
- })
23
- })
24
-
25
- describe('Explicit Assertions', () => {
26
- // https://on.cypress.io/assertions
27
- it('expect - make an assertion about a specified subject', () => {
28
- // We can use Chai's BDD style assertions
29
- expect(true).to.be.true
30
-
31
- // Pass a function to should that can have any number
32
- // of explicit assertions within it.
33
- cy.get('.assertions-p').find('p')
34
- .should(($p) => {
35
- // return an array of texts from all of the p's
36
- let texts = $p.map((i, el) => // https://on.cypress.io/$
37
- Cypress.$(el).text())
38
-
39
- // jquery map returns jquery object
40
- // and .get() convert this to simple array
41
- texts = texts.get()
42
-
43
- // array should have length of 3
44
- expect(texts).to.have.length(3)
45
-
46
- // set this specific subject
47
- expect(texts).to.deep.eq([
48
- 'Some text from first p',
49
- 'More text from second p',
50
- 'And even more text from third p',
51
- ])
52
- })
53
- })
54
-
55
- it('assert - assert shape of an object', () => {
56
- const person = {
57
- name: 'Joe',
58
- age: 20,
59
- }
60
- assert.isObject(person, 'value is object')
61
- })
62
- })
63
- })
@@ -1,55 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Connectors', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/connectors')
6
- })
7
-
8
- it('.each() - iterate over an array of elements', () => {
9
- // https://on.cypress.io/each
10
- cy.get('.connectors-each-ul>li')
11
- .each(($el, index, $list) => {
12
- console.log($el, index, $list)
13
- })
14
- })
15
-
16
- it('.its() - get properties on the current subject', () => {
17
- // https://on.cypress.io/its
18
- cy.get('.connectors-its-ul>li')
19
- // calls the 'length' property yielding that value
20
- .its('length')
21
- .should('be.gt', 2)
22
- })
23
-
24
- it('.invoke() - invoke a function on the current subject', () => {
25
- // our div is hidden in our script.js
26
- // $('.connectors-div').hide()
27
-
28
- // https://on.cypress.io/invoke
29
- cy.get('.connectors-div').should('be.hidden')
30
- // call the jquery method 'show' on the 'div.container'
31
- .invoke('show')
32
- .should('be.visible')
33
- })
34
-
35
- it('.spread() - spread an array as individual args to callback function', () => {
36
- // https://on.cypress.io/spread
37
- const arr = ['foo', 'bar', 'baz']
38
-
39
- cy.wrap(arr).spread((foo, bar, baz) => {
40
- expect(foo).to.eq('foo')
41
- expect(bar).to.eq('bar')
42
- expect(baz).to.eq('baz')
43
- })
44
- })
45
-
46
- it('.then() - invoke a callback function with the current subject', () => {
47
- // https://on.cypress.io/then
48
- cy.get('.connectors-list>li').then(($lis) => {
49
- expect($lis).to.have.length(3)
50
- expect($lis.eq(0)).to.contain('Walk the dog')
51
- expect($lis.eq(1)).to.contain('Feed the cat')
52
- expect($lis.eq(2)).to.contain('Write JavaScript')
53
- })
54
- })
55
- })
@@ -1,78 +0,0 @@
1
- /// <reference types="Cypress" />
2
-
3
- context('Cookies', () => {
4
- beforeEach(() => {
5
- Cypress.Cookies.debug(true)
6
-
7
- cy.visit('https://example.cypress.io/commands/cookies')
8
-
9
- // clear cookies again after visiting to remove
10
- // any 3rd party cookies picked up such as cloudflare
11
- cy.clearCookies()
12
- })
13
-
14
- it('cy.getCookie() - get a browser cookie', () => {
15
- // https://on.cypress.io/getcookie
16
- cy.get('#getCookie .set-a-cookie').click()
17
-
18
- // cy.getCookie() yields a cookie object
19
- cy.getCookie('token').should('have.property', 'value', '123ABC')
20
- })
21
-
22
- it('cy.getCookies() - get browser cookies', () => {
23
- // https://on.cypress.io/getcookies
24
- cy.getCookies().should('be.empty')
25
-
26
- cy.get('#getCookies .set-a-cookie').click()
27
-
28
- // cy.getCookies() yields an array of cookies
29
- cy.getCookies().should('have.length', 1).should((cookies) => {
30
-
31
- // each cookie has these properties
32
- expect(cookies[0]).to.have.property('name', 'token')
33
- expect(cookies[0]).to.have.property('value', '123ABC')
34
- expect(cookies[0]).to.have.property('httpOnly', false)
35
- expect(cookies[0]).to.have.property('secure', false)
36
- expect(cookies[0]).to.have.property('domain')
37
- expect(cookies[0]).to.have.property('path')
38
- })
39
- })
40
-
41
- it('cy.setCookie() - set a browser cookie', () => {
42
- // https://on.cypress.io/setcookie
43
- cy.getCookies().should('be.empty')
44
-
45
- cy.setCookie('foo', 'bar')
46
-
47
- // cy.getCookie() yields a cookie object
48
- cy.getCookie('foo').should('have.property', 'value', 'bar')
49
- })
50
-
51
- it('cy.clearCookie() - clear a browser cookie', () => {
52
- // https://on.cypress.io/clearcookie
53
- cy.getCookie('token').should('be.null')
54
-
55
- cy.get('#clearCookie .set-a-cookie').click()
56
-
57
- cy.getCookie('token').should('have.property', 'value', '123ABC')
58
-
59
- // cy.clearCookies() yields null
60
- cy.clearCookie('token').should('be.null')
61
-
62
- cy.getCookie('token').should('be.null')
63
- })
64
-
65
- it('cy.clearCookies() - clear browser cookies', () => {
66
- // https://on.cypress.io/clearcookies
67
- cy.getCookies().should('be.empty')
68
-
69
- cy.get('#clearCookies .set-a-cookie').click()
70
-
71
- cy.getCookies().should('have.length', 1)
72
-
73
- // cy.clearCookies() yields null
74
- cy.clearCookies()
75
-
76
- cy.getCookies().should('be.empty')
77
- })
78
- })