Skip to content

Commit

Permalink
🥗 Gizmo: System Spec to Add and Remove Gizmo
Browse files Browse the repository at this point in the history
- #1565

For whatever reason the automated check doesn't *FAIL* despite it
failing when we manually execute it!

Add Firefox to the RSpec tests

Run in Headless mode on CI

Don't send real emails in CI

save screenshots yo

Add the .env.development to the devcontaine

Add Firefox to the RSpec tests

Run in Headless mode on CI

Don't send real emails in CI

save screenshots yo
  • Loading branch information
zspencer committed Jun 25, 2023
1 parent 4327166 commit b6dd7a1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Room < ApplicationRecord

has_many :furnitures, dependent: :destroy, inverse_of: :room
accepts_nested_attributes_for :furnitures
alias_method :gizmos, :furnitures

def full_slug
"#{space.slug}--#{slug}"
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
factory :space do
sequence(:name) { |n| "#{Faker::Book.title} #{n}" }

trait :with_entrance do
entrance { association(:room, space: instance) }
end

trait :with_members do
transient do
member_count { 4 }
Expand Down
42 changes: 42 additions & 0 deletions spec/system/furniture_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require "rails_helper"

# @see https://github.com/zinc-collective/convene/issues/709
describe "Furniture" do
include ActiveJob::TestHelper
it "Managing Furniture" do
space = create(:space, :with_entrance, :with_members, member_count: 1)
# Sign in to the Space
sign_in(space.members.first, space)

add_gizmo("Markdown Text Block", room: space.entrance)
remove_gizmo("Markdown Text Block", room: space.entrance)

visit(polymorphic_path(space.entrance.location(:edit)))
expect(page).to have_text("No gizmos yet.")
end

def sign_in(user, space)
visit(polymorphic_path(space.location))
click_link_or_button("Sign in")
fill_in("authenticated_session[contact_location]", with: user.email)
find('input[type="submit"]').click
perform_enqueued_jobs

visit(URI.parse(URI.extract(ActionMailer::Base.deliveries.first.body.to_s)[1]).request_uri)
end

def add_gizmo(type, room:)
visit(polymorphic_path(room.location(:edit)))
select(type, from: "Type of gizmo")
click_link_or_button("Add Gizmo")
end

def remove_gizmo(type, room:)
visit(polymorphic_path(room.location(:edit)))
expect(page).to have_text("Markdown Text Block")
within("##{ActionView::RecordIdentifier.dom_id(room.gizmos.first)}") do
click_link_or_button "Configure Markdown Text Block"
end
click_link_or_button "Remove Gizmo"
end
end

0 comments on commit b6dd7a1

Please sign in to comment.