|
| 1 | +require "json" |
| 2 | +require "selenium-webdriver" |
| 3 | +require "rspec" |
| 4 | +require "./spec-views/helper.rb" |
| 5 | +require "./spec-views/before.rb" |
| 6 | +require "./spec-views/after.rb" |
| 7 | +require "./spec-views/user.rb" |
| 8 | +include RSpec::Expectations |
| 9 | + |
| 10 | +include Before |
| 11 | +include After |
| 12 | + |
| 13 | +describe "Collection Creation Form" do |
| 14 | + |
| 15 | + setup |
| 16 | + |
| 17 | + teardown |
| 18 | + |
| 19 | + it "form is up and new collection is created" do |
| 20 | + @driver.get(@base_url + "/") |
| 21 | + @driver.find_element(:link, "Login").click |
| 22 | + verify { (@driver.current_url).should == @base_url+"/users/sign_in"} |
| 23 | + @driver.find_element(:id, "user_email").clear |
| 24 | + @driver.find_element(:id, "user_email").send_keys @properties['admin']['name'] |
| 25 | + @driver.find_element(:id, "user_password").clear |
| 26 | + @driver.find_element(:id, "user_password").send_keys @properties['admin']['password'] |
| 27 | + @driver.find_element(:name, "commit").click |
| 28 | + @driver.get(@base_url + "/") |
| 29 | + |
| 30 | + @driver.find_element(:id, "dashboard_link").click |
| 31 | + @driver.find_element(:id, "hydra-collection-add").click |
| 32 | + |
| 33 | + verify { @driver.current_url.should == @base_url+"/collections/new" } |
| 34 | + verify { @driver.find_element(:xpath, "//label[@for = 'collection_title']/abbr[@title = 'required']").displayed? == true } |
| 35 | + title = @driver.find_element(:id, "collection_title") |
| 36 | + title.clear |
| 37 | + title.send_keys("Test Collection from Selenium") |
| 38 | + @driver.find_element(:id, "collection_creator").send_keys @properties['user1']['name'] |
| 39 | + @driver.find_element(:id, "collection_description").send_keys "Test description for the test collection." |
| 40 | + |
| 41 | + select_license = @driver.find_element(:id, "collection_license") |
| 42 | + option = Selenium::WebDriver::Support::Select.new(select_license) |
| 43 | + option.select_by(:text, "Public Domain Mark 1.0") |
| 44 | + verify { @driver.find_element(:xpath, "//label[@for = 'collection_license']/abbr[@title = 'required']").displayed? == true } |
| 45 | + @driver.find_element(:id, "create_submit").click |
| 46 | + |
| 47 | + verify { @driver.current_url.should include @base_url + "/collections/" } |
| 48 | + collection_id = @driver.current_url.match(/#{@base_url}\/collections\/(.*)$/)[1] |
| 49 | + verify { (@driver.find_element(:class, "alert-success").text).should include "Collection was successfully created."} |
| 50 | + verify { @driver.find_element(:css, "h1").text.should == "Test Collection from Selenium" } |
| 51 | + verify { @driver.find_element(:class, "collection_description").text.should == "Test description for the test collection." } |
| 52 | + verify { @driver.find_element(:xpath, "//span[@itemprop = 'creator']/span/a").text.should == @properties['user1']['name'] } |
| 53 | + |
| 54 | + verify { @driver.find_element(:xpath, "//span[@itemprop = 'total_items']").text.should == "0" } |
| 55 | + verify { @driver.find_element(:xpath, "//dt[contains(text(), 'License')]/following-sibling::dd/a").text.should == "Public Domain Mark 1.0" } |
| 56 | + @driver.find_element(:link, "My Collections").click |
| 57 | + verify { @driver.current_url.should == @base_url + "/dashboard/collections" } |
| 58 | + collection = @driver.find_element(:id, "document_"+collection_id) |
| 59 | + collection.find_element(:id, "dropdownMenu_"+collection_id).click |
| 60 | + delete = "//ul[@aria-labelledby = 'dropdownMenu_"+collection_id+"']//a[@title='Delete Collection']" |
| 61 | + collection.find_element(:xpath, delete).click |
| 62 | + @driver.switch_to.alert.accept |
| 63 | + end |
| 64 | + |
| 65 | +end |
| 66 | + |
| 67 | + |
0 commit comments