mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 20:24:43 +08:00
88d7429041
2. fixes gem dependencies issues 3. fixes failing migrations 4. updates depricated factory_girl => factory_bot and fixes related issues Signed-off-by: zmagod <zmago_devetak@yahoo.com>
135 lines
3.5 KiB
Ruby
135 lines
3.5 KiB
Ruby
When(/^I click "(.+)" button$/) do |button|
|
|
click_on(button)
|
|
end
|
|
|
|
Given(/^Show me the page$/) do
|
|
save_and_open_page
|
|
end
|
|
|
|
Then(/^I should be redirected to the homepage$/) do
|
|
current_path.should =~ /^\/$/
|
|
end
|
|
|
|
Given(/^I click "(.+)" link$/) do |link|
|
|
click_link link
|
|
end
|
|
|
|
Given(/^I click "(.+)" link within "(.+)"$/) do |link, element|
|
|
within(element) do
|
|
click_link link
|
|
end
|
|
end
|
|
|
|
Then(/^I click "(.+)" link within dropdown menu$/) do |link|
|
|
within('.dropdown-menu') do
|
|
click_link link
|
|
end
|
|
end
|
|
|
|
Then(/^I should see "(.+)"$/) do |text|
|
|
wait_for_ajax
|
|
expect(page).to have_content(text)
|
|
end
|
|
|
|
Then(/^I should be on homepage$/) do
|
|
expect(page).to have_current_path(root_path)
|
|
end
|
|
|
|
Given(/^the "([^"]*)" team exists$/) do |team_name|
|
|
FactoryBot.create(:team, name: team_name)
|
|
end
|
|
|
|
Given(/^I'm on the home page of "([^"]*)" team$/) do |team_name|
|
|
team = Team.find_by_name(team_name)
|
|
@current_user.update_attribute(:current_team_id, team.id)
|
|
visit root_path
|
|
end
|
|
|
|
Given(/^"([^"]*)" is in "([^"]*)" team as a "([^"]*)"$/) do |user_email, team_name, role|
|
|
team = Team.find_by_name(team_name)
|
|
user = User.find_by_email(user_email)
|
|
FactoryBot.create(:user_team, user: user,
|
|
team: team, role:
|
|
UserTeam.roles.fetch(role))
|
|
end
|
|
|
|
Then(/^I attach a "([^"]*)" file to "([^"]*)" field$/) do |file, field_id|
|
|
wait_for_ajax
|
|
attach_file(field_id, Rails.root.join('features', 'assets', file))
|
|
# "expensive" operation needs some time :=)
|
|
sleep(0.5)
|
|
end
|
|
|
|
Then(/^I should see "([^"]*)" error message under "([^"]*)" field$/) do |message, field_id|
|
|
wait_for_ajax
|
|
parent = find_by_id(field_id).first(:xpath, './/..')
|
|
expect(parent).to have_content(message)
|
|
end
|
|
|
|
Then(/^I click on "([^"]*)"$/) do |button|
|
|
click_on button
|
|
end
|
|
|
|
Then(/^I click on image within "([^"]*)" element$/) do |container|
|
|
sleep 0.5
|
|
within(container) do
|
|
find('img').click
|
|
end
|
|
wait_for_ajax
|
|
end
|
|
|
|
Then(/^I should see "([^"]*)" flash message$/) do |message|
|
|
wait_for_ajax
|
|
expect(find('.alert')).to have_content(message)
|
|
end
|
|
|
|
Then(/^I click on Edit on "([^"]*)" input field$/) do |container_id|
|
|
wait_for_ajax
|
|
container = page.find_by_id(container_id)
|
|
within(container) do
|
|
find('button').click
|
|
end
|
|
end
|
|
|
|
Then(/^I fill in "([^"]*)" in "([^"]*)" input field$/) do |text, input_id|
|
|
page.find_by_id(input_id).set(text)
|
|
end
|
|
|
|
Then(/^I should see "([^"]*)" in "([^"]*)" input field$/) do |text, container_id|
|
|
container = page.find_by_id(container_id)
|
|
expect(container).to have_xpath("//input[@value='#{text}']")
|
|
end
|
|
|
|
Given("I click {string} icon") do |id|
|
|
find(:css, id).click
|
|
end
|
|
|
|
Then(/^(?:|I )click on "([^"]*)" element$/) do |selector|
|
|
find(selector).click
|
|
end
|
|
|
|
Then(/^I change "([^"]*)" with "([^"]*)" in "([^"]*)" input field$/) do |old_text, new_text, container_id|
|
|
container = page.find_by_id(container_id)
|
|
expect(container).to have_xpath("//input[@value='#{old_text}']")
|
|
container.find('input').set(new_text)
|
|
end
|
|
|
|
Then(/^I fill in "([^"]*)" in "([^"]*)" textarea field$/) do |text, textarea_id|
|
|
textarea = page.find_by_id(textarea_id)
|
|
textarea.set(text)
|
|
end
|
|
|
|
Then(/^I change "([^"]*)" with "([^"]*)" in "([^"]*)" textarea field$/) do |old_text, new_text, textarea_id|
|
|
textarea = page.find_by_id(textarea_id)
|
|
expect(textarea).to have_content(old_text)
|
|
textarea.set(new_text)
|
|
end
|
|
|
|
Then(/^I should see "([^"]*)" on "([^"]*)" element$/) do |text, element|
|
|
wait_for_ajax
|
|
expect(find(element)).to have_content(text)
|
|
end
|
|
|
|
Then("I wait for {int} sec") do |sec|
|
|
sleep sec
|
|
end
|