-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathpage_list_feature_spec.rb
More file actions
120 lines (108 loc) · 4.74 KB
/
page_list_feature_spec.rb
File metadata and controls
120 lines (108 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# frozen_string_literal: true
require "rails_helper"
require "timecop"
RSpec.describe "Admin page list", type: :system do
context "not logged in" do
specify "it redirects to login" do
visit admin_pages_path(view: "list")
expect(page.current_path).to eq(Alchemy.login_path)
end
end
context "as author" do
let!(:root_page) { create(:alchemy_page, :language_root, :public, name: "Intro") }
let!(:alchemy_page) { create(:alchemy_page, parent: root_page, name: "Page 1").tap { |p| p.update!(updated_at: Time.parse("2020-08-20")) } }
let!(:alchemy_page_2) { create(:alchemy_page, parent: root_page, name: "Contact", page_layout: "contact").tap { |p| p.update(updated_at: Time.parse("2020-08-24")) } }
let!(:alchemy_page_3) { create(:alchemy_page, :layoutpage, name: "Footer") }
before do
authorize_user(:as_author)
end
specify "displays a table of non layout pages" do
visit admin_pages_path(view: "list")
within("table.list") do
expect(page).to have_css("tr:nth-child(1) td.name:contains('Contact')")
expect(page).to have_css("tr:nth-child(2) td.name:contains('Intro')")
expect(page).to have_css("tr:nth-child(3) td.name:contains('Page 1')")
expect(page).to_not have_css("td.name:contains('Footer')")
end
end
specify "can sort table of pages by name" do
visit admin_pages_path(view: "list")
page.find(".sort_link", text: "Name").click
expect(page).to have_css("thead a.sort_link.desc:contains('Name')")
within("table.list") do
expect(page).to have_css("tr:nth-child(1) td.name:contains('Page 1')")
expect(page).to have_css("tr:nth-child(2) td.name:contains('Intro')")
expect(page).to have_css("tr:nth-child(3) td.name:contains('Contact')")
end
end
specify "can sort table of pages by update date" do
Timecop.travel("2020-08-25") do
visit admin_pages_path(view: "list")
page.find(".sort_link", text: "Updated at").click
expect(page).to have_css("thead a.sort_link.desc:contains('Updated at')")
within("table.list") do
expect(page).to have_css("tr:nth-child(1) td.name:contains('Intro')")
expect(page).to have_css("tr:nth-child(2) td.name:contains('Contact')")
expect(page).to have_css("tr:nth-child(3) td.name:contains('Page 1')")
end
end
end
specify "can filter table of pages by name" do
visit admin_pages_path(view: "list")
page.find(".search_input_field").set("Page")
page.find(".search_field button").click
expect(page).to have_content("1 Page")
within("table.list") do
expect(page).to have_css("tr:nth-child(1) td.name:contains('Page 1')")
expect(page).to_not have_css("tr:nth-child(2)")
expect(page).to_not have_css("tr:nth-child(3)")
end
end
specify "can filter table of pages by status", :js do
visit admin_pages_path(view: "list")
check("Published")
expect(page).to have_content("Filtered by")
within("table.list") do
expect(page.find("tr:nth-child(1) td.name", text: "Intro")).to be
expect(page).to_not have_css("tr:nth-child(2)")
expect(page).to_not have_css("tr:nth-child(3)")
end
end
specify "can filter table of pages by type", :js do
visit admin_pages_path(view: "list")
select2("Contact", from: "Page type")
expect(page).to have_content("Filtered by")
within("table.list") do
expect(page.find("tr:nth-child(1) td.name", text: "Contact")).to be
expect(page).to_not have_css("tr:nth-child(2)")
expect(page).to_not have_css("tr:nth-child(3)")
end
end
specify "can filter table of pages by date", :js do
root_page.update!(updated_at: Time.parse("2020-08-10"))
Timecop.travel("2020-08-25") do
visit admin_pages_path(view: "list")
page.execute_script <<~JS.strip_heredoc
const fp = document.getElementById("q_updated_at_gteq")._flatpickr;
fp.setDate("2020-08-23 00:00", true);
JS
expect(page).to have_content("1 Page")
within("table.list") do
expect(page.find("tr:nth-child(1) td.name", text: "Contact")).to be
expect(page).to_not have_css("tr:nth-child(2)")
expect(page).to_not have_css("tr:nth-child(3)")
end
end
end
specify "can filter table of pages by page type", :js do
visit admin_pages_path(view: "list")
select2("contact", from: "Page Type")
expect(page).to have_content("1 Page")
within("table.list") do
expect(page.find("tr:nth-child(1) td.name", text: "Contact")).to be
expect(page).to_not have_css("tr:nth-child(2)")
expect(page).to_not have_css("tr:nth-child(3)")
end
end
end
end