forked from nanego/my-dcim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Rooms::BrowseRoom", :js do | ||
let(:room) { rooms(:one) } | ||
|
||
# The 2nd bay created an empty "couple div" in rooms #Show view, causing the test to fail. | ||
before do | ||
room.islets.first.bays.last.destroy! | ||
end | ||
|
||
it("browse a room, islets and bays, change view and background color") do # rubocop:disable RSpec/MultipleExpectations | ||
sign_in(users(:one)) | ||
|
||
visit room_path(room) | ||
expect(page).to have_current_path(room_path(room)) | ||
|
||
frame = room.frames.first | ||
|
||
# 1. Select a frame | ||
overview_frame = find("div[data-frame-id=#{frame.slug}]") | ||
overview_frame.click | ||
|
||
# Waits for the overview to fully load | ||
find("div##{room.name.downcase}") | ||
|
||
frame.servers.each do |server| | ||
expect(page).to have_content(server.name) | ||
end | ||
|
||
# 2. Change view to 'back' | ||
switch_view_btn = find("span.pull-right > a.btn.btn-success") | ||
switch_view_btn.click | ||
|
||
# Since the overview container is already loaded, we cannot use find() to wait for loading | ||
sleep 1 | ||
|
||
# On the back view, we should see some server cards (only the 2nd server has cards) | ||
frame.servers.second.cards.pluck(:name).each do |card_name| | ||
expect(page).to have_content(card_name) | ||
end | ||
|
||
# Modele background color | ||
overview_frame_title = find("div.title > a[data-frame-id=#{frame.slug}]") | ||
overview_frame_title.click | ||
|
||
sleep 1 | ||
|
||
# For background color set to 'modele', we check for a cyan/white background-color | ||
colored_lines = all("ul.servers > li.server.mystring") | ||
|
||
colored_lines.each do |line| | ||
expect(line.style("background-color")["background-color"]).to eq("rgb(183, 247, 255)").or eq("rgb(255, 255, 255)") | ||
end | ||
|
||
# 3. Change background color to 'gestionnaire' | ||
bg_dropdown_button = first("span.pull-right > * > .btn-default.dropdown-toggle") | ||
bg_dropdown_button.click | ||
|
||
bg_dropdown_gestionnaire = all(".dropdown-menu > li")[1] | ||
bg_dropdown_gestionnaire.click | ||
|
||
sleep 1 | ||
|
||
# For background color set to 'gestionnaire', we check for a green/white background-color | ||
colored_lines = all("ul.servers > li.server.mystring") | ||
|
||
colored_lines.each do |line| | ||
expect(line.style("background-color")["background-color"]).to eq("rgb(118, 255, 160)").or eq("rgb(255, 255, 255)") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "capybara/cuprite" | ||
|
||
Capybara.register_driver(:cuprite) do |app| | ||
options = { | ||
window_size: [1920, 1080], | ||
browser_options: {}, | ||
inspector: ENV.fetch("CUPRITE_INSPECTOR", nil), | ||
js_errors: true, | ||
} | ||
|
||
options[:headless] = ENV.fetch("CUPRITE_HEADLESS", nil) != "false" | ||
options[:browser_options][:"no-sandbox"] = nil if ENV["CI"] | ||
|
||
Capybara::Cuprite::Driver.new(app, options) | ||
end | ||
|
||
# NOTE: Wait for AJAX response since turbo make SHR requests. | ||
Capybara.default_max_wait_time = 5 | ||
Capybara.javascript_driver = :cuprite | ||
Capybara.server = :puma, { Silent: true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
Dir[Rails.root.join("spec/support/features/**/*.rb")].each { |f| require f } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.configure do |config| | ||
config.include Formulaic::Dsl, type: :feature | ||
end | ||
|
||
# NOTE: Wait for AJAX response since turbo make SHR requests. | ||
# See: https://github.com/thoughtbot/formulaic/blob/6f80b41773aa17f73847598abbd1e2b220b09715/README.md#assumptions | ||
Formulaic.default_wait_time = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters