Skip to content

Commit 51fe607

Browse files
committed
Added cucumber scenariosfor admin tools
1 parent a02f4b2 commit 51fe607

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

features/navigation.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,19 @@ Feature: Navigation
4040
And I should see "Login with bCourses" in the navbar
4141
And I should not see "Offerings" in the navbar
4242
And I should not see "Logout" in the navbar
43+
44+
Scenario: Admin user sees admin tools in navbar dropdown
45+
Given a course exists
46+
And I am logged in as an admin
47+
And I am on the "Courses page"
48+
Then I should see "Admin Tools" in the navbar dropdown
49+
And I should see "Dashboards" in the navbar dropdown
50+
And I should see "Background Jobs" in the navbar dropdown
51+
52+
Scenario: Non-admin user does not see admin tools in navbar dropdown
53+
Given a course exists
54+
And I am logged in as a teacher
55+
And I am on the "Courses page"
56+
Then I should not see "Admin Tools" in the navbar dropdown
57+
And I should not see "Dashboards" in the navbar dropdown
58+
And I should not see "Background Jobs" in the navbar dropdown

features/step_definitions/custom_steps.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
end
1515
end
1616

17+
Given(/^I am logged in as an admin$/) do
18+
user = create(:admin, email: 'admin@berkeley.edu', canvas_uid: 'canvas_uid_admin')
19+
page.set_rack_session(user_id: user.canvas_uid, username: user.name)
20+
end
21+
1722
Given(/^(?:I am|I'm|I) (?:logged|log) in as a (teacher|ta|student)$/i) do |role|
1823
emails = {
1924
'teacher' => 'user1@berkeley.edu',

features/step_definitions/navigation_steps.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
end
1515
end
1616

17+
Then(/^I should see "(.*?)" in the navbar dropdown$/) do |text|
18+
within('nav .dropdown-menu') do
19+
expect(page).to have_content(text)
20+
end
21+
end
22+
23+
Then(/^I should not see "(.*?)" in the navbar dropdown$/) do |text|
24+
within('nav .dropdown-menu') do
25+
expect(page).not_to have_content(text)
26+
end
27+
end
28+
1729
When(/^I navigate to any page other than the "(.*?)"$/) do |excluded_page|
1830
# Currently included home and courses page
1931
case excluded_page

0 commit comments

Comments
 (0)