diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b24a3..5e8f39d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - Update to rubyzip 1.2.3 ### Tests -- Add projects system tests +- Add projects, pages, and reports system tests ## 16.0.0 (May 9, 2019) diff --git a/test/system/pages_test.rb b/test/system/pages_test.rb index a1f507f..d09630f 100644 --- a/test/system/pages_test.rb +++ b/test/system/pages_test.rb @@ -1,49 +1,59 @@ +# frozen_string_literal: true + require "application_system_test_case" +# Test for admins to view pages. class PagesTest < ApplicationSystemTestCase setup do @page = pages(:one) + @admin = users(:admin) end - test "visiting the index" do + test "visit the index" do + visit_login(@admin) visit pages_url assert_selector "h1", text: "Pages" + screenshot("visit-pages-index") end - test "creating a Page" do + test "create a page" do + visit_login(@admin) visit pages_url - click_on "New Page" - - check "Archived" if @page.archived - fill_in "Name", with: @page.name - fill_in "Position", with: @page.position - fill_in "Slug", with: @page.slug + screenshot("create-a-page") + click_on "New page" + fill_in "page[name]", with: "Page One" + fill_in "page[position]", with: "1" + screenshot("create-a-page") click_on "Create Page" - assert_text "Page was successfully created" - click_on "Back" + assert_selector "h1", text: "Pages" + screenshot("create-a-page") end - test "updating a Page" do + test "update a page" do + visit_login(@admin) visit pages_url - click_on "Edit", match: :first - - check "Archived" if @page.archived - fill_in "Name", with: @page.name - fill_in "Position", with: @page.position - fill_in "Slug", with: @page.slug + screenshot("update-a-page") + click_on "Actions", match: :first + screenshot("update-a-page") + click_on "Edit" + fill_in "page[name]", with: "Updated Name" + screenshot("update-a-page") click_on "Update Page" - assert_text "Page was successfully updated" - click_on "Back" + assert_selector "h1", text: "Pages" + screenshot("update-a-page") end - test "destroying a Page" do + test "destroy a page" do + visit_login(@admin) visit pages_url + screenshot("destroy-a-page") + click_on "Actions", match: :first page.accept_confirm do - click_on "Destroy", match: :first + click_on "Delete" end - - assert_text "Page was successfully destroyed" + assert_text "Page was successfully deleted" + screenshot("destroy-a-page") end end diff --git a/test/system/report_rows_test.rb b/test/system/report_rows_test.rb deleted file mode 100644 index 747c898..0000000 --- a/test/system/report_rows_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "application_system_test_case" - -class ReportRowsTest < ApplicationSystemTestCase - setup do - @report_row = report_rows(:one) - end - - test "visiting the index" do - visit report_rows_url - assert_selector "h1", text: "Report Rows" - end - - test "creating a Report row" do - visit report_rows_url - click_on "New Report Row" - - click_on "Create Report row" - - assert_text "Report row was successfully created" - click_on "Back" - end - - test "updating a Report row" do - visit report_rows_url - click_on "Edit", match: :first - - click_on "Update Report row" - - assert_text "Report row was successfully updated" - click_on "Back" - end - - test "destroying a Report row" do - visit report_rows_url - page.accept_confirm do - click_on "Destroy", match: :first - end - - assert_text "Report row was successfully destroyed" - end -end diff --git a/test/system/reports_test.rb b/test/system/reports_test.rb index 76130d0..0c979da 100644 --- a/test/system/reports_test.rb +++ b/test/system/reports_test.rb @@ -1,51 +1,60 @@ +# frozen_string_literal: true + require "application_system_test_case" +# Test for admins to view reports. class ReportsTest < ApplicationSystemTestCase setup do @report = reports(:one) + @admin = users(:admin) end - test "visiting the index" do + test "visit the index" do + visit_login(@admin) visit reports_url assert_selector "h1", text: "Reports" + screenshot("visit-reports-index") end - test "creating a Report" do + test "create a report" do + visit_login(@admin) visit reports_url - click_on "New Report" - - check "Archived" if @report.archived - fill_in "Header label", with: @report.header_label - fill_in "Last cached at", with: @report.last_cached_at - fill_in "Name", with: @report.name - fill_in "Slug", with: @report.slug + screenshot("create-a-report") + click_on "New report" + select projects(:one).name, from: "report[project_id]" + select "Expressions by Site", from: "report[report_type]" + fill_in "report[name]", with: "Report One" + screenshot("create-a-report") click_on "Create Report" - assert_text "Report was successfully created" - click_on "Back" + assert_selector "h1", text: "Reports" + screenshot("create-a-report") end - test "updating a Report" do + test "update a report" do + visit_login(@admin) visit reports_url - click_on "Edit", match: :first - - check "Archived" if @report.archived - fill_in "Header label", with: @report.header_label - fill_in "Last cached at", with: @report.last_cached_at - fill_in "Name", with: @report.name - fill_in "Slug", with: @report.slug + screenshot("update-a-report") + click_on "Actions", match: :first + screenshot("update-a-report") + click_on "Edit" + fill_in "report[name]", with: "Updated Name" + screenshot("update-a-report") click_on "Update Report" - assert_text "Report was successfully updated" - click_on "Back" + assert_selector "h1", text: "Reports" + screenshot("update-a-report") end - test "destroying a Report" do + test "destroy a report" do + visit_login(@admin) visit reports_url + screenshot("destroy-a-report") + click_on "Actions", match: :first page.accept_confirm do - click_on "Destroy", match: :first + click_on "Delete" end - - assert_text "Report was successfully destroyed" + assert_text "Report was successfully deleted" + screenshot("destroy-a-report") end end