forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add chrome-server service to run integration test
- Loading branch information
1 parent
c9b3e32
commit c1cab53
Showing
6 changed files
with
131 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require "test_helper" | ||
require_relative 'helpers/application_test_helpers' | ||
|
||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | ||
include ApplicationTestHelpers::Ontologies | ||
include ApplicationTestHelpers::Users | ||
include ApplicationTestHelpers::Users | ||
include ApplicationTestHelpers::Categories | ||
include ApplicationTestHelpers::Groups | ||
|
||
driven_by :selenium, using: :chrome, options: { | ||
browser: :remote, | ||
url: "http://localhost:4444" | ||
} | ||
|
||
def login_in_as(user) | ||
visit login_index_url | ||
|
||
# Fill in the login form | ||
fill_in 'user_username', with: user.username | ||
fill_in 'user_password', with: user.password | ||
|
||
# Click the login button | ||
click_button 'Login' | ||
end | ||
|
||
def tom_select(selector, values) | ||
|
||
multiple = values.is_a?(Array) | ||
|
||
|
||
real_select = "[name='#{selector}']" | ||
|
||
# Click on the Tom Select input to open the dropdown | ||
find("#{real_select} + div").click | ||
sleep 1 | ||
|
||
return unless page.has_selector?("#{real_select} + div > .ts-dropdown") | ||
|
||
if multiple | ||
# reset the input to empty | ||
all("#{real_select} + div > .ts-control > .item .remove").each do |element| | ||
element.click | ||
end | ||
|
||
page.execute_script("document.querySelector(\"#{real_select} + div > .ts-control\").innerHTML = '';") | ||
else | ||
values = Array(values) | ||
end | ||
|
||
within "#{real_select} + div > .ts-dropdown > .ts-dropdown-content" do | ||
|
||
|
||
values.each do |value| | ||
if page.has_selector?('.option', text: value) | ||
find('.option', text: value).click | ||
end | ||
end | ||
end | ||
|
||
if multiple | ||
find("#{real_select} + div").click | ||
sleep 1 | ||
end | ||
end | ||
|
||
|
||
def date_picker_fill_in(selector, value) | ||
page.execute_script("document.querySelector(\"[name='#{selector}']\").flatpickr().setDate('#{value}')") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'rails/test_help' | ||
module ApplicationTestHelpers | ||
module Users | ||
def sign_in_as(username) | ||
user = fixtures(:users)[username] | ||
logged_in_user = LinkedData::Client::Models::User.authenticate(user.username, user.password) | ||
if logged_in_user && !logged_in_user.errors | ||
logged_in_user = create_user(user) | ||
end | ||
session[:user] = logged_in_user | ||
end | ||
|
||
def create_user(user) | ||
LinkedData::Client::Models::User.new(values: user.to_h).save | ||
end | ||
end | ||
|
||
|
||
module Ontologies | ||
def create_ontology(ontology) | ||
LinkedData::Client::Models::Ontology.new(values: ontology.to_h).save | ||
end | ||
end | ||
|
||
module Categories | ||
def create_category(category) | ||
created = LinkedData::Client::Models::Category.new(values: category.to_h).save | ||
return category if created.errors | ||
created | ||
end | ||
end | ||
|
||
module Groups | ||
def create_group(group) | ||
created = LinkedData::Client::Models::Group.new(values: group.to_h).save | ||
return group if created.errors | ||
created | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters