Skip to content

Commit

Permalink
Merge pull request #59 from gdbrowne85/Carlos_testing
Browse files Browse the repository at this point in the history
First of many cucumbers to come
  • Loading branch information
Carmeisel101 authored Apr 25, 2024
2 parents ecfaeb4 + 85a042b commit c297b88
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 110 deletions.
17 changes: 0 additions & 17 deletions features/create_singular_event.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,5 @@ Feature: Create Singular Event
| Max Capacity | 100 |
And the user submits the event creation form
Then the user should be redirected to the event details page with a unique event ID
And the user should see the following event details:
| Name | Valorant |
| Venue | Zachery |
| Date | 2023-11-22 |
| Start Time | 06:09 PM | # Updated to match the format displayed on the page
| End Time | 08:09 PM | # Updated to match the format displayed on the page
| Max Capacity | 100 |
When the user clicks the "Status" button
When the user clicks on the event named "Valorant"
Then the event content for "Valorant" should be visible
Then the event "Valorant" should display the following details:
| Date | Wednesday, 22 Nov 2023 |
| Time | 6:09 PM - 08:09 PM |
| Location | Zachery |
| Yes/No Ratio | 0 / 0 |
| Max Capacity | 100 |



2 changes: 1 addition & 1 deletion features/limit_number_of_invites_to_max_capacity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Limit number of invitations sent to the max capacity
| Event End Time | 20:09 |
| Max Capacity | 10 |
And I submit the event creation form
Given I created an event and I click on the "Status" link
Then I should be on the "Event Dashboard" page
Then I should be on the "Event Dashboard" page
And I click on "Lecture" event
Then I extract the max capacity of "Lecture"
Expand Down
111 changes: 19 additions & 92 deletions features/step_definitions/create_series_event.rb
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

11 changes: 11 additions & 0 deletions spec/factories/users.rb
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

0 comments on commit c297b88

Please sign in to comment.