Skip to content

Commit

Permalink
added cucumber tests and added untracked migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushC committed Feb 23, 2024
1 parent 96267f9 commit 96c18ec
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeToFieldForFormSubmission < ActiveRecord::Migration[6.1]
def change
EmailTemplate.find_by(path: "teacher_mailer/form_submission").update(to: "[email protected], [email protected]")
end
end
30 changes: 30 additions & 0 deletions features/email_template.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,33 @@ Scenario: Logging in as an admin should be able to edit email subject
And I press "Submit"
And I follow "Welcome Email"
Then the "email_template_subject" field should contain "Test Subject"

Scenario: Creating new email template with blank fields displays flash error
Given I am on the email templates index
And I press "New Email Templates"
When I press "Submit"
Then I should see "Failed to submit information: Body cannot be blank, To cannot be blank"

Scenario: Creating and deleting new email template with valid fields succeeds
Given I am on the email templates index
And I press "New Email Templates"
When I fill in "email_template_title" with "Test Email"
And I fill in "email_template_subject" with "Test Subject"
And I fill in "email_template_to" with "{{teacher_email}}"
And I fill in TinyMCE email form with "This is the body of my test email"
And I press "Submit"
Then I should see "Created Test Email successfully"
When I follow the first "❌" link
And I accept the popup alert
Then I should be on the email templates index
And I should not see "Test Email"

Scenario: Editing email template to have blank body or to field displays flash error
Given I am on the email templates index
And I follow "Welcome Email"
And I fill in "email_template_to" with ""
And I press "Submit"
Then I should see "Failed to save Welcome Email template: To cannot be blank"
When I fill in TinyMCE email form with ""
And I press "Submit"
Then I should see "Failed to save Welcome Email template: Body cannot be blank"
12 changes: 12 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ def with_scope(locator, &block)
page.execute_script('$(tinymce.editors[0].setContent("' + value + '"))')
end

When(/^(?:|I )follow the first "([^"]*)" link$/) do |link_text|
first("a", text: link_text).click
end

When(/^(?:|I )press the first "([^"]*)" button$/) do |button_text|
first("button", text: button_text).click
end

Then(/^(?:|I )accept the popup alert$/) do
page.driver.browser.switch_to.alert.accept
end

When(/^(?:|I )fill in "([^"]*)" for "([^"]*)"$/) do |value, field|
fill_in(field, with: value)
end
Expand Down

0 comments on commit 96c18ec

Please sign in to comment.