Skip to content

Commit

Permalink
finished homeschool feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushC committed Apr 23, 2024
1 parent 3af102d commit 2af33f6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
20 changes: 20 additions & 0 deletions features/admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,26 @@ Feature: basic admin functionality
Then I should not see "Supporting Files:"
And I should not see "Upload More Files:"

Scenario: Admin can edit files of a homeschool teacher on the teacher's show page
Given the following schools exist:
| name | country | city | state | website | grade_level | school_type |
| UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public |
And the following teachers exist:
| first_name | last_name | admin | primary_email | school |
| Jane | Doe | false | janedoe@berkeley.edu | UC Berkeley |
Given I am on the BJC home page
And I have an admin email
And I follow "Log In"
Then I can log in with Google
Then I go to the edit page for Jane Doe
And I set my status as "I am teaching homeschool with the BJC curriculum."
And I press "Update"
Then I go to the show page for Jane Doe
When I attach the file with name "test_file.txt" on the show page
Then I see a confirmation "File was successfully uploaded"
When I click the first file deletion button
And I accept the popup alert
Then I see a confirmation "File was successfully removed"

# Scenario: Admin can import csv file. The loader should filter invalid record and create associate school.
# Given the following schools exist:
Expand Down
15 changes: 14 additions & 1 deletion features/step_definitions/teacher_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,20 @@
expect(page).to have_selector("#upload_file_field", visible: :visible)
end

When("I attach the file with name {string}") do |file_name|
When("I attach the file with name {string} on the edit page") do |file_name|
page.execute_script("$('teacher_more_files').click()")
attach_file("teacher_more_files", Rails.root.join("spec/fixtures", file_name))
end

# Note: this is an admin-only action
When("I attach the file with name {string} on the show page") do |file_name|
page.execute_script("$('label.btn.btn-primary.btn-purple.mr-2').click()"); # clicks the "Add a File" button
# Execute JavaScript to make the file input field temporarily visible
page.execute_script("$('#file-upload-field').css('display', 'block');")
attach_file("file-upload-field", Rails.root.join("spec/fixtures", file_name))
page.execute_script("$('#file-upload-field').css('display', 'none');")
end

When("I click the first file deletion button") do
first('input[data-confirm="Are you sure you want to remove this file?"]').click
end

0 comments on commit 2af33f6

Please sign in to comment.