cypress-on-rails 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -14
  3. data/.gitignore +2 -1
  4. data/CHANGELOG.md +11 -0
  5. data/README.md +202 -48
  6. data/cypress-on-rails.gemspec +1 -1
  7. data/docs/authentication.md +30 -0
  8. data/docs/factory_bot_associations.md +14 -0
  9. data/lib/cypress_on_rails/configuration.rb +5 -0
  10. data/lib/cypress_on_rails/middleware.rb +1 -0
  11. data/lib/cypress_on_rails/railtie.rb +10 -2
  12. data/lib/cypress_on_rails/simple_rails_factory.rb +0 -2
  13. data/lib/cypress_on_rails/vcr/insert_eject_middleware.rb +75 -0
  14. data/lib/cypress_on_rails/vcr/middleware_helpers.rb +51 -0
  15. data/lib/cypress_on_rails/vcr/use_cassette_middleware.rb +56 -0
  16. data/lib/cypress_on_rails/version.rb +1 -1
  17. data/lib/generators/cypress_on_rails/install_generator.rb +31 -29
  18. data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +9 -1
  19. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/commands.js +22 -0
  20. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +7 -0
  21. data/lib/generators/cypress_on_rails/templates/spec/e2e/e2e_helper.rb.erb +0 -5
  22. data/spec/cypress_on_rails/configuration_spec.rb +4 -1
  23. data/spec/cypress_on_rails/vcr/insert_eject_middleware_spec.rb +177 -0
  24. data/spec/cypress_on_rails/vcr/use_cassette_middleware_spec.rb +68 -0
  25. data/specs_e2e/rails_6_1/.gitattributes +10 -0
  26. data/specs_e2e/{rails_5_2 → rails_6_1}/.gitignore +4 -0
  27. data/specs_e2e/rails_6_1/Gemfile +20 -0
  28. data/specs_e2e/{rails_5_2 → rails_6_1}/Rakefile +1 -1
  29. data/specs_e2e/rails_6_1/app/assets/stylesheets/application.css +15 -0
  30. data/specs_e2e/rails_6_1/app/jobs/application_job.rb +7 -0
  31. data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/layouts/application.html.erb +1 -1
  32. data/specs_e2e/rails_6_1/bin/bundle +114 -0
  33. data/specs_e2e/rails_6_1/bin/rails +5 -0
  34. data/specs_e2e/rails_6_1/bin/rake +5 -0
  35. data/specs_e2e/{rails_5_2 → rails_6_1}/bin/setup +15 -4
  36. data/specs_e2e/rails_6_1/bin/spring +14 -0
  37. data/specs_e2e/rails_6_1/bin/yarn +17 -0
  38. data/specs_e2e/rails_6_1/config/application.rb +34 -0
  39. data/specs_e2e/rails_6_1/config/boot.rb +4 -0
  40. data/specs_e2e/rails_6_1/config/cable.yml +10 -0
  41. data/specs_e2e/rails_6_1/config/credentials.yml.enc +1 -0
  42. data/specs_e2e/{rails_5_2 → rails_6_1}/config/database.yml +7 -0
  43. data/specs_e2e/{rails_5_2 → rails_6_1}/config/environment.rb +1 -1
  44. data/specs_e2e/{rails_5_2 → rails_6_1}/config/environments/development.rb +22 -5
  45. data/specs_e2e/rails_6_1/config/environments/production.rb +120 -0
  46. data/specs_e2e/{rails_5_2 → rails_6_1}/config/environments/test.rb +24 -7
  47. data/specs_e2e/rails_6_1/config/initializers/backtrace_silencers.rb +8 -0
  48. data/specs_e2e/{rails_5_2 → rails_6_1}/config/initializers/content_security_policy.rb +5 -0
  49. data/specs_e2e/{rails_4_2 → rails_6_1}/config/initializers/filter_parameter_logging.rb +3 -1
  50. data/specs_e2e/rails_6_1/config/initializers/permissions_policy.rb +11 -0
  51. data/specs_e2e/{rails_3_2 → rails_6_1}/config/initializers/wrap_parameters.rb +5 -1
  52. data/specs_e2e/{rails_5_2 → rails_6_1}/config/locales/en.yml +1 -1
  53. data/specs_e2e/rails_6_1/config/master.key +1 -0
  54. data/specs_e2e/rails_6_1/config/puma.rb +43 -0
  55. data/specs_e2e/rails_6_1/config/storage.yml +34 -0
  56. data/specs_e2e/{rails_5_2 → rails_6_1}/config.ru +2 -1
  57. data/specs_e2e/{rails_5_2 → rails_6_1}/db/migrate/20180621085832_create_posts.rb +1 -1
  58. data/specs_e2e/rails_6_1/package.json +8 -0
  59. data/specs_e2e/rails_6_1/playwright-report/index.html +71 -0
  60. data/specs_e2e/rails_6_1/public/robots.txt +1 -0
  61. data/specs_e2e/rails_6_1/test-results/.last-run.json +4 -0
  62. data/specs_e2e/rails_6_1/test.sh +57 -0
  63. data/specs_e2e/rails_7_2/.gitattributes +9 -0
  64. data/specs_e2e/rails_7_2/.gitignore +16 -0
  65. data/specs_e2e/rails_7_2/.rubocop.yml +8 -0
  66. data/specs_e2e/rails_7_2/Gemfile +11 -0
  67. data/specs_e2e/{rails_4_2 → rails_7_2}/Rakefile +1 -1
  68. data/specs_e2e/rails_7_2/app/assets/stylesheets/application.css +15 -0
  69. data/specs_e2e/rails_7_2/app/controllers/application_controller.rb +4 -0
  70. data/specs_e2e/rails_7_2/app/controllers/posts_controller.rb +58 -0
  71. data/specs_e2e/rails_7_2/app/helpers/posts_helper.rb +2 -0
  72. data/specs_e2e/rails_7_2/app/jobs/application_job.rb +7 -0
  73. data/specs_e2e/rails_7_2/app/models/application_record.rb +3 -0
  74. data/specs_e2e/rails_7_2/app/models/post.rb +2 -0
  75. data/specs_e2e/rails_7_2/app/views/layouts/application.html.erb +22 -0
  76. data/specs_e2e/rails_7_2/app/views/posts/_form.html.erb +32 -0
  77. data/specs_e2e/rails_7_2/app/views/posts/edit.html.erb +6 -0
  78. data/specs_e2e/rails_7_2/app/views/posts/index.html.erb +31 -0
  79. data/specs_e2e/rails_7_2/app/views/posts/new.html.erb +5 -0
  80. data/specs_e2e/rails_7_2/app/views/posts/show.html.erb +19 -0
  81. data/specs_e2e/rails_7_2/bin/brakeman +7 -0
  82. data/specs_e2e/rails_7_2/bin/bundle +109 -0
  83. data/specs_e2e/rails_7_2/bin/importmap +4 -0
  84. data/specs_e2e/rails_7_2/bin/rails +4 -0
  85. data/specs_e2e/rails_7_2/bin/rake +4 -0
  86. data/specs_e2e/rails_7_2/bin/setup +37 -0
  87. data/specs_e2e/rails_7_2/config/application.rb +37 -0
  88. data/specs_e2e/rails_7_2/config/boot.rb +4 -0
  89. data/specs_e2e/rails_7_2/config/cable.yml +10 -0
  90. data/specs_e2e/rails_7_2/config/credentials.yml.enc +1 -0
  91. data/specs_e2e/rails_7_2/config/database.yml +32 -0
  92. data/specs_e2e/{rails_4_2 → rails_7_2}/config/environment.rb +1 -1
  93. data/specs_e2e/rails_7_2/config/environments/development.rb +54 -0
  94. data/specs_e2e/rails_7_2/config/environments/production.rb +105 -0
  95. data/specs_e2e/rails_7_2/config/environments/test.rb +45 -0
  96. data/specs_e2e/rails_7_2/config/importmap.rb +7 -0
  97. data/specs_e2e/rails_7_2/config/initializers/content_security_policy.rb +25 -0
  98. data/specs_e2e/rails_7_2/config/initializers/filter_parameter_logging.rb +8 -0
  99. data/specs_e2e/{rails_5_2 → rails_7_2}/config/initializers/inflections.rb +4 -4
  100. data/specs_e2e/rails_7_2/config/initializers/permissions_policy.rb +13 -0
  101. data/specs_e2e/rails_7_2/config/locales/en.yml +31 -0
  102. data/specs_e2e/rails_7_2/config/master.key +1 -0
  103. data/specs_e2e/rails_7_2/config/puma.rb +34 -0
  104. data/specs_e2e/rails_7_2/config/routes.rb +5 -0
  105. data/specs_e2e/rails_7_2/config/storage.yml +34 -0
  106. data/specs_e2e/{rails_4_2 → rails_7_2}/config.ru +3 -1
  107. data/specs_e2e/rails_7_2/db/migrate/20180621085832_create_posts.rb +11 -0
  108. data/specs_e2e/rails_7_2/db/seeds.rb +9 -0
  109. data/specs_e2e/rails_7_2/db/test.sqlite3-shm +0 -0
  110. data/specs_e2e/rails_7_2/db/test.sqlite3-wal +0 -0
  111. data/specs_e2e/rails_7_2/package.json +8 -0
  112. data/specs_e2e/rails_7_2/playwright-report/index.html +71 -0
  113. data/specs_e2e/{rails_4_2 → rails_7_2}/public/404.html +6 -6
  114. data/specs_e2e/rails_7_2/public/406-unsupported-browser.html +66 -0
  115. data/specs_e2e/{rails_4_2 → rails_7_2}/public/422.html +6 -6
  116. data/specs_e2e/{rails_4_2 → rails_7_2}/public/500.html +6 -6
  117. data/specs_e2e/rails_7_2/public/icon.png +0 -0
  118. data/specs_e2e/rails_7_2/public/icon.svg +3 -0
  119. data/specs_e2e/rails_7_2/public/robots.txt +1 -0
  120. data/specs_e2e/rails_7_2/storage/test.sqlite3 +0 -0
  121. data/specs_e2e/rails_7_2/test/controllers/posts_controller_test.rb +48 -0
  122. data/specs_e2e/rails_7_2/test/cypress_fixtures/posts.yml +11 -0
  123. data/specs_e2e/rails_7_2/test/fixtures/posts.yml +11 -0
  124. data/specs_e2e/rails_7_2/test/models/post_test.rb +7 -0
  125. data/specs_e2e/rails_7_2/test-results/.last-run.json +4 -0
  126. data/specs_e2e/rails_7_2/test.sh +57 -0
  127. data/specs_e2e/rails_8/.gitattributes +9 -0
  128. data/specs_e2e/rails_8/.gitignore +16 -0
  129. data/specs_e2e/rails_8/.rubocop.yml +8 -0
  130. data/specs_e2e/rails_8/Gemfile +20 -0
  131. data/specs_e2e/{rails_3_2 → rails_8}/Rakefile +2 -3
  132. data/specs_e2e/rails_8/app/assets/stylesheets/application.css +10 -0
  133. data/specs_e2e/rails_8/app/controllers/application_controller.rb +4 -0
  134. data/specs_e2e/rails_8/app/controllers/posts_controller.rb +58 -0
  135. data/specs_e2e/rails_8/app/helpers/posts_helper.rb +2 -0
  136. data/specs_e2e/rails_8/app/jobs/application_job.rb +7 -0
  137. data/specs_e2e/rails_8/app/models/application_record.rb +3 -0
  138. data/specs_e2e/rails_8/app/models/post.rb +2 -0
  139. data/specs_e2e/rails_8/app/views/layouts/application.html.erb +27 -0
  140. data/specs_e2e/rails_8/app/views/posts/_form.html.erb +32 -0
  141. data/specs_e2e/rails_8/app/views/posts/edit.html.erb +6 -0
  142. data/specs_e2e/rails_8/app/views/posts/index.html.erb +31 -0
  143. data/specs_e2e/rails_8/app/views/posts/new.html.erb +5 -0
  144. data/specs_e2e/rails_8/app/views/posts/show.html.erb +19 -0
  145. data/specs_e2e/rails_8/bin/brakeman +7 -0
  146. data/specs_e2e/rails_8/bin/bundle +109 -0
  147. data/specs_e2e/rails_8/bin/dev +2 -0
  148. data/specs_e2e/rails_8/bin/importmap +4 -0
  149. data/specs_e2e/rails_8/bin/rails +4 -0
  150. data/specs_e2e/rails_8/bin/rake +4 -0
  151. data/specs_e2e/rails_8/bin/setup +34 -0
  152. data/specs_e2e/rails_8/bin/thrust +5 -0
  153. data/specs_e2e/rails_8/config/application.rb +27 -0
  154. data/specs_e2e/rails_8/config/boot.rb +4 -0
  155. data/specs_e2e/rails_8/config/cable.yml +17 -0
  156. data/specs_e2e/rails_8/config/cache.yml +16 -0
  157. data/specs_e2e/rails_8/config/credentials.yml.enc +1 -0
  158. data/specs_e2e/rails_8/config/database.yml +41 -0
  159. data/specs_e2e/rails_8/config/deploy.yml +116 -0
  160. data/specs_e2e/rails_8/config/environment.rb +5 -0
  161. data/specs_e2e/rails_8/config/environments/development.rb +57 -0
  162. data/specs_e2e/rails_8/config/environments/production.rb +90 -0
  163. data/specs_e2e/rails_8/config/environments/test.rb +45 -0
  164. data/specs_e2e/rails_8/config/importmap.rb +7 -0
  165. data/specs_e2e/rails_8/config/initializers/content_security_policy.rb +25 -0
  166. data/specs_e2e/rails_8/config/initializers/filter_parameter_logging.rb +8 -0
  167. data/specs_e2e/rails_8/config/initializers/inflections.rb +16 -0
  168. data/specs_e2e/rails_8/config/locales/en.yml +31 -0
  169. data/specs_e2e/rails_8/config/master.key +1 -0
  170. data/specs_e2e/rails_8/config/puma.rb +41 -0
  171. data/specs_e2e/rails_8/config/queue.yml +18 -0
  172. data/specs_e2e/rails_8/config/recurring.yml +10 -0
  173. data/specs_e2e/rails_8/config/routes.rb +5 -0
  174. data/specs_e2e/rails_8/config/storage.yml +34 -0
  175. data/specs_e2e/rails_8/config.ru +6 -0
  176. data/specs_e2e/rails_8/db/cable_schema.rb +11 -0
  177. data/specs_e2e/rails_8/db/cache_schema.rb +14 -0
  178. data/specs_e2e/rails_8/db/migrate/20180621085832_create_posts.rb +11 -0
  179. data/specs_e2e/rails_8/db/queue_schema.rb +129 -0
  180. data/specs_e2e/rails_8/db/seeds.rb +9 -0
  181. data/specs_e2e/rails_8/package.json +8 -0
  182. data/specs_e2e/rails_8/playwright-report/index.html +71 -0
  183. data/specs_e2e/rails_8/public/400.html +114 -0
  184. data/specs_e2e/rails_8/public/404.html +114 -0
  185. data/specs_e2e/rails_8/public/406-unsupported-browser.html +114 -0
  186. data/specs_e2e/rails_8/public/422.html +114 -0
  187. data/specs_e2e/rails_8/public/500.html +114 -0
  188. data/specs_e2e/rails_8/public/icon.png +0 -0
  189. data/specs_e2e/rails_8/public/icon.svg +3 -0
  190. data/specs_e2e/rails_8/public/robots.txt +1 -0
  191. data/specs_e2e/rails_8/storage/test.sqlite3 +0 -0
  192. data/specs_e2e/rails_8/storage/test.sqlite3-shm +0 -0
  193. data/specs_e2e/rails_8/storage/test.sqlite3-wal +0 -0
  194. data/specs_e2e/rails_8/test/application_system_test_case.rb +5 -0
  195. data/specs_e2e/rails_8/test/controllers/posts_controller_test.rb +48 -0
  196. data/specs_e2e/rails_8/test/cypress_fixtures/posts.yml +11 -0
  197. data/specs_e2e/rails_8/test/fixtures/posts.yml +11 -0
  198. data/specs_e2e/rails_8/test/models/post_test.rb +7 -0
  199. data/specs_e2e/rails_8/test/test_helper.rb +15 -0
  200. data/specs_e2e/rails_8/test-results/.last-run.json +4 -0
  201. data/specs_e2e/{rails_5_2 → rails_8}/test.sh +17 -8
  202. metadata +221 -153
  203. data/lib/cypress_on_rails/vcr_middleware.rb +0 -73
  204. data/lib/generators/cypress_on_rails/update_generator.rb +0 -24
  205. data/spec/cypress_on_rails/vcr_middleware_spec.rb +0 -119
  206. data/specs_e2e/rails_3_2/.gitignore +0 -9
  207. data/specs_e2e/rails_3_2/.ruby_version +0 -1
  208. data/specs_e2e/rails_3_2/Gemfile +0 -7
  209. data/specs_e2e/rails_3_2/README.rdoc +0 -261
  210. data/specs_e2e/rails_3_2/app/assets/stylesheets/application.css +0 -13
  211. data/specs_e2e/rails_3_2/app/controllers/application_controller.rb +0 -3
  212. data/specs_e2e/rails_3_2/app/controllers/welcome_controller.rb +0 -4
  213. data/specs_e2e/rails_3_2/app/helpers/application_helper.rb +0 -2
  214. data/specs_e2e/rails_3_2/app/models/post.rb +0 -21
  215. data/specs_e2e/rails_3_2/app/views/layouts/application.html.erb +0 -13
  216. data/specs_e2e/rails_3_2/app/views/welcome/index.html.erb +0 -24
  217. data/specs_e2e/rails_3_2/bin/rails +0 -6
  218. data/specs_e2e/rails_3_2/config/application.rb +0 -68
  219. data/specs_e2e/rails_3_2/config/boot.rb +0 -6
  220. data/specs_e2e/rails_3_2/config/environment.rb +0 -5
  221. data/specs_e2e/rails_3_2/config/environments/development.rb +0 -31
  222. data/specs_e2e/rails_3_2/config/environments/production.rb +0 -64
  223. data/specs_e2e/rails_3_2/config/environments/test.rb +0 -35
  224. data/specs_e2e/rails_3_2/config/initializers/backtrace_silencers.rb +0 -7
  225. data/specs_e2e/rails_3_2/config/initializers/inflections.rb +0 -15
  226. data/specs_e2e/rails_3_2/config/initializers/mime_types.rb +0 -5
  227. data/specs_e2e/rails_3_2/config/initializers/secret_token.rb +0 -7
  228. data/specs_e2e/rails_3_2/config/initializers/session_store.rb +0 -8
  229. data/specs_e2e/rails_3_2/config/locales/en.yml +0 -5
  230. data/specs_e2e/rails_3_2/config/routes.rb +0 -60
  231. data/specs_e2e/rails_3_2/config.ru +0 -4
  232. data/specs_e2e/rails_3_2/public/404.html +0 -26
  233. data/specs_e2e/rails_3_2/public/422.html +0 -26
  234. data/specs_e2e/rails_3_2/public/500.html +0 -25
  235. data/specs_e2e/rails_3_2/public/robots.txt +0 -5
  236. data/specs_e2e/rails_3_2/test.sh +0 -43
  237. data/specs_e2e/rails_4_2/.gitignore +0 -11
  238. data/specs_e2e/rails_4_2/Gemfile +0 -11
  239. data/specs_e2e/rails_4_2/README.rdoc +0 -28
  240. data/specs_e2e/rails_4_2/app/assets/javascripts/using_vcr.js +0 -2
  241. data/specs_e2e/rails_4_2/app/assets/stylesheets/using_vcr.css +0 -4
  242. data/specs_e2e/rails_4_2/app/controllers/application_controller.rb +0 -5
  243. data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +0 -10
  244. data/specs_e2e/rails_4_2/app/controllers/welcome_controller.rb +0 -4
  245. data/specs_e2e/rails_4_2/app/models/post.rb +0 -23
  246. data/specs_e2e/rails_4_2/app/views/layouts/application.html.erb +0 -12
  247. data/specs_e2e/rails_4_2/app/views/using_vcr/index.html.erb +0 -6
  248. data/specs_e2e/rails_4_2/app/views/using_vcr/record_cats.html.erb +0 -7
  249. data/specs_e2e/rails_4_2/app/views/welcome/index.html.erb +0 -24
  250. data/specs_e2e/rails_4_2/bin/bundle +0 -3
  251. data/specs_e2e/rails_4_2/bin/rails +0 -4
  252. data/specs_e2e/rails_4_2/bin/rake +0 -4
  253. data/specs_e2e/rails_4_2/bin/setup +0 -29
  254. data/specs_e2e/rails_4_2/config/application.rb +0 -32
  255. data/specs_e2e/rails_4_2/config/boot.rb +0 -3
  256. data/specs_e2e/rails_4_2/config/environments/development.rb +0 -25
  257. data/specs_e2e/rails_4_2/config/environments/production.rb +0 -64
  258. data/specs_e2e/rails_4_2/config/environments/test.rb +0 -42
  259. data/specs_e2e/rails_4_2/config/initializers/backtrace_silencers.rb +0 -7
  260. data/specs_e2e/rails_4_2/config/initializers/cookies_serializer.rb +0 -3
  261. data/specs_e2e/rails_4_2/config/initializers/session_store.rb +0 -3
  262. data/specs_e2e/rails_4_2/config/initializers/to_time_preserves_timezone.rb +0 -10
  263. data/specs_e2e/rails_4_2/config/initializers/wrap_parameters.rb +0 -9
  264. data/specs_e2e/rails_4_2/config/locales/en.yml +0 -23
  265. data/specs_e2e/rails_4_2/config/routes.rb +0 -61
  266. data/specs_e2e/rails_4_2/config/secrets.yml +0 -22
  267. data/specs_e2e/rails_4_2/package.json +0 -10
  268. data/specs_e2e/rails_4_2/public/favicon.ico +0 -0
  269. data/specs_e2e/rails_4_2/public/robots.txt +0 -5
  270. data/specs_e2e/rails_4_2/test.sh +0 -44
  271. data/specs_e2e/rails_5_2/Gemfile +0 -15
  272. data/specs_e2e/rails_5_2/app/assets/javascripts/posts.js +0 -2
  273. data/specs_e2e/rails_5_2/app/assets/stylesheets/posts.css +0 -4
  274. data/specs_e2e/rails_5_2/app/assets/stylesheets/scaffold.css +0 -80
  275. data/specs_e2e/rails_5_2/app/jobs/application_job.rb +0 -2
  276. data/specs_e2e/rails_5_2/app/views/welcome/index.html.erb +0 -5
  277. data/specs_e2e/rails_5_2/bin/bundle +0 -3
  278. data/specs_e2e/rails_5_2/bin/rails +0 -4
  279. data/specs_e2e/rails_5_2/bin/rake +0 -4
  280. data/specs_e2e/rails_5_2/bin/update +0 -25
  281. data/specs_e2e/rails_5_2/config/application.rb +0 -33
  282. data/specs_e2e/rails_5_2/config/boot.rb +0 -4
  283. data/specs_e2e/rails_5_2/config/credentials.yml.enc +0 -1
  284. data/specs_e2e/rails_5_2/config/environments/production.rb +0 -68
  285. data/specs_e2e/rails_5_2/config/initializers/backtrace_silencers.rb +0 -7
  286. data/specs_e2e/rails_5_2/config/initializers/filter_parameter_logging.rb +0 -4
  287. data/specs_e2e/rails_5_2/config/initializers/mime_types.rb +0 -4
  288. data/specs_e2e/rails_5_2/config/initializers/wrap_parameters.rb +0 -9
  289. data/specs_e2e/rails_5_2/config/master.key +0 -1
  290. data/specs_e2e/rails_5_2/public/favicon.ico +0 -0
  291. data/specs_e2e/rails_5_2/public/robots.txt +0 -1
  292. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/controllers/application_controller.rb +0 -0
  293. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/controllers/posts_controller.rb +0 -0
  294. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/helpers/posts_helper.rb +0 -0
  295. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/models/application_record.rb +0 -0
  296. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/models/post.rb +0 -0
  297. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/posts/_form.html.erb +0 -0
  298. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/posts/edit.html.erb +0 -0
  299. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/posts/index.html.erb +0 -0
  300. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/posts/new.html.erb +0 -0
  301. /data/specs_e2e/{rails_5_2 → rails_6_1}/app/views/posts/show.html.erb +0 -0
  302. /data/specs_e2e/{rails_5_2 → rails_6_1}/config/initializers/application_controller_renderer.rb +0 -0
  303. /data/specs_e2e/{rails_5_2 → rails_6_1}/config/initializers/cookies_serializer.rb +0 -0
  304. /data/specs_e2e/{rails_4_2 → rails_6_1}/config/initializers/inflections.rb +0 -0
  305. /data/specs_e2e/{rails_4_2 → rails_6_1}/config/initializers/mime_types.rb +0 -0
  306. /data/specs_e2e/{rails_5_2 → rails_6_1}/config/routes.rb +0 -0
  307. /data/specs_e2e/{rails_5_2 → rails_6_1}/public/404.html +0 -0
  308. /data/specs_e2e/{rails_5_2 → rails_6_1}/public/422.html +0 -0
  309. /data/specs_e2e/{rails_5_2 → rails_6_1}/public/500.html +0 -0
  310. /data/specs_e2e/{rails_5_2 → rails_6_1}/public/apple-touch-icon-precomposed.png +0 -0
  311. /data/specs_e2e/{rails_5_2 → rails_6_1}/public/apple-touch-icon.png +0 -0
  312. /data/specs_e2e/{rails_3_2 → rails_6_1}/public/favicon.ico +0 -0
  313. /data/specs_e2e/{rails_5_2 → rails_6_1}/test/controllers/posts_controller_test.rb +0 -0
  314. /data/specs_e2e/{rails_5_2 → rails_6_1}/test/cypress_fixtures/posts.yml +0 -0
  315. /data/specs_e2e/{rails_5_2 → rails_6_1}/test/fixtures/posts.yml +0 -0
  316. /data/specs_e2e/{rails_5_2 → rails_6_1}/test/models/post_test.rb +0 -0
  317. /data/specs_e2e/{rails_3_2/log → rails_6_1/vendor}/.keep +0 -0
  318. /data/specs_e2e/{rails_3_2/tmp → rails_7_2/vendor}/.keep +0 -0
  319. /data/specs_e2e/{rails_4_2/spec → rails_7_2/vendor/javascript}/.keep +0 -0
  320. /data/specs_e2e/{rails_5_2 → rails_8}/README.md +0 -0
  321. /data/specs_e2e/{rails_4_2/vendor → rails_8/storage}/.keep +0 -0
  322. /data/specs_e2e/{rails_5_2 → rails_8}/vendor/.keep +0 -0
  323. /data/specs_e2e/{rails_3_2/vendor/.gitkeep → rails_8/vendor/javascript/.keep} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dc7073afd439183f15dbe8e33fd275ec4ec4121c2640e026ed5d7f80bc2736c
4
- data.tar.gz: 2361d555bab1bae7072d8909275669a139b9c2ee255f5f8195660189208591fa
3
+ metadata.gz: 7fc65785a8f2d8eb2d7197abd2beac221b90c045f05ec126ee1ab96b2ee80f6c
4
+ data.tar.gz: dff5e1727f058aa6afc16ee9ca2c61c2f72039a9a0e2e00da4c95be38d6fd4a4
5
5
  SHA512:
6
- metadata.gz: 717a48f1352f07b052683ba0699d2806191aed7ebc249e6c0f319af8f2e47d3eb0062787fa6d847ce326afe66325c59859806c9f93f3f95a8276e6aec85d580f
7
- data.tar.gz: abee0f60bec8a8eca395b6a621c33c0caa731452f5e253d27b80c967cd7138a992cb29c68fa41bafcddc85a3f02e6767f6a3f5bcf77ffbaad543264c31d5630a
6
+ metadata.gz: c8cefbd4f704c001587c4a2321d5178a7f49e224039739079406b8666922571204d0bc6cb1f2dba9c7044d8932df5baf7c5c8c128afd349d3614dfa5a959b7ea
7
+ data.tar.gz: 5410e0101bc5bebf3acf5abecf3ee650a6dcb0fb328e700c87f3bd7f72a01b8f9ac47c67c322cf2f28205840f02ba331c2f6b5f7d03c8611d7a35c009e292826
@@ -7,57 +7,57 @@ on:
7
7
  branches: [ master ]
8
8
 
9
9
  jobs:
10
- rails_3_2:
10
+ rails_6_1:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v4
15
15
  - name: Set up Ruby
16
16
  uses: ruby/setup-ruby@v1
17
17
  with:
18
- ruby-version: 2.3
18
+ ruby-version: 2.7.6
19
19
  bundler-cache: true
20
20
  - name: Run tests
21
21
  run: bundle exec rake
22
- - run: gem uninstall -v '>= 2' -ax bundler || true
23
- - run: gem install bundler -v '< 2'
24
22
  - name: Run interaction tests
25
- run: ./specs_e2e/rails_3_2/test.sh
23
+ run: ./specs_e2e/rails_6_1/test.sh
26
24
  env:
27
25
  CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
28
26
 
29
- rails_4_2:
27
+ rails_7_2:
30
28
  runs-on: ubuntu-latest
31
29
 
32
30
  steps:
33
- - uses: actions/checkout@v2
31
+ - uses: actions/checkout@v4
34
32
  - name: Set up Ruby
35
33
  uses: ruby/setup-ruby@v1
36
34
  with:
37
- ruby-version: 2.5
35
+ ruby-version: 3.1.3
38
36
  bundler-cache: true
39
37
  - name: Run tests
40
38
  run: bundle exec rake
41
39
  - run: gem uninstall -v '>= 2' -ax bundler || true
42
40
  - run: gem install bundler -v '< 2'
43
41
  - name: Run interaction tests
44
- run: ./specs_e2e/rails_4_2/test.sh
42
+ run: ./specs_e2e/rails_7_2/test.sh
45
43
  env:
46
44
  CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
47
45
 
48
- rails_5_2:
46
+ rails_8:
49
47
  runs-on: ubuntu-latest
50
48
 
51
49
  steps:
52
- - uses: actions/checkout@v2
50
+ - uses: actions/checkout@v4
53
51
  - name: Set up Ruby
54
52
  uses: ruby/setup-ruby@v1
55
53
  with:
56
- ruby-version: 2.6
54
+ ruby-version: 3.2.2
57
55
  bundler-cache: true
58
56
  - name: Run tests
59
57
  run: bundle exec rake
58
+ - run: gem uninstall -v '>= 2' -ax bundler || true
59
+ - run: gem install bundler -v '< 2'
60
60
  - name: Run interaction tests
61
- run: ./specs_e2e/rails_5_2/test.sh
61
+ run: ./specs_e2e/rails_8/test.sh
62
62
  env:
63
63
  CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
data/.gitignore CHANGED
@@ -9,4 +9,5 @@ vendor/bundle
9
9
  .vscode
10
10
  node_modules
11
11
  package-lock.json
12
- yarn.lock
12
+ yarn.lock
13
+ specs_e2e/server.pid
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [1.17.0]
2
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.16.0...v1.17.0
3
+
4
+ ### Changed
5
+ * Removed the update generator and reduced options for install generator [PR 149](https://github.com/shakacode/cypress-on-rails/pull/149)
6
+
7
+ ### Fixed
8
+ * fix update index.js in install generator [PR 147](https://github.com/shakacode/cypress-on-rails/pull/147) by [Judahmeek]
9
+ * Support rails 7.1 by adding content-type header to generated on-rails.js file [PR 148](https://github.com/shakacode/cypress-on-rails/pull/148) by [anark]
10
+ * Rewind body before reading it [PR 150](https://github.com/shakacode/cypress-on-rails/pull/150)
11
+
1
12
  ## [1.16.0]
2
13
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.15.1...v1.16.0
3
14
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CypressOnRails
1
+ # Cypress and Playwright on Rails
2
2
 
3
3
  ![Build Status](https://github.com/shakacode/cypress-on-rails/actions/workflows/ruby.yml/badge.svg)
4
4
  [![cypress-on-rails](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/2b6cjr/master&style=plastic&logo=cypress)](https://dashboard.cypress.io/projects/2b6cjr/runs)
@@ -6,33 +6,56 @@
6
6
 
7
7
  ----
8
8
 
9
- This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React (with TS or ReScript) front-ends, often with Ruby on Rails or Gatsby. See [our recent work](https://www.shakacode.com/recent-work) and [client engagement model](https://www.shakacode.com/blog/client-engagement-model/). Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
9
+ This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails).
10
10
 
11
- Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
11
+ ### ShakaCode Support
12
12
 
13
- Need help with cypress-on-rails? Contact [ShakaCode](mailto:justin@shakacode.com).
13
+ [ShakaCode](https://www.shakacode.com) focuses on helping Ruby on Rails teams use React and Webpack better. We can upgrade your project and improve your development and customer experiences, allowing you to focus on building new features or fixing bugs instead.
14
+
15
+ For an overview of working with us, see our [Client Engagement Model](https://www.shakacode.com/blog/client-engagement-model/) article and [how we bill for time](https://www.shakacode.com/blog/shortcut-jira-trello-github-toggl-time-and-task-tracking/).
16
+
17
+ We also specialize in helping development teams lower infrastructure and CI costs. Check out our project [Control Plane Flow](https://github.com/shakacode/control-plane-flow/), which can allow you to get the ease of Heroku with the power of Kubernetes and big cost savings.
18
+
19
+ If you think ShakaCode can help your project, [click here](https://meetings.hubspot.com/justingordon/30-minute-consultation) to book a call with [Justin Gordon](mailto:justin@shakacode.com), the creator of React on Rails and Shakapacker.
20
+
21
+ Here's a testimonial of how ShakaCode can help from [Florian Gößler](https://github.com/FGoessler) of [Blinkist](https://www.blinkist.com/), January 2, 2023:
22
+ > Hey Justin 👋
23
+ >
24
+ > I just wanted to let you know that we today shipped the webpacker to shakapacker upgrades and it all seems to be running smoothly! Thanks again for all your support and your teams work! 😍
25
+ >
26
+ > On top of your work, it was now also very easy for me to upgrade Tailwind and include our external node_module based web component library which we were using for our other (more modern) apps already. That work is going to be shipped later this week though as we are polishing the last bits of it. 😉
27
+ >
28
+ > Have a great 2023 and maybe we get to work together again later in the year! 🙌
29
+
30
+ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2118154).
31
+
32
+ ---
33
+
34
+ Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
35
+
36
+ Need help with cypress-on-rails? Contact [Justin Gordon](mailto:justin@shakacode.com).
14
37
 
15
38
  ----
16
39
 
17
- # Totally new to Cypress?
18
- Suggest you first learn the basics of Cypress before attempting to integrate with Ruby on Rails
40
+ # New to Cypress?
41
+ Consider first learning the basics of Cypress before attempting to integrate with Ruby on Rails.
19
42
 
20
43
  * [Good start Here](https://docs.cypress.io/examples/tutorials.html#Best-Practices)
21
44
 
22
45
  # Totally new to Playwright?
23
- Suggest you first learn the basics of Playwright before attempting to integrate with Ruby on Rails
46
+ Consider first learning the basics of Playwright before attempting to integrate with Ruby on Rails.
24
47
 
25
48
  * [Good start Here](https://playwright.dev/docs/writing-tests)
26
49
 
27
50
  ## Overview
28
51
 
29
- Gem for using [cypress.io](http://github.com/cypress-io/) or [playwright.dev](https://playwright.dev/) in Rails and Ruby Rack applications with the goal of controlling state as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State)
52
+ Gem for using [cypress.io](http://github.com/cypress-io/) or [playwright.dev](https://playwright.dev/) in Rails and Ruby Rack applications to control state as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State).
30
53
 
31
- It allows you to run code in the application context when executing cypress or playwright tests.
54
+ It allows you to run code in the context of the application when executing Cypress or Playwright tests.
32
55
  Do things like:
33
56
  * use database_cleaner before each test
34
57
  * seed the database with default data for each test
35
- * use factory_bot to setup data
58
+ * use factory_bot to set up data
36
59
  * create scenario files used for specific tests
37
60
 
38
61
  Has examples of setting up state with:
@@ -61,48 +84,46 @@ Generate the boilerplate code using:
61
84
  # by default installs only cypress
62
85
  bin/rails g cypress_on_rails:install
63
86
 
64
- # if you have/want a different cypress folder (default is cypress)
65
- bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
66
-
67
- # to install both cypress and playwright
68
- bin/rails g cypress_on_rails:install --install_cypress --install_playwright --playwright_folder=playwright
87
+ # if you have/want a different cypress folder (default is e2e)
88
+ bin/rails g cypress_on_rails:install --install_folder=spec/cypress
69
89
 
70
- # to change where the Ruby files reside (default is e2e)
71
- bin/rails g cypress_on_rails:install --install_folder=test/e2e
90
+ # to install playwright instead of cypress
91
+ bin/rails g cypress_on_rails:install --framework playwright
72
92
 
73
93
  # if you target the Rails server with a path prefix to your URL
74
94
  bin/rails g cypress_on_rails:install --api_prefix=/api
75
95
 
76
- # if you want to install cypress with npm
77
- bin/rails g cypress_on_rails:install --install_cypress_with=npm
96
+ # if you want to install with npm instead
97
+ bin/rails g cypress_on_rails:install --install_with=npm
78
98
 
79
99
  # if you already have cypress installed globally
80
- bin/rails g cypress_on_rails:install --no-install-cypress
100
+ bin/rails g cypress_on_rails:install --install_with=skip
81
101
 
82
102
  # to update the generated files run
83
- bin/rails g cypress_on_rails:update
103
+ bin/rails g cypress_on_rails:install --install_with=skip
84
104
  ```
85
105
 
86
106
  The generator modifies/adds the following files/directory in your application:
87
107
  * `config/initializers/cypress_on_rails.rb` used to configure Cypress on Rails
88
- * `spec/cypress/e2e/` contains your cypress tests
89
- * `spec/playwright/e2e/` contains your playwright tests
90
- * `spec/cypress/support/on-rails.js` contains Cypress on Rails support code
91
- * `spec/playwright/support/on-rails.js` contains Playwright on Rails support code
92
- * `spec/e2e/app_commands/scenarios/` contains your Cypress on Rails scenario definitions
93
- * `spec/e2e/cypress_helper.rb` contains helper code for Cypress on Rails app commands
108
+ * `e2e/cypress/integration/` contains your cypress tests
109
+ * `e2e/cypress/support/on-rails.js` contains Cypress on Rails support code
110
+ * `e2e/cypress/e2e_helper.rb` contains helper code to require libraries like factory_bot
111
+ * `e2e/cypress/app_commands/` contains your scenario definitions
112
+ * `e2e/playwright/e2e/` contains your playwright tests
113
+ * `e2e/playwright/support/on-rails.js` contains Playwright on Rails support code
94
114
 
95
- If you are not using `database_cleaner` look at `spec/e2e/app_commands/clean.rb`.
96
- If you are not using `factory_bot` look at `spec/e2e/app_commands/factory_bot.rb`.
115
+ If you are not using `database_cleaner` look at `e2e/cypress/app_commands/clean.rb`.
116
+ If you are not using `factory_bot` look at `e2e/cypress/app_commands/factory_bot.rb`.
97
117
 
98
118
  Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit.
99
119
 
100
120
  ### Update your database.yml
101
121
 
102
- When running `cypress test` or `playwright test` on your local computer it's recommended to start your server in development mode so that changes you
103
- make are picked up without having to restart the server.
122
+ When writing and running tests on your local computer, it's recommended to start your server in development mode so that changes you
123
+ make are picked up without having to restart your local server.
124
+
104
125
  It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database
105
- otherwise cypress will keep clearing your development database.
126
+ otherwise, cypress will keep clearing your development database.
106
127
 
107
128
  For example:
108
129
  ```yaml
@@ -127,11 +148,9 @@ Getting started on your local environment
127
148
  CYPRESS=1 bin/rails server -p 5017
128
149
 
129
150
  # in separate window start cypress
130
- yarn cypress open
151
+ yarn cypress open --project ./e2e
131
152
  # or for npm
132
- node_modules/.bin/cypress open
133
- # or if you changed the cypress folder to spec/cypress
134
- yarn cypress open --project ./spec
153
+ npx cypress open --project ./e2e
135
154
  # or for playwright
136
155
  yarn playwright test --ui
137
156
  # or using npm
@@ -144,15 +163,16 @@ How to run cypress on CI
144
163
  # setup rails and start server in background
145
164
  # ...
146
165
 
147
- yarn run cypress run
166
+ yarn run cypress run --project ./e2e
148
167
  # or for npm
149
- npx cypress run
168
+ npx cypress run --project ./e2e
150
169
  ```
151
170
 
152
171
  ### Example of using factory bot
153
172
 
154
173
  You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
155
174
 
175
+ then in Cypress
156
176
  ```js
157
177
  // spec/cypress/e2e/simple.cy.js
158
178
  describe('My First Test', () => {
@@ -176,6 +196,32 @@ describe('My First Test', () => {
176
196
  })
177
197
  })
178
198
  ```
199
+
200
+ then in Playwright
201
+ ```js
202
+ const { test, expect, request } = require('@playwright/test');
203
+
204
+ test.describe('My First Test', () => {
205
+ test('visit root', async ({ page }) => {
206
+ // This calls to the backend to prepare the application state
207
+ await appFactories([
208
+ ['create_list', 'post', 10],
209
+ ['create', 'post', { title: 'Hello World' }],
210
+ ['create', 'post', 'with_comments', { title: 'Factory_bot Traits here' }]
211
+ ]);
212
+
213
+ // Visit the application under test
214
+ await page.goto('/');
215
+
216
+ await expect(page).toHaveText('Hello World');
217
+
218
+ // Accessing result
219
+ const records = await appFactories([['create', 'invoice', { paid: false }]]);
220
+ await page.goto(`/invoices/${records[0].id}`);
221
+ });
222
+ });
223
+ ```
224
+
179
225
  You can check the [association docs](docs/factory_bot_associations.md) on more ways to setup association with the correct data.
180
226
 
181
227
  In some cases, using static Cypress fixtures may not provide sufficient flexibility when mocking HTTP response bodies. It's possible to use `FactoryBot.build` to generate Ruby hashes that can then be used as mock JSON responses:
@@ -336,16 +382,21 @@ yarn add cypress-on-rails --dev
336
382
  ### for VCR
337
383
 
338
384
  This only works when you start the Rails server with a single worker and single thread
385
+ It can be used in two modes:
386
+ - with separate insert/eject calls (more general, recommended way)
387
+ - with use_cassette wrapper (supports only GraphQL integration)
339
388
 
340
- #### setup
389
+ #### basic setup
341
390
 
342
- Add your VCR configuration to your `cypress_helper.rb`
391
+ Add your VCR configuration to your `config/cypress_on_rails.rb`
343
392
 
344
393
  ```ruby
345
- require 'vcr'
346
- VCR.configure do |config|
347
- config.hook_into :webmock
348
- end
394
+ c.vcr_options = {
395
+ hook_into: :webmock,
396
+ default_cassette_options: { record: :once },
397
+ # It's possible to override cassette_library_dir using install_folder
398
+ cassette_library_dir: File.expand_path("#{__dir__}/../../spec/cypress/fixtures/vcr_cassettes")
399
+ }
349
400
  ```
350
401
 
351
402
  Add to your `cypress/support/index.js`:
@@ -362,13 +413,16 @@ VCR.turn_off!
362
413
  WebMock.disable! if defined?(WebMock)
363
414
  ```
364
415
 
416
+ #### insert/eject setup
417
+
365
418
  Add to your `config/cypress_on_rails.rb`:
366
419
 
367
420
  ```ruby
368
421
  c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
422
+ # c.use_vcr_use_cassette_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
369
423
  ```
370
424
 
371
- #### usage
425
+ #### insert/eject usage
372
426
 
373
427
  You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette
374
428
 
@@ -395,6 +449,63 @@ describe('My First Test', () => {
395
449
  })
396
450
  ```
397
451
 
452
+ #### use_cassette setup
453
+
454
+ Add to your `config/cypress_on_rails.rb`:
455
+
456
+ ```ruby
457
+ # c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
458
+ c.use_vcr_use_cassette_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
459
+ ```
460
+
461
+ Adjust record mode in `config/cypress_on_rails.rb` if needed:
462
+
463
+ ```ruby
464
+ c.vcr_options = {
465
+ hook_into: :webmock,
466
+ default_cassette_options: { record: :once },
467
+ }
468
+ ```
469
+
470
+ Add to your `cypress/support/command.js`:
471
+
472
+ ```js
473
+ // Add proxy-like mock to add operation name into query string
474
+ Cypress.Commands.add('mockGraphQL', () => {
475
+ cy.on('window:before:load', (win) => {
476
+ const originalFetch = win.fetch;
477
+ const fetch = (path, options, ...rest) => {
478
+ if (options && options.body) {
479
+ try {
480
+ const body = JSON.parse(options.body);
481
+ if (body.operationName) {
482
+ return originalFetch(`${path}?operation=${body.operationName}`, options, ...rest);
483
+ }
484
+ } catch (e) {
485
+ return originalFetch(path, options, ...rest);
486
+ }
487
+ }
488
+ return originalFetch(path, options, ...rest);
489
+ };
490
+ cy.stub(win, 'fetch', fetch);
491
+ });
492
+ });
493
+ ```
494
+
495
+ Add to your `cypress/support/on-rails.js`, to `beforeEach`:
496
+
497
+ ```js
498
+ cy.mockGraphQL() // for GraphQL usage with use_cassette, see cypress/support/commands.rb
499
+ ```
500
+
501
+ #### use_cassette usage
502
+
503
+ There is nothing special to be called during the Cypress scenario. Each request is wrapped with `VCR.use_cassette`.
504
+ Consider VCR configuration in `cypress_helper.rb` to ignore hosts.
505
+
506
+ All cassettes will be recorded and saved automatically, using the pattern `<vcs_cassettes_path>/graphql/<operation_name>`
507
+
508
+
398
509
  ## `before_request` configuration
399
510
 
400
511
  You may perform any custom action before running a CypressOnRails command, such as authentication, or sending metrics. Please set `before_request` as part of the CypressOnRails configuration.
@@ -463,6 +574,9 @@ Cypress.Commands.add('appCommands', (body) => {
463
574
  method: 'POST',
464
575
  url: '/__cypress__/command',
465
576
  body: JSON.stringify(body),
577
+ headers: {
578
+ 'Content-Type': 'application/json; charset=utf-8',
579
+ },
466
580
  log: true,
467
581
  failOnStatusCode: true
468
582
  })
@@ -487,6 +601,46 @@ beforeEach(() => {
487
601
  });
488
602
  ```
489
603
 
604
+ add the following file to Playwright
605
+ ```js
606
+ // test/playwright/support/on-rails.js
607
+ async function appCommands(body) {
608
+ const context = await request.newContext();
609
+ const response = await context.post('/__e2e__/command', {
610
+ data: body,
611
+ headers: {
612
+ 'Content-Type': 'application/json'
613
+ }
614
+ });
615
+
616
+ if (response.status() !== 201) {
617
+ const responseBody = await response.text();
618
+ throw new Error(`Expected status 201 but got ${response.status()} - ${responseBody}`);
619
+ }
620
+
621
+ return response.json();
622
+ }
623
+
624
+ async function app(name, commandOptions = {}) {
625
+ const body = await appCommands({ name, options: commandOptions });
626
+ return body[0];
627
+ }
628
+
629
+ async function appScenario(name, options = {}) {
630
+ const body = { name: `scenarios/${name}`, options };
631
+ const result = await appCommands(body);
632
+ return result[0];
633
+ }
634
+
635
+ async function appFactories(options) {
636
+ return app('factory_bot', options);
637
+ }
638
+
639
+ async function clean() {
640
+ await app('clean');
641
+ }
642
+ ```
643
+
490
644
  ## API Prefix
491
645
 
492
646
  If your Rails server is exposed under a proxy, typically https://my-local.dev/api, you can use the `api_prefix` option.
@@ -508,8 +662,8 @@ In `config/initializers/cypress_on_rails.rb`, add this line:
508
662
 
509
663
  ## Supporters
510
664
 
511
- <a href="https://www.jetbrains.com">
512
- <img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
665
+ <a href="https://jb.gg/OpenSource" style="margin-right: 20px;">
666
+ <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains" height="120px">
513
667
  </a>
514
668
  <a href="https://scoutapp.com">
515
669
  <picture>
@@ -518,7 +672,7 @@ In `config/initializers/cypress_on_rails.rb`, add this line:
518
672
  <img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
519
673
  </picture>
520
674
  </a>
521
- <a href="https://controlplane.com">
675
+ <a href="https://shakacode.controlplane.com">
522
676
  <picture>
523
677
  <img alt="Control Plane" src="https://github.com/shakacode/.github/assets/20628911/90babd87-62c4-4de3-baa4-3d78ef4bec25" height="120px">
524
678
  </picture>
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'rake'
20
20
  s.add_development_dependency 'rspec'
21
21
  s.add_development_dependency 'railties', '>= 3.2'
22
- s.add_development_dependency 'factory_bot'
22
+ s.add_development_dependency 'factory_bot', '!= 6.4.5'
23
23
  s.add_development_dependency 'vcr'
24
24
  s.metadata = {
25
25
  "bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
@@ -51,3 +51,33 @@ cy.forceLogin()
51
51
  cy.forceLogin({redirect_to: '/profile'})
52
52
  cy.forceLogin({email: 'someuser@mail.com'})
53
53
  ```
54
+
55
+ In `playwright/support/on-rails.js`:
56
+
57
+ ```js
58
+ async function forceLogin(page, { email, redirect_to = '/' }) {
59
+ // Validate inputs
60
+ if (typeof email !== 'string' || typeof redirect_to !== 'string') {
61
+ throw new Error('Invalid input: email and redirect_to must be non-empty strings');
62
+ }
63
+
64
+ const response = await page.request.post('/__e2e__/force_login', {
65
+ data: { email: email, redirect_to: redirect_to },
66
+ headers: { 'Content-Type': 'application/json' }
67
+ });
68
+
69
+ // Handle response based on status code
70
+ if (response.ok()) {
71
+ await page.goto(redirect_to);
72
+ } else {
73
+ // Throw an exception for specific error statuses
74
+ throw new Error(`Login failed with status: ${response.status()}`);
75
+ }
76
+ }
77
+ ```
78
+
79
+ Examples of usage in Playwright specs:
80
+ ```js
81
+ await forceLogin(page, { email: 'someuser@mail.com', redirect_to: '/profile' });
82
+
83
+ ```
@@ -54,6 +54,15 @@ cy.appFactories([['create', 'author']]).then((records) => {
54
54
  })
55
55
  ```
56
56
 
57
+ then in Playwright
58
+ There are a few ways you can set up associations with the correct data using Playwright and FactoryBot.
59
+ ```js
60
+ const records = await appFactories([['create', 'author', { name: 'James' }]], context);
61
+ await appFactories([['create', 'post', { title: 'Playwright is cool', author_id: records[0].id }]], context);
62
+ // Note: These Playwright examples demonstrate asynchronous interactions with the server for setting up data associations. Ensure that your environment is configured to handle these async operations.
63
+ ```
64
+
65
+
57
66
  ## 2. Using transient attributes
58
67
 
59
68
  ```rb
@@ -81,6 +90,11 @@ cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_name: 'Ja
81
90
  cy.appFactories([['create', 'post']])
82
91
  ```
83
92
 
93
+ then in Playwright
94
+ ```js
95
+ const records = await appFactories([['create', 'post', { title: 'Playwright is cool', author_name: 'James' }]]);
96
+ ```
97
+
84
98
  ## 3. Using Nested Attributes
85
99
 
86
100
  ```rb
@@ -6,8 +6,10 @@ module CypressOnRails
6
6
  attr_accessor :install_folder
7
7
  attr_accessor :use_middleware
8
8
  attr_accessor :use_vcr_middleware
9
+ attr_accessor :use_vcr_use_cassette_middleware
9
10
  attr_accessor :before_request
10
11
  attr_accessor :logger
12
+ attr_accessor :vcr_options
11
13
 
12
14
  # Attributes for backwards compatibility
13
15
  def cypress_folder
@@ -25,14 +27,17 @@ module CypressOnRails
25
27
 
26
28
  alias :use_middleware? :use_middleware
27
29
  alias :use_vcr_middleware? :use_vcr_middleware
30
+ alias :use_vcr_use_cassette_middleware? :use_vcr_use_cassette_middleware
28
31
 
29
32
  def reset
30
33
  self.api_prefix = ''
31
34
  self.install_folder = 'spec/e2e'
32
35
  self.use_middleware = true
33
36
  self.use_vcr_middleware = false
37
+ self.use_vcr_use_cassette_middleware = false
34
38
  self.before_request = -> (request) {}
35
39
  self.logger = Logger.new(STDOUT)
40
+ self.vcr_options = {}
36
41
  end
37
42
 
38
43
  def tagged_logged
@@ -51,6 +51,7 @@ module CypressOnRails
51
51
  # Halt the middleware if an Rack Env was returned by `before_request`
52
52
  return maybe_env unless maybe_env.nil?
53
53
 
54
+ req.body.rewind
54
55
  body = JSON.parse(req.body.read)
55
56
  logger.info "handle_command: #{body}"
56
57
  commands = Command.from_body(body, configuration)
@@ -9,8 +9,16 @@ module CypressOnRails
9
9
  app.middleware.use Middleware
10
10
  end
11
11
  if CypressOnRails.configuration.use_vcr_middleware?
12
- require 'cypress_on_rails/vcr_middleware'
13
- app.middleware.use VCRMiddleware
12
+ require 'cypress_on_rails/vcr/insert_eject_middleware'
13
+ app.middleware.use Vcr::InsertEjectMiddleware
14
+ end
15
+ if CypressOnRails.configuration.use_vcr_use_cassette_middleware?
16
+ if CypressOnRails.configuration.use_vcr_middleware?
17
+ raise 'Configure only one VCR middleware at a time: use_vcr_middleware OR use_vcr_use_cassette_middleware'
18
+ end
19
+
20
+ require 'cypress_on_rails/vcr/use_cassette_middleware'
21
+ app.middleware.use Vcr::UseCassetteMiddleware
14
22
  end
15
23
  end
16
24
  end
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/string'
2
-
3
1
  module CypressOnRails
4
2
  module SimpleRailsFactory
5
3
  def self.create(type, *params)