Skip to content

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Sep 26, 2025

Enables: ManageIQ/manageiq-ui-classic#9633 to use cypress on rails

We add this to core so the railtie in cypress-on-rails can hook into the rails
app startup as needed:
https://github.com/shakacode/cypress-playwright-on-rails/blob/d50de890b345879205124fa4de52bf899d9df2d0/lib/cypress_on_rails/railtie.rb#L6

Note, this could be pushed down to UI Classic, see below, but this has a few
problems:

  1. Core already has bundler groups for development and test that these nicely
    fit into. This allows us to easily exclude them from different installation
    scenarios such as smaller deployments with just the required runtime
    dependencies.

  2. UI-Classic is a gem engine that gets pulled in, so only the runtime
    dependencies are resolved and available. Therefore, we would need to add these
    test gems as runtime dependencies which sends the wrong message and makes it
    difficult to exclude.

Alternative setup (not suggested):

a) Remove it from core:

index https://github.com/jrafanie/manageiq/commit/cd4501593716391e5412903b8f0bdbf6f3b87d7c..https://github.com/jrafanie/manageiq/commit/b62ae61bb07e6cb4f0f74f57b0032b5f45ef6256 100644
--- a/Gemfile
+++ b/Gemfile
@@ -326,7 +326,4 @@ group :development, :test do
   gem "parallel_tests",                 "~>4.4", :require => false
   gem "routes_lazy_routes"
   gem "rspec-rails",                    "~>7.0"
-  gem "cypress-on-rails",               "~>1.17.0" # Need railtie to be loaded with rails app
-  gem "factory_bot_rails"
-  gem "database_cleaner",               "~>2.1"
 end

b) Require it in UI-Classic's Engine and add the gems to the gemspec:

index dc72a001ec..cf420620c1 100644
--- a/lib/manageiq/ui/classic/engine.rb
+++ b/lib/manageiq/ui/classic/engine.rb
@@ -36,6 +36,8 @@ module ManageIQ
           config.assets.js_compressor = :manageiq_ui_classic_js_compressor
         end
Enables: https://github.com/ManageIQ/manageiq-ui-classic/pull/9633


+        require 'cypress-on-rails' if ENV['CYPRESS'].present?
+
         def self.vmdb_plugin?
           true
         end
diff --git a/manageiq-ui-classic.gemspec b/manageiq-ui-classic.gemspec
index cef587a45a..3ed378abed 100644
--- a/manageiq-ui-classic.gemspec
+++ b/manageiq-ui-classic.gemspec
@@ -31,7 +31,10 @@ Gem::Specification.new do |s|
   s.add_dependency "uglifier", "~>4.2.0"
   s.add_dependency "webpacker", "~>2.0.0"

-  s.add_development_dependency "cypress-on-rails", "~> 1.0"
+  s.add_dependency "cypress-on-rails", "~>1.17.0"
+  s.add_dependency "factory_bot_rails"
+  s.add_dependency "database_cleaner", "~>2.1"
+

@jrafanie jrafanie requested a review from Fryguy as a code owner September 26, 2025 20:08
@jrafanie jrafanie added the test label Sep 26, 2025
@jrafanie jrafanie changed the title Cypress on rails [WIP] Cypress on rails Sep 26, 2025
Gemfile Outdated
gem "parallel_tests", "~>4.4", :require => false
gem "routes_lazy_routes"
gem "rspec-rails", "~>7.0"
gem "cypress-on-rails", "~>1.17.0" # Need railtie to be loaded with rails app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor but add a gap before this or rubocop is going to complain about sort order.

Suggested change
gem "cypress-on-rails", "~>1.17.0" # Need railtie to be loaded with rails app
gem "cypress-on-rails", "~>1.17.0" # Need railtie to be loaded with rails app

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that note, the next 3 need to be in sort order 😆

Enables: ManageIQ/manageiq-ui-classic#9633

We add this to core so the railtie in cypress-on-rails can hook into the rails
app startup as needed:
https://github.com/shakacode/cypress-playwright-on-rails/blob/d50de890b345879205124fa4de52bf899d9df2d0/lib/cypress_on_rails/railtie.rb#L6

Note, this could be pushed down to UI Classic, see below, but this has a few
problems:

1) Core already has bundler groups for development and test that these nicely
fit into.  This allows us to easily exclude them from different installation
scenarios such as smaller deployments with just the required runtime
dependencies.

2) UI-Classic is a gem engine that gets pulled in, so only the runtime
dependencies are resolved and available.  Therefore, we would need to add these
test gems as runtime dependencies which sends the wrong message and makes it
difficult to exclude.

Alternative setup (not suggested):

a) Remove it from core:

```diff --git a/Gemfile b/Gemfile
index cd45015..b62ae61 100644
--- a/Gemfile
+++ b/Gemfile
@@ -326,7 +326,4 @@ group :development, :test do
   gem "parallel_tests",                 "~>4.4", :require => false
   gem "routes_lazy_routes"
   gem "rspec-rails",                    "~>7.0"
-  gem "cypress-on-rails",               "~>1.17.0" # Need railtie to be loaded with rails app
-  gem "factory_bot_rails"
-  gem "database_cleaner",               "~>2.1"
 end
```

b) Require it in UI-Classic's Engine and add the gems to the gemspec:

```diff --git a/lib/manageiq/ui/classic/engine.rb b/lib/manageiq/ui/classic/engine.rb
index dc72a001ec..cf420620c1 100644
--- a/lib/manageiq/ui/classic/engine.rb
+++ b/lib/manageiq/ui/classic/engine.rb
@@ -36,6 +36,8 @@ module ManageIQ
           config.assets.js_compressor = :manageiq_ui_classic_js_compressor
         end

+        require 'cypress-on-rails' if ENV['CYPRESS'].present?
+
         def self.vmdb_plugin?
           true
         end
diff --git a/manageiq-ui-classic.gemspec b/manageiq-ui-classic.gemspec
index cef587a45a..3ed378abed 100644
--- a/manageiq-ui-classic.gemspec
+++ b/manageiq-ui-classic.gemspec
@@ -31,7 +31,10 @@ Gem::Specification.new do |s|
   s.add_dependency "uglifier", "~>4.2.0"
   s.add_dependency "webpacker", "~>2.0.0"

-  s.add_development_dependency "cypress-on-rails", "~> 1.0"
+  s.add_dependency "cypress-on-rails", "~>1.17.0"
+  s.add_dependency "factory_bot_rails"
+  s.add_dependency "database_cleaner", "~>2.1"
+
```
@jrafanie jrafanie changed the title [WIP] Cypress on rails [WIP] Add cypress-on-rails support Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants