Run jasmine specs using chrome headless

This commit is contained in:
Jonne Haß 2021-04-10 14:09:59 +02:00
parent 79133df4a9
commit cd6eb3de7f
5 changed files with 48 additions and 62 deletions

View file

@ -304,6 +304,7 @@ group :development, :test do
gem "cucumber-rails", "2.0.0", require: false gem "cucumber-rails", "2.0.0", require: false
# Jasmine (client side application tests (JS)) # Jasmine (client side application tests (JS))
gem "chrome_remote", "0.3.0"
gem "jasmine", "3.6.0" gem "jasmine", "3.6.0"
gem "jasmine-jquery-rails", "2.0.3" gem "jasmine-jquery-rails", "2.0.3"
gem "rails-assets-jasmine-ajax", "4.0.0", source: "https://gems.diasporafoundation.org" gem "rails-assets-jasmine-ajax", "4.0.0", source: "https://gems.diasporafoundation.org"

View file

@ -112,6 +112,8 @@ GEM
timers (>= 4.1.1) timers (>= 4.1.1)
celluloid-supervision (0.20.6) celluloid-supervision (0.20.6)
timers (>= 4.1.1) timers (>= 4.1.1)
chrome_remote (0.3.0)
websocket-driver (~> 0.6)
chunky_png (1.3.11) chunky_png (1.3.11)
citrus (3.0.2) citrus (3.0.2)
cliver (0.3.2) cliver (0.3.2)
@ -232,7 +234,7 @@ GEM
http-cookie (~> 1.0.0) http-cookie (~> 1.0.0)
faraday_middleware (0.13.1) faraday_middleware (0.13.1)
faraday (>= 0.7.4, < 1.0) faraday (>= 0.7.4, < 1.0)
ffi (1.12.2) ffi (1.15.0)
ffi-compiler (1.0.1) ffi-compiler (1.0.1)
ffi (>= 1.0.0) ffi (>= 1.0.0)
rake rake
@ -319,7 +321,7 @@ GEM
http-cookie (1.0.3) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
http-form_data (2.3.0) http-form_data (2.3.0)
http-parser (1.2.1) http-parser (1.2.3)
ffi-compiler (>= 1.0, < 2.0) ffi-compiler (>= 1.0, < 2.0)
http_accept_language (2.1.1) http_accept_language (2.1.1)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
@ -666,7 +668,7 @@ GEM
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
sassc (2.2.1) sassc (2.4.0)
ffi (~> 1.9) ffi (~> 1.9)
sawyer (0.8.2) sawyer (0.8.2)
addressable (>= 2.3.5) addressable (>= 2.3.5)
@ -797,6 +799,7 @@ DEPENDENCIES
bootstrap-switch-rails (= 3.3.3) bootstrap-switch-rails (= 3.3.3)
capybara (= 3.15.0) capybara (= 3.15.0)
carrierwave (= 1.3.1) carrierwave (= 1.3.1)
chrome_remote (= 0.3.0)
compass-rails (= 3.1.0) compass-rails (= 3.1.0)
configurate (= 0.5.0) configurate (= 0.5.0)
cucumber-api-steps (= 0.14) cucumber-api-steps (= 0.14)

View file

@ -37,8 +37,6 @@ describe("app.views.Content", function(){
}); });
}); });
// These tests don't work in PhantomJS because it doesn't support HTML5 <video>.
if (/PhantomJS/.exec(navigator.userAgent) === null) {
describe("onVideoThumbClick", function() { describe("onVideoThumbClick", function() {
beforeEach(function() { beforeEach(function() {
this.post = new app.models.StatusMessage({text: "[title](https://www.w3schools.com/html/mov_bbb.mp4)"}); this.post = new app.models.StatusMessage({text: "[title](https://www.w3schools.com/html/mov_bbb.mp4)"});
@ -51,13 +49,13 @@ describe("app.views.Content", function(){
this.view.$("video").stop(); this.view.$("video").stop();
}); });
it("hides video overlay", function() { xit("hides video overlay", function() {
expect(this.view.$(".video-overlay").length).toBe(1); expect(this.view.$(".video-overlay").length).toBe(1);
this.view.$(".media-embed .thumb").click(); this.view.$(".media-embed .thumb").click();
expect(this.view.$(".video-overlay")).toHaveClass("hidden"); expect(this.view.$(".video-overlay")).toHaveClass("hidden");
}); });
it("expands posts on click", function() { xit("expands posts on click", function() {
this.view.$(".collapsible").height(500); this.view.$(".collapsible").height(500);
this.view.collapseOversized(); this.view.collapseOversized();
@ -66,7 +64,7 @@ describe("app.views.Content", function(){
expect(this.view.$(".opened").length).toBe(1); expect(this.view.$(".opened").length).toBe(1);
}); });
it("plays video", function(done) { xit("plays video", function(done) {
this.view.$("video").on("playing", function() { this.view.$("video").on("playing", function() {
done(); done();
}); });
@ -74,5 +72,4 @@ describe("app.views.Content", function(){
this.view.$(".media-embed .thumb").click(); this.view.$(".media-embed .thumb").click();
}); });
}); });
}
}); });

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
Jasmine.configure do |config|
config.prevent_phantom_js_auto_install = true
config.runner_browser = :chromeheadless
config.chrome_startup_timeout = 20
config.chrome_cli_options["autoplay-policy"] = "no-user-gesture-required"
end

View file

@ -1,23 +0,0 @@
# frozen_string_literal: true
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
ENV["JASMINE_BROWSER"] = "firefox"
require 'rubygems'
require 'json'
require 'jasmine'
require 'rspec'
jasmine_config = Jasmine::Config.new
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
should_stop = false
RSpec.configuration.after(:suite) do
spec_builder.stop if should_stop
end
spec_builder.start
should_stop = true
spec_builder.declare_suites