-
Notifications
You must be signed in to change notification settings - Fork 494
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
1 parent
cd97bb0
commit 796ff79
Showing
4 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
def expect_scheduled(event, time) | ||
visit admin_conference_program_event_path(event.conference.short_title, event) | ||
if time | ||
date = event.conference.start_date.strftime('%F') | ||
expect(page).to have_text("Scheduled time #{date} #{time} #{event.conference.timezone}") | ||
else | ||
expect(page).to have_no_text('Scheduled') | ||
end | ||
end | ||
|
||
def move(event, to:) | ||
draggable = find("#event-#{event.id}.ui-draggable") | ||
droppable = find("#schedule-room-#{to[0].guid}-#{to[1]}-#{to[2]}.ui-droppable") | ||
wait_for_ajax { draggable.drag_to droppable } | ||
end | ||
|
||
def remove(event) | ||
button = find("#event-#{event.id} .schedule-event-delete-button") | ||
wait_for_ajax { button.click } | ||
end | ||
|
||
feature Schedule do | ||
let(:venue) { create(:venue) } | ||
let(:conference) { create(:conference, venue: venue) } | ||
let!(:room) { create(:room, venue: venue) } | ||
let!(:event) { create(:event, program: conference.program, state: 'confirmed') } | ||
|
||
context 'as an organizer' do | ||
let(:organizer) { create(:organizer, resource: conference) } | ||
|
||
before :each do | ||
sign_in organizer | ||
end | ||
|
||
scenario 'create a schedule', js: true do | ||
expect_scheduled event, nil | ||
|
||
visit admin_conference_schedules_path(conference) | ||
click_on 'Add Schedule' | ||
move event, to: [room, 9, 30] | ||
wait_for_ajax { switch conference.short_title, to: true } | ||
|
||
expect_scheduled event, '09:30' | ||
end | ||
|
||
scenario 'reschedule an event', js: true do | ||
create(:event_schedule, event: event, room: room) | ||
expect_scheduled event, '09:00' | ||
|
||
visit admin_conference_schedule_path(conference, conference.program.selected_schedule) | ||
move event, to: [room, 12, 15] | ||
|
||
expect_scheduled event, '12:15' | ||
end | ||
|
||
scenario 'unschedule an event', js: true do | ||
create(:event_schedule, event: event, room: room) | ||
expect_scheduled event, '09:00' | ||
|
||
visit admin_conference_schedule_path(conference, conference.program.selected_schedule) | ||
remove event | ||
|
||
expect_scheduled event, nil | ||
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
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module BootstrapMacros | ||
# Interact with Bootstrap Switch | ||
def switch(locator, to:, **options) | ||
checkbox = find(:checkbox, locator, **options, visible: :hidden) | ||
|
||
checkbox.ancestor('.bootstrap-switch').click unless checkbox.checked? == to | ||
expect(page).to have_selector(:checkbox, locator, **options, visible: :hidden, checked: to) | ||
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module JQueryMacros | ||
# Wait for one jQuery Ajax request during the block | ||
def wait_for_ajax | ||
flag = "window.ajax_#{SecureRandom.alphanumeric(16)}" | ||
page.execute_script "#{flag} = false; $(document).one('ajaxComplete', () => #{flag} = true);" | ||
|
||
yield | ||
|
||
Timeout.timeout(Capybara.default_max_wait_time) { loop until page.evaluate_script(flag) } | ||
page.execute_script "delete #{flag};" | ||
end | ||
end |