Skip to content

Commit

Permalink
Add cucumber tests for reason empty behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
perryzjc committed Mar 4, 2024
1 parent 648ecb7 commit 46ecd1a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 14 deletions.
68 changes: 54 additions & 14 deletions features/admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Feature: basic admin functionality

Background: Has an Admin in DB
Given the following teachers exist:
| first_name | last_name | admin | email |
| Joseph | Mamoa | true | testadminuser@berkeley.edu |
| first_name | last_name | admin | email |
| Joseph | Mamoa | true | testadminuser@berkeley.edu |

Scenario: Logging in as an admin
Given I am on the BJC home page
Expand Down Expand Up @@ -76,8 +76,8 @@ Feature: basic admin functionality

Scenario: Edit teacher info as an admin
Given the following schools exist:
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
Given the following teachers exist:
| first_name | last_name | admin | email | school | snap |
| Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo |
Expand Down Expand Up @@ -132,9 +132,9 @@ Feature: basic admin functionality
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
Given the following teachers exist:
| first_name | last_name | admin | email | school | application_status |
| Victor | Validateme | false | testteacher1@berkeley.edu | UC Berkeley | Validated |
| Danny | Denyme | false | testteacher2@berkeley.edu | UC Berkeley | Denied |
| Peter | Pendme | false | testteacher3@berkeley.edu | UC Berkeley | Not Reviewed |
| Victor | Validateme | false | testteacher1@berkeley.edu | UC Berkeley | Validated |
| Danny | Denyme | false | testteacher2@berkeley.edu | UC Berkeley | Denied |
| Peter | Pendme | false | testteacher3@berkeley.edu | UC Berkeley | Not Reviewed |
Given I am on the BJC home page
Given I have an admin email
And I follow "Log In"
Expand All @@ -156,7 +156,7 @@ Feature: basic admin functionality
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
Given the following teachers exist:
| first_name | last_name | admin | email | school | snap |
| Joseph | Test | false | testteacher@berkeley.edu | UC Berkeley | alonzo |
| Joseph | Test | false | testteacher@berkeley.edu | UC Berkeley | alonzo |
Given I am on the BJC home page
Given I have an admin email
And I follow "Log In"
Expand All @@ -173,11 +173,11 @@ Feature: basic admin functionality

Scenario: Edit teacher info as an admin navigating from view only page to edit page
Given the following schools exist:
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
Given the following teachers exist:
| first_name | last_name | admin | email | school | snap |
| Joseph | Mamoa New | false | testteacher@berkeley.edu | UC Berkeley | alonzo |
| Joseph | Mamoa New | false | testteacher@berkeley.edu | UC Berkeley | alonzo |
Given I am on the BJC home page
Given I have an admin email
And I follow "Log In"
Expand All @@ -197,11 +197,11 @@ Feature: basic admin functionality

Scenario: Should be able to resend welcome email
Given the following schools exist:
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
Given the following teachers exist:
| first_name | last_name | admin | email | school | snap | application_status |
| Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | validated |
| Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | validated |
Given I am on the BJC home page
Given I have an admin email
And I follow "Log In"
Expand Down Expand Up @@ -253,7 +253,47 @@ Feature: basic admin functionality
And I fill in "request_reason" with "Complete your profile details"
And I press "Submit"
Then I can send a request info email
Then I should see dialog box closed

Scenario: Denying teacher without specifying a reason as an admin should not send email
Given the following schools exist:
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
And the following teachers exist:
| first_name | last_name | admin | email | school |
| Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley |
And I am on the BJC home page
And I have an admin email
When I follow "Log In"
Then I can log in with Google
And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)"
Then I should see "Reason"
And I should see "Deny Joseph Mamoa"
And I capture the email count
And I fill in "denial_reason" with ""
And I press "Submit"
Then I should see dialog box remain open
Then no new emails should have been sent

Scenario: Requesting more information from a teacher without specifying a reason as an admin should not send email
Given the following schools exist:
| name | city | state | website | grade_level | school_type |
| UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public |
And the following teachers exist:
| first_name | last_name | admin | email | school |
| Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley |
And I am on the BJC home page
And I have an admin email
When I follow "Log In"
Then I can log in with Google
And I press "❓" within "#DataTables_Table_0 > tbody > tr:nth-child(1)"
Then I should see "Reason"
And I should see "Request Info from Joseph Mamoa"
And I capture the email count
And I fill in "request_reason" with ""
And I press "Submit"
Then I should see dialog box remain open
Then no new emails should have been sent

# Scenario: Admin can import csv file. The loader should filter invalid record and create associate school.
# Given the following schools exist:
Expand Down
11 changes: 11 additions & 0 deletions features/step_definitions/admin_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@
attach_file("file", File.expand_path(path))
Capybara.ignore_hidden_elements = true
end

Given(/I capture the email count/) do
# Store the initial count of emails in an instance variable
@initial_email_count = ActionMailer::Base.deliveries.count
end

Then(/no new emails should have been sent/) do
# Compare the current email count to the initial count stored earlier
expect(ActionMailer::Base.deliveries.count).to eq @initial_email_count
end

8 changes: 8 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,11 @@ def with_scope(locator, &block)
field_labeled(field).find(:xpath, ".//option[@selected = 'selected'][text() = '#{value}']").should be_present
end
end

Then("I should see dialog box remain open") do
expect(page).to have_css(".js-denialModal.show")
end

Then("I should see dialog box closed") do
expect(page).to have_no_css(".js-denialModal.show")
end

0 comments on commit 46ecd1a

Please sign in to comment.