Commit c65eace0151b524e7acb5ac52aafd8bd818e5dc0
1 parent
e4777a8f
Exists in
master
and in
27 other branches
[media-panel-improvements] Test coverage
Selenium tests for the new media panel. I also fixed the attach file step and a blog test.
Showing
4 changed files
with
271 additions
and
2 deletions
Show diff stats
features/blog.feature
... | ... | @@ -124,7 +124,7 @@ Feature: blog |
124 | 124 | Then I should not see "Delete cover image" |
125 | 125 | |
126 | 126 | # the step for attaching a file on the input only works with capybara 1.1.2, but it requires rails 1.9.3 |
127 | - @selenium-fixme | |
127 | + @selenium | |
128 | 128 | Scenario: display cover image after uploading an image as the blog cover |
129 | 129 | Given the following blogs |
130 | 130 | | owner | name | | ... | ... |
... | ... | @@ -0,0 +1,238 @@ |
1 | +Feature: uploads items on media panel | |
2 | + As a noosfero user | |
3 | + I want to uploads items when creating or editing articles | |
4 | + | |
5 | + Background: | |
6 | + Given the following users | |
7 | + | login | name | | |
8 | + | joaosilva | Joao Silva | | |
9 | + And feature "media_panel" is enabled on environment | |
10 | + And I am logged in as "joaosilva" | |
11 | + And I am on /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
12 | + | |
13 | + Scenario: see media panel collapsed | |
14 | + Then I should see "Insert media" | |
15 | + And I should not see an element ".show-media-panel" | |
16 | + | |
17 | + @selenium | |
18 | + Scenario: expand media panel | |
19 | + When I follow "Show/Hide" | |
20 | + Then I should see an element ".show-media-panel" | |
21 | + | |
22 | + @selenium | |
23 | + Scenario: upload file showing percentage and name | |
24 | + When I follow "Show/Hide" | |
25 | + And I attach the file "public/images/rails.png" to "file" | |
26 | + Then I should see "100%" | |
27 | + And I should see "rails.png" | |
28 | + | |
29 | + @selenium | |
30 | + Scenario: upload multiple files | |
31 | + When I follow "Show/Hide" | |
32 | + And I attach the file "public/images/rails.png" to "file" | |
33 | + And I attach the file "public/503.jpg" to "file" | |
34 | + Then I should see "rails.png" within "#file-1" | |
35 | + And I should see "503.jpg" within "#file-2" | |
36 | + | |
37 | + @selenium | |
38 | + Scenario: show error when upload fails | |
39 | + When I follow "Show/Hide" | |
40 | + And I attach the file "public/images/rails.png" to "file" | |
41 | + # uploads the same file twice to induce error (unique name validation) | |
42 | + And I attach the file "public/images/rails.png" to "file" | |
43 | + Then I should see "rails.png" within "#file-1" | |
44 | + And I should see "100%" within "#file-1" | |
45 | + But I should see "Validation failed: Slug The title (article name) is already being used by another article, please use another title." within "#file-2" | |
46 | + And The page should contain "div.error-message" | |
47 | + | |
48 | + @selenium | |
49 | + Scenario: select destination folder | |
50 | + When I follow "Show/Hide" | |
51 | + And I attach the file "public/images/rails.png" to "file" | |
52 | + And I select "joaosilva" from "parent_id" within "#media-upload-form" | |
53 | + And I attach the file "public/503.jpg" to "file" | |
54 | + And I go to joaosilva's cms | |
55 | + Then I should not see "rails.png" | |
56 | + But I should see "503.jpg" | |
57 | + When I follow "Gallery" | |
58 | + Then I should see "rails.png" | |
59 | + But I should not see "503.jpg" | |
60 | + | |
61 | + @selenium | |
62 | + Scenario: create new folder with parent | |
63 | + Given I follow "Show/Hide" | |
64 | + And I should see "joaosilva" within "#media-upload-form" | |
65 | + And I should see "joaosilva/Gallery" within "#media-upload-form" | |
66 | + And I should see "joaosilva" within "#published-media" | |
67 | + And I should see "joaosilva/Gallery" within "#published-media" | |
68 | + | |
69 | + When I follow "New folder" | |
70 | + And I select "joaosilva" from "parent_id" within "#new-folder-dialog" | |
71 | + And I fill in "Name" with "Main folder" within "#new-folder-dialog" | |
72 | + And I press "Create" | |
73 | + Then I should see "joaosilva" within "#media-upload-form" | |
74 | + And I should see "joaosilva/Gallery" within "#media-upload-form" | |
75 | + And I should see "joaosilva/Main folder" within "#media-upload-form" | |
76 | + And "joaosilva/Main folder" should be selected for "parent_id" within "#media-upload-form" | |
77 | + And I should see "joaosilva" within "#published-media" | |
78 | + And I should see "joaosilva/Gallery" within "#published-media" | |
79 | + And I should see "joaosilva/Main folder" within "#published-media" | |
80 | + | |
81 | + When I follow "New folder" | |
82 | + And I select "joaosilva/Gallery" from "parent_id" within "#new-folder-dialog" | |
83 | + And I fill in "Name" with "Gallery folder" within "#new-folder-dialog" | |
84 | + And I press "Create" | |
85 | + Then I should see "joaosilva" within "#media-upload-form" | |
86 | + And I should see "joaosilva/Gallery" within "#media-upload-form" | |
87 | + And I should see "joaosilva/Main folder" within "#media-upload-form" | |
88 | + And I should see "joaosilva/Gallery/Gallery folder" within "#media-upload-form" | |
89 | + And "joaosilva/Gallery/Gallery folder" should be selected for "parent_id" within "#media-upload-form" | |
90 | + And I should see "joaosilva" within "#published-media" | |
91 | + And I should see "joaosilva/Gallery" within "#published-media" | |
92 | + And I should see "joaosilva/Main folder" within "#published-media" | |
93 | + And I should see "joaosilva/Gallery/Gallery folder" within "#published-media" | |
94 | + | |
95 | + @selenium | |
96 | + Scenario: select type when create new folder | |
97 | + When I follow "Show/Hide" | |
98 | + And I follow "New folder" | |
99 | + And I choose "Folder" within "#new-folder-dialog" | |
100 | + And I fill in "Name" with "Main new folder" within "#new-folder-dialog" | |
101 | + And I press "Create" | |
102 | + Then I should see "joaosilva/Gallery/Main new folder" within "#parent_id" | |
103 | + When I follow "New folder" | |
104 | + And I choose "Gallery" within "#new-folder-dialog" | |
105 | + And I fill in "Name" with "Gallery new folder" within "#new-folder-dialog" | |
106 | + And I press "Create" | |
107 | + And I go to joaosilva's cms | |
108 | + And I follow "Gallery" | |
109 | + Then I should see "Folder" within "tr[title='Main new folder'] td.article-mime" | |
110 | + And I should see "Gallery" within "tr[title='Gallery new folder'] td.article-mime" | |
111 | + | |
112 | + @selenium | |
113 | + Scenario: hide and show upload list | |
114 | + When I follow "Show/Hide" | |
115 | + And I attach the file "public/images/rails.png" to "file" | |
116 | + And I attach the file "public/503.jpg" to "file" | |
117 | + And I follow "Hide all uploads" | |
118 | + Then I should not see "503.jpg" | |
119 | + And I should not see "rails.png" | |
120 | + When I follow "Show all uploads" | |
121 | + Then I should see "503.jpg" | |
122 | + And I should see "rails.png" | |
123 | + | |
124 | + @selenium | |
125 | + Scenario: update recent media after file upload | |
126 | + Given the following files | |
127 | + | owner | file | mime | | |
128 | + | joaosilva | other-pic.jpg | image/jpeg | | |
129 | + When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
130 | + And I follow "Show/Hide" | |
131 | + And I select "Recent media" from "parent_id" within "#published-media" | |
132 | + Then I should see div with title "other-pic.jpg" within ".items" | |
133 | + When I select "joaosilva" from "parent_id" within "#media-upload-form" | |
134 | + And I attach the file "public/503.jpg" to "file" | |
135 | + Then I should see div with title "503.jpg" within ".items" | |
136 | + And I should see div with title "other-pic.jpg" within ".items" | |
137 | + When I select "joaosilva/Gallery" from "parent_id" within "#media-upload-form" | |
138 | + And I attach the file "public/images/rails.png" to "file" | |
139 | + And I attach the file "public/robots.txt" to "file" | |
140 | + Then I should see div with title "rails.png" within ".items" | |
141 | + And I should see div with title "503.jpg" within ".items" | |
142 | + And I should see div with title "other-pic.jpg" within ".items" | |
143 | + And I should see "robots.txt" link | |
144 | + | |
145 | + @selenium | |
146 | + Scenario: select folder to show items | |
147 | + Given the following galleries | |
148 | + | owner | name | | |
149 | + | joaosilva | other-gallery | | |
150 | + And the following files | |
151 | + | owner | file | mime | parent | | |
152 | + | joaosilva | rails.png | image/png | other-gallery | | |
153 | + | joaosilva | other-pic.jpg | image/jpeg | gallery | | |
154 | + When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
155 | + And I follow "Show/Hide" | |
156 | + And I select "joaosilva/Gallery" from "parent_id" within "#published-media" | |
157 | + Then I should see div with title "other-pic.jpg" within ".items" | |
158 | + And I should not see div with title "rails.png" within ".items" | |
159 | + When I select "joaosilva/other-gallery" from "parent_id" within "#published-media" | |
160 | + Then I should see div with title "rails.png" within ".items" | |
161 | + And I should not see div with title "other-pic.jpg" within ".items" | |
162 | + | |
163 | + @selenium | |
164 | + Scenario: update selected folder content when upload file to same folder | |
165 | + Given the following galleries | |
166 | + | owner | name | | |
167 | + | joaosilva | other-gallery | | |
168 | + And the following files | |
169 | + | owner | file | mime | parent | | |
170 | + | joaosilva | other-pic.jpg | image/jpeg | gallery | | |
171 | + When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
172 | + And I follow "Show/Hide" | |
173 | + And I select "joaosilva/Gallery" from "parent_id" within "#published-media" | |
174 | + And I select "joaosilva/Gallery" from "parent_id" within "#media-upload-form" | |
175 | + And I attach the file "public/503.jpg" to "file" | |
176 | + Then I should see div with title "other-pic.jpg" within ".items" | |
177 | + And I should see div with title "503.jpg" within ".items" | |
178 | + | |
179 | + When I select "joaosilva/other-gallery" from "parent_id" within "#media-upload-form" | |
180 | + And I attach the file "public/robots.txt" to "file" | |
181 | + Then I should see div with title "other-pic.jpg" within ".items" | |
182 | + And I should see div with title "503.jpg" within ".items" | |
183 | + And I should not see "robots.txt" within ".items" | |
184 | + | |
185 | + @selenium | |
186 | + Scenario: filter media with search | |
187 | + Given the following galleries | |
188 | + | owner | name | | |
189 | + | joaosilva | other-gallery | | |
190 | + And the following files | |
191 | + | owner | file | mime | parent | | |
192 | + | joaosilva | rails.png | image/png | other-gallery | | |
193 | + When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
194 | + And I follow "Show/Hide" | |
195 | + And I select "Recent media" from "parent_id" within "#published-media" | |
196 | + And I fill in "Search" with "rails" within "#published-media" | |
197 | + Then I should see div with title "rails.png" within ".items" | |
198 | + When I select "joaosilva/Gallery" from "parent_id" within "#published-media" | |
199 | + And I fill in "Search" with "rails" within "#published-media" | |
200 | + Then I should not see div with title "rails.png" within ".items" | |
201 | + When I select "joaosilva/other-gallery" from "parent_id" within "#published-media" | |
202 | + And I fill in "Search" with "rails" within "#published-media" | |
203 | + Then I should see div with title "rails.png" within ".items" | |
204 | + | |
205 | + @selenium | |
206 | + Scenario: separete images from non-images | |
207 | + When I follow "Show/Hide" | |
208 | + Then I should not see "Images" | |
209 | + And I should not see "Files" | |
210 | + When I attach the file "public/robots.txt" to "file" | |
211 | + And I attach the file "public/images/rails.png" to "file" | |
212 | + Then I should see "Files" | |
213 | + And I should see "robots.txt" within ".generics" | |
214 | + But I should not see "rails.png" within ".generics" | |
215 | + And I should see "Images" | |
216 | + And I should see div with title "rails.png" within ".images" | |
217 | + But I should not see div with title "robots.txt" within ".images" | |
218 | + | |
219 | + @selenium | |
220 | + Scenario: view all media button if there are too many uploads | |
221 | + Given the following galleries | |
222 | + | owner | name | | |
223 | + | joaosilva | other-gallery | | |
224 | + | joaosilva | my-gallery | | |
225 | + And the following files | |
226 | + | owner | file | mime | parent | | |
227 | + | joaosilva | rails.png | image/png | other-gallery | | |
228 | + | joaosilva | other-pic.jpg | image/jpeg | other-gallery | | |
229 | + | joaosilva | rails.png | image/png | my-gallery | | |
230 | + | joaosilva | other-pic.jpg | image/jpeg | my-gallery | | |
231 | + | joaosilva | rails.png | image/png | gallery | | |
232 | + | joaosilva | other-pic.jpg | image/jpeg | gallery | | |
233 | + When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle | |
234 | + And I follow "Show/Hide" | |
235 | + And I should not see "View all" | |
236 | + And I attach the file "public/503.jpg" to "file" | |
237 | + Then I should see "View all" link | |
238 | + And I should see div with title "503.jpg" within ".images" | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +Then /^I should (not )?see an element "([^"]*)"$/ do |negate, selector| | |
2 | + expectation = negate ? :should_not : :should | |
3 | + page.html.send(expectation, have_css(selector)) | |
4 | +end | |
5 | + | |
6 | +Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector| | |
7 | + with_scope(selector) do | |
8 | + field_labeled(field).find(:xpath, ".//option[@selected = 'selected'][text() = '#{value}']").should be_present | |
9 | + end | |
10 | +end | |
11 | + | |
12 | +Then /^(?:|I )should see div with title "([^"]*)"(?: within "([^"]*)")?$/ do |name, selector| | |
13 | + with_scope(selector) do | |
14 | + if page.respond_to? :should | |
15 | + page.should have_xpath(".//div[@title='#{name}']") | |
16 | + else | |
17 | + assert page.has_xpath?(".//div[@title='#{name}']") | |
18 | + end | |
19 | + end | |
20 | +end | |
21 | + | |
22 | +Then /^(?:|I )should not see div with title "([^"]*)"(?: within "([^"]*)")?$/ do |name, selector| | |
23 | + with_scope(selector) do | |
24 | + if page.respond_to? :should | |
25 | + page.should have_no_xpath(".//div[@title='#{name}']") | |
26 | + else | |
27 | + assert page.has_no_xpath?(".//div[@title='#{name}']") | |
28 | + end | |
29 | + end | |
30 | +end | ... | ... |
features/step_definitions/web_steps.rb
... | ... | @@ -99,6 +99,7 @@ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector| |
99 | 99 | end |
100 | 100 | |
101 | 101 | When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector| |
102 | + path = File.expand_path(path).gsub('/', File::ALT_SEPARATOR || File::SEPARATOR) | |
102 | 103 | with_scope(selector) do |
103 | 104 | attach_file(field, path) |
104 | 105 | end |
... | ... | @@ -252,7 +253,7 @@ Then /^display "([^\"]*)"$/ do |element| |
252 | 253 | end |
253 | 254 | |
254 | 255 | Then /^there should be a div with class "([^"]*)"$/ do |klass| |
255 | - should have_selector('div', :class => klass) | |
256 | + should have_selector("div.#{klass}") | |
256 | 257 | end |
257 | 258 | |
258 | 259 | When /^(?:|I )follow exact "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector| | ... | ... |