Skip to content

Commit

Permalink
Add projects, pages, and reports system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
remomueller committed May 27, 2019
1 parent 0b3341c commit a228b83
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 90 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
56 changes: 33 additions & 23 deletions test/system/pages_test.rb
Original file line number Diff line number Diff line change
@@ -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
41 changes: 0 additions & 41 deletions test/system/report_rows_test.rb

This file was deleted.

59 changes: 34 additions & 25 deletions test/system/reports_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a228b83

Please sign in to comment.