-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add projects, pages, and reports system tests
- Loading branch information
1 parent
0b3341c
commit a228b83
Showing
4 changed files
with
68 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |