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
@jrafanie jrafanie changed the title [WIP] Cypress on rails [WIP] Add cypress-on-rails support Sep 29, 2025
@jrafanie
Copy link
Member Author

jrafanie commented Oct 1, 2025

@miq-bot cross_repo_test including ManageIQ/manageiq-ui-classic#9633

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Oct 1, 2025
@jrafanie jrafanie mentioned this pull request Oct 8, 2025
1 task
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.19.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"
+
```
These are UI dependencies that will be required in the UI Classic engine.rb
@jrafanie jrafanie changed the title [WIP] Add cypress-on-rails support Add cypress-on-rails support Oct 9, 2025
@jrafanie
Copy link
Member Author

jrafanie commented Oct 9, 2025

@Fryguy This one is ready to go. I'd like to kick ManageIQ/manageiq-ui-classic#9633 so the cypress tests can run on CI there with this merged. I ran them locally but want to make sure I'm not breaking anything.

@Fryguy Fryguy merged commit 7a81b41 into ManageIQ:master Oct 9, 2025
9 checks passed
@Fryguy Fryguy self-assigned this Oct 9, 2025
@jrafanie jrafanie deleted the cypress-on-rails branch October 9, 2025 21:14
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