Skip to content

Commit 3d01f53

Browse files
committed
Added step definitions and cucumber scenarios for UI changes of request table
1 parent 160e6f5 commit 3d01f53

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

features/requests.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,15 @@ Scenario: Teacher sees Request in Requests table
7777
Then I log in as a teacher
7878
And I go to the Requests page
7979
Then I should see "Homework 3"
80+
81+
Scenario: Approve Selected and Reject Selected buttons appear below the requests table
82+
Given a pending request exists
83+
And I go to the Requests page
84+
Then the "Approve Selected" button should appear after the requests table
85+
And the "Reject Selected" button should appear after the requests table
86+
87+
Scenario: Clicking the status of a request navigates to the request page
88+
Given a pending request exists
89+
And I go to the Requests page
90+
When I click the status cell for that request
91+
Then I should be on the request page for that request

features/step_definitions/custom_steps.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,29 @@
195195
expect(search_input.value).not_to be_empty
196196
end
197197

198+
Given(/^a pending request exists$/) do
199+
student = User.joins(:user_to_courses).find_by(user_to_courses: { course: @course, role: 'student' })
200+
assignment = Assignment.find_by(course: @course)
201+
@pending_request = create(:request, user: student, course: @course, assignment: assignment)
202+
end
203+
204+
Then(/^the "([^"]*)" button should appear after the requests table$/) do |button_text|
205+
table = find('#requests-table')
206+
button = find('button', text: button_text)
207+
expect(table.native.xpath("following::button[normalize-space(.)='#{button_text}']").any?).to be true
208+
end
209+
210+
When(/^I click the status cell for that request$/) do
211+
within(:xpath, "//tr[td[contains(@data-export, '')]][1]") do
212+
find('td:last-child a').click
213+
end
214+
end
215+
216+
Then(/^I should be on the request page for that request$/) do
217+
expected_path = "/courses/#{@course.id}/requests/#{@pending_request.id}"
218+
expect(page.current_path).to eq(expected_path)
219+
end
220+
198221
Given(/^I deny the request for "([^"]*)"$/) do |assignment_name|
199222
request = Request.joins(:assignment)
200223
.find_by(assignments: { name: assignment_name }, status: 'pending')

0 commit comments

Comments
 (0)