diff --git a/features/create_singular_event.feature b/features/create_singular_event.feature index f54cce9..a36ee3b 100644 --- a/features/create_singular_event.feature +++ b/features/create_singular_event.feature @@ -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 | - diff --git a/features/limit_number_of_invites_to_max_capacity.feature b/features/limit_number_of_invites_to_max_capacity.feature index 704f113..00e6084 100644 --- a/features/limit_number_of_invites_to_max_capacity.feature +++ b/features/limit_number_of_invites_to_max_capacity.feature @@ -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" diff --git a/features/step_definitions/create_series_event.rb b/features/step_definitions/create_series_event.rb index cc821b3..0f88235 100644 --- a/features/step_definitions/create_series_event.rb +++ b/features/step_definitions/create_series_event.rb @@ -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 + diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 0000000..f3d0ec5 --- /dev/null +++ b/spec/factories/users.rb @@ -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 + \ No newline at end of file