Commit 554faa41 authored by flaburgan's avatar flaburgan Committed by Jonne Haß
Browse files

Reorganize steps a bit

parent caf822f4
Loading
Loading
Loading
Loading
+1 −79
Original line number Diff line number Diff line
@@ -61,18 +61,6 @@ And /^I submit the form$/ do
  find("input[type='submit']").click
end

And /^I expand the publisher$/ do
 click_publisher
end

And /^I close the publisher$/ do
  find("#publisher .md-cancel").click
end

Then /^the publisher should be expanded$/ do
  find("#publisher")["class"].should_not include("closed")
end

Then /^the text area wrapper mobile should be with attachments$/ do
  find("#publisher-textarea-wrapper")["class"].should include("with_attachments")
end
@@ -88,48 +76,6 @@ And /^I hover over the "([^"]+)"$/ do |element|
  find("#{element}", match: :first).hover
end

When /^I prepare the deletion of the first post$/ do
  find(".stream .stream-element", match: :first).hover
  within(find(".stream .stream-element", match: :first)) do
    ctrl = find(".control-icons")
    ctrl.hover
    ctrl.find(".remove_post").click
  end
end

When /^I prepare hiding the first post$/ do
  find(".stream .stream-element", match: :first).hover
  within(find(".stream .stream-element", match: :first)) do
    ctrl = find(".control-icons")
    ctrl.hover
    ctrl.find(".hide_post").click
  end
end

When /^I click to delete the first post$/ do
  accept_alert do
    step "I prepare the deletion of the first post"
  end
  expect(find(".stream")).to have_no_css(".stream-element.loaded.deleting")
end

When /^I click to hide the first post$/ do
  accept_alert do
    step "I prepare hiding the first post"
  end
end

When /^I click to delete the first comment$/ do
  within("div.comment", match: :first) do
    find(".comment_delete", visible: false).click
  end
end

When /^I click to delete the first uploaded photo$/ do
  page.execute_script("$('#photodropzone .x').css('display', 'block');")
  find("#photodropzone .x", match: :first).trigger "click"
end

And /^I click on selector "([^"]*)"$/ do |selector|
  find(selector).click
end
@@ -221,15 +167,7 @@ When /^I resize my window to 800x600$/ do
  page.driver.resize(800, 600)
end

Then 'I should see an image attached to the post' do
  step %(I should see a "img" within ".stream-element div.photo-attachments")
end

Then 'I press the attached image' do
  step %(I press the 1st "img" within ".stream-element div.photo-attachments")
end

And "I wait for the popovers to appear" do
And /^I wait for the popovers to appear$/ do
  expect(page).to have_selector(".popover", count: 3)
end

@@ -282,22 +220,6 @@ When /^I focus the "([^"]+)" field$/ do |field|
  find_field(field).click
end

Given /^I have configured a Bitcoin address$/ do
  AppConfig.settings.bitcoin_address = "AAAAAA"
end

Then /^I should see the Bitcoin address$/ do
  find("#bitcoin_address")['value'].should == "AAAAAA"
end

Given /^I have configured a Liberapay username$/ do
  AppConfig.settings.liberapay_username = "BBBBBB"
end

Then /^I should see the Liberapay donate button$/ do
  find("#liberapay-button")["href"].should == "https://liberapay.com/BBBBBB/donate"
end

Given /^"([^"]*)" is hidden$/ do |selector|
  page.should have_selector(selector, visible: false)
  page.should_not have_selector(selector)
+23 −0
Original line number Diff line number Diff line
# frozen_string_literal: true

When /^(?:|I )click on "([^"]*)" navbar title$/ do |title|
  with_scope(".info-bar") do
    find("h5", text: title).click
  end
end

Given /^I have configured a Bitcoin address$/ do
  AppConfig.settings.bitcoin_address = "AAAAAA"
end

Then /^I should see the Bitcoin address$/ do
  find("#bitcoin_address")['value'].should == "AAAAAA"
end

Given /^I have configured a Liberapay username$/ do
  AppConfig.settings.liberapay_username = "BBBBBB"
end

Then /^I should see the Liberapay donate button$/ do
  find("#liberapay-button")["href"].should == "https://liberapay.com/BBBBBB/donate"
end
+6 −66
Original line number Diff line number Diff line
@@ -8,36 +8,6 @@ Then /^the post should be expanded$/ do
  first_post_expanded?
end

Then /^I should see an uploaded image within the photo drop zone$/ do
  expect(find("#photodropzone img")["src"]).to include("uploads/images")
end

Then /^I should not see an uploaded image within the photo drop zone$/ do
  page.should_not have_css "#photodropzone img"
end

Then /^I should not see any posts in my stream$/ do
  expect(page).not_to have_selector("#paginate .loader")
  expect(page).not_to have_selector(".stream-element .media")
  expect(page).to have_selector(".stream-element .no-posts-info")
end

Then /^I should not see any picture in my stream$/ do
  expect(page).to have_selector(".photo_area img", count: 0)
end

Then /^I should see (\d+) pictures in my stream$/ do |count|
  expect(page).to have_selector(".photo_area img", count: count)
end

Then /^I should not be able to submit the publisher$/ do
  expect(publisher_submittable?).to be false
end

Then /^I should see "([^"]*)" in the publisher$/ do |text|
  expect(page).to have_field("status_message[text]", with: text)
end

Given /^I have a limited post with text "([^\"]*)" in the aspect "([^"]*)"$/ do |text, aspect_name|
  @me.post :status_message, text: text, to: @me.aspects.where(name: aspect_name).first.id
end
@@ -83,10 +53,6 @@ And /^the post with text "([^"]*)" is reshared by "([^"]*)"$/ do |text, email|
  user.post(:reshare, :root_guid => root.guid, :public => true, :to => user.aspect_ids)
end

And /^I submit the publisher$/ do
  submit_publisher
end

When /^I click on the first block button/ do
  find(".stream-element", match: :first).hover
  find(".block_user").click
@@ -100,40 +66,14 @@ When /^I expand the post$/ do
  expand_first_post
end

When /^I click the publisher and post "([^"]*)"$/ do |text|
  click_and_post(text)
end

When /^I post an extremely long status message$/ do
  click_and_post("I am a very interesting message " * 64)
end

When /^I write the status message "([^"]*)"$/ do |text|
  write_in_publisher(text)
end

When /^I insert an extremely long status message$/ do
  write_in_publisher("I am a very interesting message " * 64)
end

When /^I append "([^"]*)" to the publisher$/ do |text|
  append_to_publisher(text)
end

When /^I attach "([^"]*)" to the publisher$/ do |path|
  upload_file_with_publisher(path)
end

When /^I open the show page of the "([^"]*)" post$/ do |post_text|
  visit post_path_by_content(post_text)
end

When /^I select "([^"]*)" on the aspect dropdown$/ do |text|
  page.execute_script(
    "$('#publisher .dropdown .dropdown_list, #publisher .aspect-dropdown .dropdown-menu')
      .find('li').each(function(i,el){
      var elem = $(el);
      if ('" + text + "' == $.trim(elem.text()) ) {
        elem.click();
      }});")
Then /^I should see an image attached to the post$/ do
  step %(I should see a "img" within ".stream-element div.photo-attachments")
end

Then /^I press the attached image$/ do
  step %(I press the 1st "img" within ".stream-element div.photo-attachments")
end
+74 −0
Original line number Diff line number Diff line
# frozen_string_literal: true

Then /^I expand the publisher$/ do
  click_publisher
end

And /^I close the publisher$/ do
  find("#publisher .md-cancel").click
end

Then /^the publisher should be expanded$/ do
  find("#publisher")["class"].should_not include("closed")
end

When /^I click to delete the first uploaded photo$/ do
  page.execute_script("$('#photodropzone .x').css('display', 'block');")
  image_count = all(".publisher_photo img", wait: false).count
  find("#photodropzone .x", match: :first).trigger "click"
  page.assert_selector(".publisher_photo img", count: image_count - 1)
end

Then /^I should see an uploaded image within the photo drop zone$/ do
  expect(find("#photodropzone img")["src"]).to include("uploads/images")
end

Then /^I should not see an uploaded image within the photo drop zone$/ do
  page.should_not have_css "#photodropzone img"
end

Then /^I should not be able to submit the publisher$/ do
  expect(publisher_submittable?).to be false
end

Then /^I should see "([^"]*)" in the publisher$/ do |text|
  expect(page).to have_field("status_message[text]", with: text)
end

When /^I write the status message "([^"]*)"$/ do |text|
  write_in_publisher(text)
end

When /^I insert an extremely long status message$/ do
  write_in_publisher("I am a very interesting message " * 64)
end

When /^I append "([^"]*)" to the publisher$/ do |text|
  append_to_publisher(text)
end

When /^I attach "([^"]*)" to the publisher$/ do |path|
  upload_file_with_publisher(path)
end

And /^I submit the publisher$/ do
  submit_publisher
end

When /^I click the publisher and post "([^"]*)"$/ do |text|
  click_and_post(text)
end

When /^I post an extremely long status message$/ do
  click_and_post("I am a very interesting message " * 64)
end

When /^I select "([^"]*)" on the aspect dropdown$/ do |text|
  page.execute_script(
    "$('#publisher .dropdown .dropdown_list, #publisher .aspect-dropdown .dropdown-menu')
      .find('li').each(function(i,el){
      var elem = $(el);
      if ('" + text + "' == $.trim(elem.text()) ) {
        elem.click();
      }});")
end
+48 −7
Original line number Diff line number Diff line
@@ -4,10 +4,6 @@ When /^I (?:like|unlike) the post "([^"]*)" in the stream$/ do |post_text|
  like_stream_post(post_text)
end

Then /^I should see an image in the publisher$/ do
  photo_in_publisher.should be_present
end

Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
  stream_element_numbers_content(position).should have_content(post_text)
end
@@ -24,8 +20,53 @@ Then /^I should have (\d+) nsfw posts$/ do |num_posts|
  page.should have_css(".nsfw-shield", count: num_posts.to_i)
end

When /^(?:|I )click on "([^"]*)" navbar title$/ do |title|
  with_scope(".info-bar") do
    find("h5", text: title).click
When /^I prepare the deletion of the first post$/ do
  find(".stream .stream-element", match: :first).hover
  within(find(".stream .stream-element", match: :first)) do
    ctrl = find(".control-icons")
    ctrl.hover
    ctrl.find(".remove_post").click
  end
end

When /^I prepare hiding the first post$/ do
  find(".stream .stream-element", match: :first).hover
  within(find(".stream .stream-element", match: :first)) do
    ctrl = find(".control-icons")
    ctrl.hover
    ctrl.find(".hide_post").click
  end
end

When /^I click to delete the first post$/ do
  accept_alert do
    step "I prepare the deletion of the first post"
  end
  expect(find(".stream")).to have_no_css(".stream-element.loaded.deleting")
end

When /^I click to hide the first post$/ do
  accept_alert do
    step "I prepare hiding the first post"
  end
end

When /^I click to delete the first comment$/ do
  within("div.comment", match: :first) do
    find(".comment_delete", visible: false).click
  end
end

Then /^I should not see any posts in my stream$/ do
  expect(page).not_to have_selector("#paginate .loader")
  expect(page).not_to have_selector(".stream-element .media")
  expect(page).to have_selector(".stream-element .no-posts-info")
end

Then /^I should not see any picture in my stream$/ do
  expect(page).to have_selector(".photo_area img", count: 0)
end

Then /^I should see (\d+) pictures in my stream$/ do |count|
  expect(page).to have_selector(".photo_area img", count: count)
end