forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create post_test.rb to test posting at /post (publiclab#5605)
* Create post_test.rb * UserSession.create(users(:bob)) # log in * Update post_test.rb * Update rich.html.erb * Update post_test.rb * Update post_test.rb * Trying login via modal * add login-button id * Update post_test.rb * Update post_test.rb * Update post_test.rb * locators instead of css "It appears you may be passing a CSS selector or XPath expression rather than a locator. Please see the documentation for acceptable locator values." * locators instead of css "It appears you may be passing a CSS selector or XPath expression rather than a locator. Please see the documentation for acceptable locator values." * Update post_test.rb * /images/pl.png in scraped image * /images/pl.png in scraped image * Update post_test.rb * add assert_page_reloads * Update post_test.rb * Update post_test.rb * Update post_test.rb * Update post_test.rb
- Loading branch information
1 parent
e36dd42
commit 73a9233
Showing
3 changed files
with
58 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require "application_system_test_case" | ||
# https://guides.rubyonrails.org/testing.html#implementing-a-system-test | ||
|
||
class PostTest < ApplicationSystemTestCase | ||
|
||
def setup | ||
activate_authlogic | ||
end | ||
|
||
test 'posting from the editor' do | ||
visit '/' | ||
|
||
click_on 'Login' | ||
fill_in("username-login", with: "Bob") | ||
fill_in("password-signup", with: "secretive") | ||
click_on "Log in" | ||
|
||
visit '/post' | ||
|
||
fill_in("Title", with: "My new post") | ||
|
||
el = find(".wk-wysiwyg") # rich text input | ||
el.set("All about this interesting stuff") | ||
|
||
assert_page_reloads do | ||
|
||
find('.ple-publish').click | ||
assert_selector('h1', text: "My new post") | ||
assert_selector('#content', text: "All about this interesting stuff") | ||
assert_selector('.alert-success', text: "×\nSuccess! Thank you for contributing open research, and thanks for your patience while your post is approved by community moderators and we'll email you when it is published. In the meantime, if you have more to contribute, feel free to do so.") | ||
|
||
end | ||
|
||
end | ||
|
||
# Utility methods: | ||
|
||
def assert_page_reloads(message = "page should reload") | ||
page.evaluate_script "document.body.classList.add('not-reloaded')" | ||
yield | ||
if has_selector? "body.not-reloaded" | ||
assert false, message | ||
end | ||
end | ||
|
||
def assert_page_does_not_reload(message = "page should not reload") | ||
page.evaluate_script "document.body.classList.add('not-reloaded')" | ||
yield | ||
unless has_selector? "body.not-reloaded" | ||
assert false, message | ||
end | ||
page.evaluate_script "document.body.classList.remove('not-reloaded')" | ||
end | ||
|
||
end | ||
|