sambal-cle 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. data/README.md +4 -0
  2. data/lib/sambal-cle/base_page.rb +20 -0
  3. data/lib/sambal-cle/core-ext.rb +90 -0
  4. data/lib/sambal-cle/data_objects/announcement.rb +82 -0
  5. data/lib/sambal-cle/data_objects/assessment.rb +32 -0
  6. data/lib/sambal-cle/data_objects/assignment.rb +205 -0
  7. data/lib/sambal-cle/data_objects/blog.rb +46 -0
  8. data/lib/sambal-cle/data_objects/blogger.rb +49 -0
  9. data/lib/sambal-cle/data_objects/chat_room.rb +54 -0
  10. data/lib/sambal-cle/data_objects/event.rb +89 -0
  11. data/lib/sambal-cle/data_objects/forum.rb +212 -0
  12. data/lib/sambal-cle/data_objects/lesson.rb +185 -0
  13. data/lib/sambal-cle/data_objects/message.rb +57 -0
  14. data/lib/sambal-cle/data_objects/poll.rb +74 -0
  15. data/lib/sambal-cle/data_objects/resource.rb +209 -0
  16. data/lib/sambal-cle/data_objects/site.rb +295 -0
  17. data/lib/sambal-cle/data_objects/syllabus.rb +73 -0
  18. data/lib/sambal-cle/data_objects/web_content_tool.rb +51 -0
  19. data/lib/sambal-cle/data_objects/wiki.rb +63 -0
  20. data/lib/sambal-cle/date_makers.rb +118 -0
  21. data/lib/sambal-cle/gem_ext.rb +23 -0
  22. data/lib/sambal-cle/page_helper.rb +22 -0
  23. data/lib/sambal-cle/page_maker.rb +48 -0
  24. data/lib/sambal-cle/page_objects/account.rb +111 -0
  25. data/lib/sambal-cle/page_objects/aliases.rb +43 -0
  26. data/lib/sambal-cle/page_objects/announcements.rb +190 -0
  27. data/lib/sambal-cle/page_objects/assessments.rb +874 -0
  28. data/lib/sambal-cle/page_objects/assignments.rb +770 -0
  29. data/lib/sambal-cle/page_objects/basic_lti.rb +6 -0
  30. data/lib/sambal-cle/page_objects/blogger.rb +205 -0
  31. data/lib/sambal-cle/page_objects/blogs.rb +60 -0
  32. data/lib/sambal-cle/page_objects/calendar.rb +330 -0
  33. data/lib/sambal-cle/page_objects/calendar_summary.rb +1 -0
  34. data/lib/sambal-cle/page_objects/chat_room.rb +22 -0
  35. data/lib/sambal-cle/page_objects/drop_box.rb +9 -0
  36. data/lib/sambal-cle/page_objects/email_archive.rb +22 -0
  37. data/lib/sambal-cle/page_objects/entity_picker.rb +62 -0
  38. data/lib/sambal-cle/page_objects/evaluations.rb +158 -0
  39. data/lib/sambal-cle/page_objects/feedback.rb +36 -0
  40. data/lib/sambal-cle/page_objects/forms.rb +120 -0
  41. data/lib/sambal-cle/page_objects/forums.rb +254 -0
  42. data/lib/sambal-cle/page_objects/glossary.rb +117 -0
  43. data/lib/sambal-cle/page_objects/gradebook.rb +29 -0
  44. data/lib/sambal-cle/page_objects/gradebook2.rb +17 -0
  45. data/lib/sambal-cle/page_objects/home.rb +36 -0
  46. data/lib/sambal-cle/page_objects/jforums.rb +444 -0
  47. data/lib/sambal-cle/page_objects/job_scheduler.rb +121 -0
  48. data/lib/sambal-cle/page_objects/lessons.rb +361 -0
  49. data/lib/sambal-cle/page_objects/login.rb +28 -0
  50. data/lib/sambal-cle/page_objects/matrix.rb +241 -0
  51. data/lib/sambal-cle/page_objects/media_gallery.rb +13 -0
  52. data/lib/sambal-cle/page_objects/messages.rb +622 -0
  53. data/lib/sambal-cle/page_objects/my_workspace.rb +44 -0
  54. data/lib/sambal-cle/page_objects/news.rb +8 -0
  55. data/lib/sambal-cle/page_objects/podcasts.rb +27 -0
  56. data/lib/sambal-cle/page_objects/polls.rb +69 -0
  57. data/lib/sambal-cle/page_objects/portfolio_templates.rb +161 -0
  58. data/lib/sambal-cle/page_objects/portfolios.rb +162 -0
  59. data/lib/sambal-cle/page_objects/post_em.rb +1 -0
  60. data/lib/sambal-cle/page_objects/profile.rb +51 -0
  61. data/lib/sambal-cle/page_objects/profile2.rb +344 -0
  62. data/lib/sambal-cle/page_objects/public_search.rb +61 -0
  63. data/lib/sambal-cle/page_objects/realms.rb +19 -0
  64. data/lib/sambal-cle/page_objects/resources.rb +326 -0
  65. data/lib/sambal-cle/page_objects/resources_roster.rb +0 -0
  66. data/lib/sambal-cle/page_objects/rosters.rb +70 -0
  67. data/lib/sambal-cle/page_objects/rwiki.rb +34 -0
  68. data/lib/sambal-cle/page_objects/search.rb +34 -0
  69. data/lib/sambal-cle/page_objects/sections.rb +295 -0
  70. data/lib/sambal-cle/page_objects/single_user.rb +1 -0
  71. data/lib/sambal-cle/page_objects/site_setup.rb +621 -0
  72. data/lib/sambal-cle/page_objects/site_statistics.rb +1 -0
  73. data/lib/sambal-cle/page_objects/sites.rb +255 -0
  74. data/lib/sambal-cle/page_objects/styles.rb +74 -0
  75. data/lib/sambal-cle/page_objects/syllabus.rb +166 -0
  76. data/lib/sambal-cle/page_objects/user_membership.rb +57 -0
  77. data/lib/sambal-cle/page_objects/users.rb +88 -0
  78. data/lib/sambal-cle/randomizers.rb +117 -0
  79. data/lib/sambal-cle/rich_text.rb +38 -0
  80. data/lib/sambal-cle/utilities.rb +31 -0
  81. data/lib/sambal-cle/workflows.rb +223 -0
  82. data/lib/sambal-cle.rb +31 -0
  83. data/sambal-cle.gemspec +14 -0
  84. data/test/add_assignment_to_calendar_spec.rb +86 -0
  85. data/test/assignment_announcements_spec.rb +71 -0
  86. data/test/assignment_gradebook_spec.rb +98 -0
  87. data/test/config.yml.template +4 -0
  88. data/test/directory.yml.template +123 -0
  89. data/test/duplicate_site_spec.rb +244 -0
  90. metadata +167 -0
@@ -0,0 +1,326 @@
1
+ #================
2
+ # Resources Pages
3
+ #================
4
+
5
+ # This class consolidates the code that can be shared among all the
6
+ # File Upload and Attachment pages.
7
+ #
8
+ # Not every method in this class will be appropriate for every attachment page.
9
+ class ResourcesBase < BasePage
10
+
11
+ frame_element
12
+
13
+ element(:files_table) { |b| b.frm.table(:class=>/listHier lines/) }
14
+
15
+ # Returns an array of the displayed folder names.
16
+ def folder_names
17
+ names = []
18
+ files_table.rows.each do |row|
19
+ next if row.td(:class=>"specialLink").exist? == false
20
+ next if row.td(:class=>"specialLink").link(:title=>"Folder").exist? == false
21
+ names << row.td(:class=>"specialLink").link(:title=>"Folder").text
22
+ end
23
+ names
24
+ end
25
+
26
+ # Returns an array of the file names currently listed
27
+ # on the page.
28
+ #
29
+ # It excludes folder names.
30
+ def file_names
31
+ names = []
32
+ files_table.rows.each do |row|
33
+ next if row.td(:class=>"specialLink").exist? == false
34
+ next if row.td(:class=>"specialLink").link(:title=>"Folder").exist?
35
+ names << row.td(:class=>"specialLink").link(:href=>/access.content/, :index=>1).text
36
+ end
37
+ names
38
+ end
39
+
40
+ # Use this as a means of checking if the file is visible or not
41
+ def item(name)
42
+ frm.link(:text=>name)
43
+ end
44
+
45
+ # Clicks the Select button next to the specified file.
46
+ def select_file(filename)
47
+ files_table.row(:text, /#{Regexp.escape(filename)}/).link(:text=>"Select").click
48
+ end
49
+
50
+ # Clicks the Remove button.
51
+ action(:remove) { |b| b.frm.button(:value=>"Remove").click }
52
+
53
+ # Clicks the remove link for the specified item in the attachment list.
54
+ def remove_item(file_name)
55
+ files_table.row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doRemoveitem/).click
56
+ end
57
+
58
+ # Clicks the Move button.
59
+ action(:move) { |b| b.frm.button(:value=>"Move").click }
60
+
61
+ # Clicks the Show Other Sites link.
62
+ action(:show_other_sites) { |b| b.frm.link(:text=>"Show other sites").click }
63
+
64
+ def href(item)
65
+ frm.link(:text=>item).href
66
+ end
67
+
68
+ # Clicks on the specified folder image, which
69
+ # will open the folder tree and remain on the page.
70
+ def open_folder(foldername)
71
+ files_table.row(:text=>/#{Regexp.escape(foldername)}/).link(:title=>"Open this folder").click
72
+ end
73
+
74
+ # Clicks on the specified folder name, which should open
75
+ # the folder contents on a refreshed page.
76
+ def go_to_folder(foldername)
77
+ frm.link(:text=>foldername).click
78
+ end
79
+
80
+ # Sets the URL field to the specified value.
81
+ def url=(url_string)
82
+ frm.text_field(:id=>"url").set(url_string)
83
+ end
84
+
85
+ # Clicks the Add button next to the URL field.
86
+ action(:add) { |b| b.frm.button(:value=>"Add").click }
87
+
88
+ # Gets the value of the access level cell for the specified
89
+ # file.
90
+ def access_level(filename)
91
+ files_table.row(:text=>/#{Regexp.escape(filename)}/)[6].text
92
+ end
93
+
94
+ def edit_details(name)
95
+ open_actions_menu(name)
96
+ files_table.row(:text=>/#{Regexp.escape(name)}/).link(:text=>"Edit Details").click
97
+ end
98
+
99
+ def edit_content(html_page_name)
100
+ open_actions_menu(html_page_name)
101
+ files_table.row(:text=>/#{Regexp.escape(html_page_name)}/).link(:text=>"Edit Content").click
102
+ end
103
+
104
+ # Clicks the Create Folders menu item in the
105
+ # Add menu of the specified folder.
106
+ def create_subfolders_in(folder_name)
107
+ open_add_menu(folder_name)
108
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create Folders").click
109
+ end
110
+
111
+ def create_html_page_in(folder_name)
112
+ open_add_menu(folder_name)
113
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create HTML Page").click
114
+ end
115
+
116
+ element(:upload_file_field) { |b| b.frm.file_field(:id=>"upload") }
117
+
118
+ # Enters the specified file into the file field name (assuming it's in the
119
+ # data/sakai-cle-test-api folder or a subfolder therein)
120
+ #
121
+ def upload_file(filename, filepath="")
122
+ upload_file_field.set(filepath + filename)
123
+ if frm.div(:class=>"alertMessage").exist?
124
+ sleep 2
125
+ upload_file(filename)
126
+ end
127
+ end
128
+
129
+ # Enters the specified file into the file field name (assuming it's in the
130
+ # data/sakai-cle-test-api folder or a subfolder therein)
131
+ #
132
+ # Use this method ONLY for instances where there's a file field on the page
133
+ # with an "upload" id.
134
+ def upload_local_file(filename, filepath="")
135
+ upload_file_field.set(filepath + filename)
136
+ if frm.div(:class=>"alertMessage").exist?
137
+ sleep 2
138
+ upload_local_file(filename)
139
+ end
140
+ end
141
+
142
+ # Clicks the Add Menu for the specified
143
+ # folder, then selects the Upload Files
144
+ # command in the menu that appears.
145
+ def upload_files_to_folder(folder_name)
146
+ if frm.li(:text=>/A/, :class=>"menuOpen").exist?
147
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).li(:text=>/A/, :class=>"menuOpen").fire_event("onclick")
148
+ else
149
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus")
150
+ end
151
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Upload Files").click
152
+ end
153
+ alias upload_file_to_folder upload_files_to_folder
154
+
155
+ # Clicks the "Attach a copy" link for the specified
156
+ # file, then reinstantiates the Class.
157
+ # If an alert box appears, the method will call itself again.
158
+ # Note that this can lead to an infinite loop. Will need to fix later.
159
+ def attach_a_copy(file_name)
160
+ files_table.row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doAttachitem/).click
161
+ if frm.div(:class=>"alertMessage").exist?
162
+ sleep 1
163
+ attach_a_copy(file_name) # TODO - This can loop infinitely
164
+ end
165
+ end
166
+
167
+ # Takes the specified array object containing pointers
168
+ # to local file resources, then uploads those files to
169
+ # the folder specified, checks if they all uploaded properly and
170
+ # if not, re-tries the ones that failed the first time.
171
+ #
172
+ # Finally, it re-instantiates the appropriate page class.
173
+ # Note that it expects all files to be located in the same folder (can be in subfolders of that folder).
174
+ def upload_multiple_files_to_folder(folder, file_array, file_path="")
175
+
176
+ upload = upload_files_to_folder folder
177
+
178
+ file_array.each do |file|
179
+ upload.file_to_upload(file, file_path)
180
+ upload.add_another_file
181
+ end
182
+
183
+ resources = upload.upload_files_now
184
+
185
+ file_array.each do |file|
186
+ file =~ /(?<=\/).+/
187
+ # puts $~.to_s # For debugging purposes
188
+ unless resources.file_names.include?($~.to_s)
189
+ upload_files = resources.upload_files_to_folder(folder)
190
+ upload_files.file_to_upload(file, file_path)
191
+ upload_files.upload_files_now
192
+ end
193
+ end
194
+ end
195
+
196
+ # Clicks the Continue button
197
+ def continue
198
+ frm.div(:class=>"highlightPanel").span(:id=>"submitnotifxxx").wait_while_present
199
+ frm.button(:value=>"Continue").click
200
+ end
201
+
202
+ def open_add_menu(folder_name)
203
+ files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus")
204
+ end
205
+
206
+ def open_actions_menu(name)
207
+ files_table.row(:text=>/#{Regexp.escape(name)}/).li(:text=>/Action/, :class=>"menuOpen").fire_event("onclick")
208
+ end
209
+
210
+ end
211
+
212
+ # Resources page for a given Site, in the Course Tools menu
213
+ class Resources < ResourcesBase
214
+
215
+
216
+
217
+ end
218
+
219
+ class ResourcesUploadFiles < ResourcesBase
220
+
221
+ @@filex=0 # TODO: This is almost certainly not going to work right.
222
+
223
+ # Enters the specified folder/filename value into
224
+ # the file field on the page.
225
+ # The method will throw an error if the specified file
226
+ # is not found.
227
+ #
228
+ # This method is designed to be able to use
229
+ # multiple times, but it assumes
230
+ # that the add_another_file method is used
231
+ # before it, every time except before the first time.
232
+ def file_to_upload(file_name, file_path="")
233
+ frm.file_field(:id, "content_#{@@filex}").set(file_path + file_name)
234
+ @@filex+=1
235
+ end
236
+
237
+ # Clicks the Upload Files Now button, resets the
238
+ # @@filex class variable back to zero, and instantiates
239
+ # the Resources page class.
240
+ def upload_files_now
241
+ frm.button(:value=>"Upload Files Now").click
242
+ @@filex=0
243
+ # Resources.new(@browser)
244
+ end
245
+
246
+ # Clicks the Add Another File link.
247
+ def add_another_file
248
+ frm.link(:text=>"Add Another File").click
249
+ end
250
+
251
+ end
252
+
253
+ class EditFileDetails < ResourcesBase
254
+
255
+ # Clicks the Update button, then instantiates
256
+ # the Resources page class.
257
+ def update
258
+ frm.button(:value=>"Update").click
259
+ Resources.new(@browser)
260
+ end
261
+
262
+ # Enters the specified string into the title field.
263
+ def title=(title)
264
+ frm.text_field(:id=>"displayName_0").set(title)
265
+ end
266
+
267
+ # Enters the specified string into the description field.
268
+ def description=(description)
269
+ frm.text_field(:id=>"description_0").set(description)
270
+ end
271
+
272
+ # Sets the radio button for publically viewable.
273
+ def select_publicly_viewable
274
+ frm.radio(:id=>"access_mode_public_0").set
275
+ end
276
+
277
+ # Checks the checkbox for showing only on the specifed
278
+ # condition.
279
+ def check_show_only_if_condition
280
+ frm.checkbox(:id=>"cbCondition_0")
281
+ end
282
+
283
+ # Selects the specified Gradebook item value in the
284
+ # select list.
285
+ def gradebook_item=(item)
286
+ frm.select(:id=>"selectResource_0").select(item)
287
+ end
288
+
289
+ # Selects the specified value in the item condition
290
+ # field.
291
+ def item_condition=(condition)
292
+ frm.select(:id=>"selectCondition_0").select(condition)
293
+ end
294
+
295
+ # Sets the Grade field to the specified value.
296
+ def assignment_grade=(grade)
297
+ frm.text_field(:id=>"assignment_grade_0").set(grade)
298
+ end
299
+ end
300
+
301
+ class CreateFolders < ResourcesBase
302
+
303
+ thing(:folder_name) { |b| b.frm.text_field(:id=>"content_0") }
304
+ action(:create_folders_now) { |b| b.frm.button(:value=>"Create Folders Now").click }
305
+
306
+ end
307
+
308
+ class EditHTMLPageContent < BasePage
309
+
310
+ frame_element
311
+ include FCKEditor
312
+
313
+ thing(:editor) { |b| b.frm.frame(:id=>"content___Frame") }
314
+ action(:continue) { |b| b.frm.button(id: "saveChanges").click }
315
+ element(:email_notification) { |b| b.frm.select(:id=>"notify") }
316
+
317
+ end
318
+
319
+ class EditHTMLPageProperties < ResourcesBase
320
+
321
+ thing(:name) { |b| b.frm.text_field(id: "displayName_0") }
322
+ thing(:description) { |b| b.frm.text_field(id: "description_0") }
323
+
324
+ action(:finish) { |b| b.frm.button(id: "finish_button").click }
325
+
326
+ end
File without changes
@@ -0,0 +1,70 @@
1
+ #================
2
+ # Roster Pages for a Site
3
+ #================
4
+
5
+ #
6
+ class Roster < BasePage
7
+
8
+ frame_element
9
+
10
+ def find
11
+ frm.button(:value=>"Find").click
12
+ Roster.new @browser
13
+ end
14
+
15
+ def names
16
+ list = []
17
+ frm.table(:id=>"roster_form:rosterTable").rows.each do |row|
18
+ list << row[0].text
19
+ end
20
+ list.delete_at(0)
21
+ return list
22
+ end
23
+
24
+ # Clicks on the link on the page that matches the specified name.
25
+ # Then instantiates the RosterProfileView class.
26
+ # Note that it expects an exact match for the name string, otherwise
27
+ # the script will error out.
28
+ def view(name)
29
+ frm.link(:text=>name).click
30
+ RosterProfileView.new @browser
31
+ end
32
+
33
+
34
+ element(:name_or_id) { |b| b.frm.text_field(:id=>"roster_form:search") }
35
+
36
+ end
37
+
38
+ #
39
+ class RosterProfileView < BasePage
40
+
41
+ frame_element
42
+
43
+ def back
44
+ frm.button(:value=>"Back").click
45
+ Roster.new(@browser)
46
+ end
47
+
48
+ # Returns a hash containing the contents of the Public Information
49
+ # table on the page, with the keys being the row headers and the values
50
+ # being the row's data contents.
51
+ def public_information
52
+ hash = {}
53
+ frm.table(:class=>"chefEditItem", :index=>0).rows.each do |row|
54
+ hash.store(row[0].text, row[1].text)
55
+ end
56
+ return hash
57
+ end
58
+
59
+ # Returns a hash containing the contents of the Personal Information
60
+ # table on the page, with the keys being the row headers and the values
61
+ # being the row's data contents.
62
+ def personal_information
63
+ hash = {}
64
+ frm.table(:class=>"chefEditItem", :index=>1).rows.each do |row|
65
+ hash.store(row[0].text, row[1].text)
66
+ end
67
+ return hash
68
+ end
69
+
70
+ end
@@ -0,0 +1,34 @@
1
+ class RwikiBase < BasePage
2
+
3
+ frame_element
4
+ class << self
5
+ def menu_elements
6
+ action(:home) { |b| b.frm.link(id: "homelink").click }
7
+ action(:view) { |b| b.frm.link(id: "viewLink").click }
8
+ action(:edit) { |b| b.frm.link(id: "editLink").click }
9
+ action(:info) { |b| b.frm.link(id: "infoLink").click }
10
+ action(:history) { |b| b.frm.link(id: "historyLink").click }
11
+ action(:watch) { |b| b.frm.link(id: "watchLink").click }
12
+ element(:search_field) { |b| b.frm.text_field(id: "searchField") }
13
+ element(:rss_link) { |b| b.frm.link(id: "rssLink") }
14
+ end
15
+ end
16
+ end
17
+
18
+ class Rwiki < RwikiBase
19
+
20
+ menu_elements
21
+
22
+ element(:content) { |b| b.frm.text_field(id: "content") }
23
+ action(:save) { |b| b.frm.button(text: "Save").click }
24
+ action(:cancel) { |b| b.frm.button(text: "Cancel").click }
25
+
26
+ def open_wiki(title)
27
+ frm.link(:text=>title).click
28
+ end
29
+
30
+ def wiki_href(title)
31
+ frm.link(:text=>title).href
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+ #================
2
+ # Administrative Search Pages
3
+ #================
4
+
5
+ # The Search page in the Administration Workspace - "icon-sakai-search"
6
+ class Search < BasePage
7
+
8
+ frame_element
9
+
10
+ action(:admin) { |b| b.frm.link(:text=>"Admin").click }
11
+ element(:search_field) { |b| b.frm.text_field(:id=>"search") }
12
+ action(:search_button) { |b| b.frm.button(:name=>"sb").click }
13
+ element(:this_site) { |b| b.frm.radio(:id=>"searchSite") }
14
+ element(:all_my_sites) { |b| b.frm.radio(:id=>"searchMine") }
15
+
16
+ end
17
+
18
+
19
+ # The Search Admin page within the Search page in the Admin workspace
20
+ class SearchAdmin < BasePage
21
+
22
+ frame_element
23
+
24
+ action(:search) { |b| b.frm.link(:text=>"Search").click }
25
+ action(:rebuild_site_index) { |b| b.frm.link(:text=>"Rebuild Site Index").click }
26
+ action(:refresh_site_index) { |b| b.frm.link(:text=>"Refresh Site Index").click }
27
+ action(:rebuild_whole_index) { |b| b.frm.link(:text=>"Rebuild Whole Index").click }
28
+ action(:refresh_whole_index) { |b| b.frm.link(:text=>"Refresh Whole Index").click }
29
+ action(:remove_lock) { |b| b.frm.link(:text=>"Remove Lock").click }
30
+ action(:reload_index) { |b| b.frm.link(:text=>"Reload Index").click }
31
+ action(:enable_diagnostics) { |b| b.frm.link(:text=>"Enable Diagnostics").click }
32
+ action(:disable_diagnostics) { |b| b.frm.link(:text=>"Disable Diagnostics").click }
33
+
34
+ end