Skip to content

Commit

Permalink
Add specs for copying via the dialog form
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmir committed Nov 11, 2024
1 parent b63a7db commit 34af85d
Showing 1 changed file with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
require_relative "../../support/pages/structured_meeting/show"
require_relative "../../support/pages/meetings/index"


RSpec.describe "Structured meetings CRUD",
:js,
:with_cuprite do
Expand Down Expand Up @@ -79,7 +78,6 @@
meetings_page.set_start_date "2013-03-28"
meetings_page.set_start_time "13:30"
meetings_page.set_duration "1.5"
# meetings_page.invite(other_user)

if test.metadata[:checked]
expect(page).to have_unchecked_field "send_notifications" # rubocop:disable RSpec/ExpectInHook
Expand Down Expand Up @@ -274,17 +272,23 @@
expect(page).to have_css(".flash", text: I18n.t("activerecord.errors.messages.error_conflict"))
end

it "can copy the meeting" do
it "can copy the meeting via the dialog form" do
expect_flash(type: :success, message: "Successful creation")

# Can add and edit a single item
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
fill_in "min", with: "25"
end

show_page.expect_agenda_item title: "My agenda item"
item = MeetingAgendaItem.find_by!(title: "My agenda item")

show_page.open_participant_form
show_page.in_participant_form do
check(id: "checkbox_invited_#{other_user.id}")
check(id: "checkbox_attended_#{other_user.id}")

click_on("Save")
end

click_on("op-meetings-header-action-trigger")

Expand All @@ -294,11 +298,30 @@
expect(page).to have_text("Copy meeting")
end

check "Email participants"
fill_in "Title", with: ""
click_on "Create meeting"

# check for dialog form validations
expect(page).to have_content "Title can't be blank."
fill_in "Title", with: "Some title"
click_on "Create meeting"

show_page.expect_agenda_item title: "My agenda item"
new_meeting = StructuredMeeting.reorder(id: :asc).last
expect(page).to have_current_path "/projects/#{project.identifier}/meetings/#{new_meeting.id}"

# check for copied agenda items
expect(page).to have_content "My agenda item"

# check for copied participants with attended status reset
page.find_test_selector("manage-participants-button").click
expect(page).to have_css("#edit-participants-dialog")
expect(page).to have_field(id: "checkbox_invited_#{other_user.id}", checked: true)
expect(page).to have_field(id: "checkbox_attended_#{other_user.id}", checked: false)

# check for email notifications
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to eq 1
end

context "with a work package reference to another" do
Expand All @@ -323,11 +346,6 @@
end
end

it "sends emails on creation when 'Send emails' is checked", :checked, pending: "TEMP" do
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to eq 2
end

context "with sections" do
let!(:meeting) { create(:structured_meeting, project:, author: current_user) }
let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }
Expand Down

0 comments on commit 34af85d

Please sign in to comment.