forked from SwIRL-CSCE-606/SwIRL-CSCE-606
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from gdbrowne85/Carlos_testing
First of many cucumbers to come
- Loading branch information
Showing
4 changed files
with
31 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
Given('the user is on the series event page') do | ||
visit('/series') # Path for the series event page | ||
end | ||
|
||
When('the user fills in the series event form with the following details:') do |table| | ||
data = table.rows_hash | ||
fill_in 'Event Name', with: data['Event Name'] | ||
fill_in 'Event Venue', with: data['Event Venue'] | ||
fill_in 'event[time_slots_attributes][0][date]', with: data['Date'] | ||
fill_in 'event[time_slots_attributes][0][start_time]', with: data['Start Time'] | ||
fill_in 'event[time_slots_attributes][0][end_time]', with: data['End Time'] | ||
end | ||
|
||
# When('the user adds two date-time pairs') do | ||
# 2.times { find_button('add-date-time').click } | ||
|
||
# # Wait for the specific number of date-time pairs to appear | ||
|
||
# # expect(page).to have_selector('.date-time-pair', count: 2, wait: 5) | ||
|
||
# # Now find all elements with the class '.date-time-pair' | ||
# date_time_pairs = all('.date-time-pair') | ||
|
||
# # Debug: Output the number of date-time pairs found | ||
# puts "Date-time pairs found: #{date_time_pairs.size}" | ||
|
||
# # Iterate over the found date-time pairs | ||
# date_time_pairs.each_with_index do |pair, index| | ||
# within(pair) do | ||
# # Assuming the date and time fields can be identified without relying on unique IDs | ||
# fill_in 'event[time_slot][][date]', with: (Date.today + 1).strftime('%Y-%m-%d') | ||
# fill_in 'event[time_slot][][start_time]', with: '09:00' | ||
# fill_in 'event[time_slot][][end_time]', with: '17:00' | ||
# end | ||
# end | ||
# end | ||
|
||
# When('the user removes the last date-time pair') do | ||
# # Assuming you have a 'Remove' button for each date-time pair | ||
# all('.remove-date-time').last.click | ||
# end | ||
|
||
And('the user submits the series event form') do | ||
date_times = all('.date-time-pair') | ||
raise 'No date-time pairs found' if date_times.empty? | ||
|
||
date_times.each do |pair| | ||
date_field = pair.find('.form-input[type="date"]') | ||
start_time_field = pair.find('.form-input[type="time"]', match: :first) | ||
end_time_field = pair.find('.form-input[type="time"]', match: :prefer_exact) | ||
|
||
if date_field.value.empty? || start_time_field.value.empty? || end_time_field.value.empty? | ||
raise 'Date and Time fields cannot be empty' | ||
end | ||
end | ||
|
||
click_button('Submit') | ||
end | ||
|
||
Then('the user should see the following series event details:') do |table| | ||
table.rows_hash.each do |_field, value| | ||
expect(page).to have_content(value) | ||
visit('/series') # Path for the series event page | ||
end | ||
|
||
When('the user fills in the series event form with the following details:') do |table| | ||
data = table.rows_hash | ||
fill_in 'Event Name', with: data['Event Name'] | ||
fill_in 'Event Venue', with: data['Event Venue'] | ||
fill_in 'event[time_slots_attributes][0][date]', with: data['Date'] | ||
fill_in 'event[time_slots_attributes][0][start_time]', with: data['Start Time'] | ||
fill_in 'event[time_slots_attributes][0][end_time]', with: data['End Time'] | ||
end | ||
|
||
# Then('the user should see a confirmation that the series event was created') do | ||
# # Adjust the expected text to match what your application will show as a confirmation message | ||
# expect(page).to have_content('Series event was successfully created') | ||
# end | ||
|
||
When('the user uploads a csv file') do | ||
# Assuming 'path_to_csv' is the path to your CSV file | ||
# Assuming 'path_to_csv' is the path to your CSV file | ||
|
||
path_to_csv = './features/step_definitions/files/Test.csv' | ||
attach_file('event[csv_file]', path_to_csv) # 'Choose File' is the name of the input field for file upload | ||
path_to_csv = './features/step_definitions/files/Test.csv' | ||
attach_file('event[csv_file]', path_to_csv) # 'Choose File' is the name of the input field for file upload | ||
end | ||
|
||
And('the event {string} should display the following attendee details:') do |event_name, attendees_table| | ||
# Find and click the event card to reveal the event content | ||
find('.event-card', text: event_name).click | ||
When('the user submits the series event form') do | ||
click_button('Submit') # Adjust this if your submit button has a different name or text | ||
end | ||
|
||
# Now check the attendee details within the event content | ||
attendees_table.hashes.each do |attendee| | ||
within('.event-content', visible: true) do | ||
attendee_li = find('.attendee', text: attendee['Email']) | ||
expect(attendee_li).to have_text("Email: #{attendee['Email']}") | ||
status_span = attendee_li.find('span.status') | ||
expect(status_span.text).to eq(attendee['Status']) | ||
Then('the user should see the following series event details:') do |table| | ||
table.rows_hash.each do |_field, value| | ||
expect(page).to have_content(value) | ||
end | ||
end | ||
end | ||
|
||
# Scenario: Successfully adding and removing date-time pairs | ||
# When the user fills in the series event form with the following details: | ||
# | Field | Value | | ||
# | Event Name | MultiMeet | | ||
# | Event Venue | Conference Room A | | ||
# And the user adds two date-time pairs | ||
# And the user removes the last date-time pair | ||
# And the user submits the series event form | ||
# Then the user should see a confirmation that the series event was created | ||
|
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 @@ | ||
# spec/factories/users.rb | ||
|
||
FactoryBot.define do | ||
factory :user do | ||
email { "organizer@example.com" } | ||
password { "securepassword" } | ||
role { "organizer" } # assuming your User model has a role attribute | ||
# add other necessary attributes | ||
end | ||
end | ||
|