From b6dd7a17cdef7c1bef4519d5749496a623ef835b Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:01:56 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A5=97=20`Gizmo`:=20System=20Spec=20t?= =?UTF-8?q?o=20Add=20and=20Remove=20Gizmo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://github.com/zinc-collective/convene/issues/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 --- app/models/room.rb | 1 + spec/factories/space.rb | 4 ++++ spec/system/furniture_spec.rb | 42 +++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 spec/system/furniture_spec.rb diff --git a/app/models/room.rb b/app/models/room.rb index 2be84d42c..c46e94e8f 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -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}" diff --git a/spec/factories/space.rb b/spec/factories/space.rb index 4dbdb3c47..36f692f86 100644 --- a/spec/factories/space.rb +++ b/spec/factories/space.rb @@ -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 } diff --git a/spec/system/furniture_spec.rb b/spec/system/furniture_spec.rb new file mode 100644 index 000000000..509ae51c9 --- /dev/null +++ b/spec/system/furniture_spec.rb @@ -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 From 8706547bd906d608efe033075b196123a21890ea Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:01:56 -0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9E=F0=9F=94=A8=20`Gizmo`:=20Fix?= =?UTF-8?q?=20bug=20where=20removing=20a=20Gizmo=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://github.com/zinc-collective/convene/issues/1565 OK this is also a bit much; but it does fix the bug. I'm going to try and tighten it up a bit --- app/assets/stylesheets/components/button.scss | 3 ++- app/views/furnitures/_form.html.erb | 11 +++++++---- app/views/furnitures/_furniture.html.erb | 1 + spec/system/furniture_spec.rb | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/components/button.scss b/app/assets/stylesheets/components/button.scss index b044401ea..e5d4520fd 100644 --- a/app/assets/stylesheets/components/button.scss +++ b/app/assets/stylesheets/components/button.scss @@ -1,10 +1,11 @@ +/* @todo DELETE ME */ @layer components { [type="reset"], [type="button"], [type="submit"], button, .button { - @apply font-bold py-2 px-4 my-1 rounded bg-primary-500 text-white text-center transition ease-in-out duration-150; + @apply font-bold py-2 px-4 rounded bg-primary-500 text-white text-center transition ease-in-out duration-150; &:hover { @apply bg-primary-700; diff --git a/app/views/furnitures/_form.html.erb b/app/views/furnitures/_form.html.erb index c0b7ef08c..6c9b239b8 100644 --- a/app/views/furnitures/_form.html.erb +++ b/app/views/furnitures/_form.html.erb @@ -1,14 +1,17 @@
<%- if policy(furniture).edit? %> - <%= form_with(model: [furniture.room.space, furniture.room, furniture], local: true) do |form| %> + <%= form_with(model: [furniture.room.space, furniture.room, furniture]) do |form| %>
<%= render partial: furniture.furniture.form_template, locals: { form: form } %>