-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create post_test.rb to test posting at /post #5605
Changes from all commits
e81c46a
dc3ae63
a184374
2960393
b537c1f
f58eb88
9d17253
f4d0511
5975695
3e93806
a368207
ac3cc72
51e67f7
141becd
8f3fc8f
cd3ad49
8610bbb
9b5dd73
1b053a8
febcf33
70a7a1e
61895c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on redundant, but I'm not sure how to create a session we can use to test logged-in stuff. I tried doing as we do in other tests, with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My biggest interests in system tests are:
But yeah... lots of other possibilities. |
||||||||||||||||||||||
fill_in("username-login", with: "Bob") | ||||||||||||||||||||||
fill_in("password-signup", with: "secretive") | ||||||||||||||||||||||
click_on "Log in" | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are logging in first and then going to '/post What do you suggest Jeff? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm, good idea... let me try... |
||||||||||||||||||||||
|
||||||||||||||||||||||
visit '/post' | ||||||||||||||||||||||
|
||||||||||||||||||||||
fill_in("Title", with: "My new post") | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fill_in(x, with: Y) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. X is ... i can't remember the term... maybe a |
||||||||||||||||||||||
|
||||||||||||||||||||||
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 | ||||||||||||||||||||||
|
This comment was marked as resolved.
Sorry, something went wrong.