Skip to content

Commit

Permalink
Stabilize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemanrubia committed Dec 14, 2024
1 parent 273de45 commit 8bcd5d8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/hotwire_spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -3656,6 +3656,9 @@ var HotwireSpark = (function () {
consumer.subscriptions.create({
channel: "HotwireSpark::Channel"
}, {
connected() {
document.body.setAttribute("data-hotwire-spark-ready", "");
},
received(data) {
this.dispatchMessage(data);
},
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions app/javascript/hotwire_spark/channels/monitoring_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { CssReloader } from "../reloaders/css_reloader.js";
import { StimulusReloader } from "../reloaders/stimulus_reloader.js";

consumer.subscriptions.create({ channel: "HotwireSpark::Channel" }, {
connected() {
document.body.setAttribute("data-hotwire-spark-ready", "")
},

received(data) {
this.dispatchMessage(data)
},
Expand Down
6 changes: 6 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :cuprite, screen_size: [ 1440, 900 ], options: { headless: "new" }

include HotwireSpark::Engine.routes.url_helpers

def visit(...)
super.tap do
wait_for_hotwire_spark
end
end
end

Capybara.server = :puma, { Silent: true }
6 changes: 6 additions & 0 deletions test/errors_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "application_system_test_case"

class ErrorsTest < ApplicationSystemTestCase
test "" do
end
end
1 change: 1 addition & 0 deletions test/stimulus_reload_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StimulusReloadTest < ApplicationSystemTestCase
assert_no_text "This was replaced!"

edit_file "app/views/home/show.html.erb", replace: "_REPLACE_CONTROLLER_", with: "other-dummy"
sleep 2 # Broadcasting many jobs in a row sometimes makes the test fail

add_file "app/javascript/controllers/other_dummy_controller.js", <<~JS
import { Controller } from "@hotwired/stimulus"
Expand Down
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ class ActiveSupport::TestCase
def reload_rails_reloader
Rails.application.reloader.reload!
end

def wait_for_hotwire_spark
assert_css "[data-hotwire-spark-ready]"
end
end

0 comments on commit 8bcd5d8

Please sign in to comment.