-
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
Conversation
OK, seeing this in #5525 and #5526:
|
81d1622
to
dc3ae63
Compare
OK back in business:
|
Hmm.
|
test/system/post_test.rb
Outdated
|
||
visit '/post' | ||
|
||
fill_in("input#title-input", with: "My new post") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd think this would work, but it doesn't seem to!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jywarren , the syntax is correct . I think we are not logged-in and hence this text field is not visible .
I think we should sign-in like this : Source : http://blog.mechanicles.com/2018/03/04/gotchas-rails-system-testing.html |
test/system/post_test.rb
Outdated
end | ||
|
||
test 'posting from the editor' do | ||
UserSession.create(users(:bob)) # log in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, perhaps because this doesn't create a session in the headless browser?
OK, trying to log in via Capybara commands! Hope i got it right! |
|
"It appears you may be passing a CSS selector or XPath expression rather than a locator. Please see the documentation for acceptable locator values."
"It appears you may be passing a CSS selector or XPath expression rather than a locator. Please see the documentation for acceptable locator values."
|
test 'posting from the editor' do | ||
visit '/' | ||
|
||
click_on 'Login' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Here we are visiting login but on line 29 we get the message
User was successfully created.
Can you please explain this code snippet? - We have same integration test here
plots2/test/integration/login_flow_test.rb
Lines 4 to 13 in 856c371
test 'redirect to login page if user is not logged in and then redirect back to desired page after login' do get '/post?tags=question:question&template=question' follow_redirect! assert_equal '/login', path post '/user_sessions', params: { user_session: { username: users(:jeff).username, password: 'secretive' } } follow_redirect! assert_equal '/post?tags=question:question&template=question', request.fullpath end - In theory of Software Testing at my university, we are taught that System tests are written to
validate the non-functional parameters
like server load time, access time between end nodes etc. Are we also going to do those amazing stuff later on? - I am having difficulty in installing the prerequisites for System tests. Can you please tell a good reference? I searched a lot but none worked during past one week.
- How can we use Recaptcha or Spamaway in system test? Any idea. You may require them in this pr too in case we want
assert_selector('#notice', 'User was successfully created.')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 UserSession.new()
or whatever, but I think it literally isn't connecting that session we make in the back-end to an actual logged in session that Capybara can interact with on headless chrome! So, i'm trying to log in manually here... how else ought we to log in? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we also going to do those amazing stuff later on?
My biggest interests in system tests are:
- testing the interaction of our complex JS with the Rails app, end-to-end, because things keep breaking here
- seeing screenshots!
But yeah... lots of other possibilities.
OK! Added a real image URL to |
Great,
|
test/system/post_test.rb
Outdated
visit '/post' | ||
|
||
fill_in("Title", with: "My new post") | ||
fill_in("text-input", with: "All about this interesting stuff") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we need a better way to select the right field. Maybe this is because we're in wysiwyg and not markdown mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
test/system/post_test.rb
Outdated
find('.ple-publish').click | ||
# find('.ple-publish').click # may have to do it twice if it prompts for an image | ||
|
||
assert_response :redirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, here... NoMethodError: NoMethodError: undefined method
response_code' for nil:NilClass`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 26 is not right, we shouldn't have to click twice. Not sure why this isn't working...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. i used Capycorder to try this but it didn't get everything:
it 'SHOULDDOSOMETHING' do
visit('/post')
page.should have_selector('.wk-wysiwyg')
page.should have_selector('html > body > .container > .row > .pl-editor > .ple-content > .ple-module-title.ple-module.row > .ple-module-content.col-lg-9:nth-child(1) > .form-control.input-lg')
fill_in('undefined', :with => 'title title')
page.should have_selector('.ple-publish.btn.btn-lg.btn-primary.float-right')
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in fact on stable, posting is not working, so maybe this is just because the functionality is broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see a 500 on https://stable.publiclab.org/post,
title: testing
body: testing
authenticity_token: yYh7o/22lYcj6XJ0dJViugBbFW72WK790hzjEJAFI52tUAZEijrbnzc3+d1ZZaj+LgBwIoz2PK6pwJslzEWgRw==
draft: false
tags:
has_main_image:
main_image:
node_images:
image[photo]:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this 500 possibly due to email not sending? I thought we'd resolved this but who knows... hmm. We may need to try to pull the logs here since this is not failing in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, think I resolved the 500 on stable... testing....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's resolved on stable. Still not here, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I realized that it's not doing a real redirect... it's JS sending us to a new page. So, I'm using a snippet from https://stackoverflow.com/questions/20243208/how-can-i-test-in-capybara-that-a-page-has-not-reloaded-javascript-onclick-in to show that assert_page_reloads
and then just going forward with the next steps!
Hmm!
|
Closer...
|
Maybe we need to tell it to load the page JavaScript sends it to?
|
🤞 |
Hooray!!!! System test running!!! |
Wow amazing !!! 🙌 |
Awesome!!!
…On Fri, May 3, 2019 at 11:04 AM Sagarpreet Chadha ***@***.***> wrote:
Wow amazing !!! 🙌
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5605 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFAAEQ37D72VQXMXSFHKOXTPTPFFPANCNFSM4HH7WU2Q>
.
|
* 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
* OAuth route creation for MK and SWB * OAuth routes created * Github working properly * Modified the route to accept the provider * OAuth completed * removed codeclimate issues * Documentation added * test modified * tests modified * modified test to have roles * Travis is passing * Added OAuth tests * made travis pass * username removed from CDSM * Removed redundant test * Fixing date issue in subscription mailer (#5638) * add nid to rss titles (#5644) * Fix scraped image system test bug (#5646) * Fix scraped image system test bug * Update node_test.rb * Create post_test.rb to test posting at /post (#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 * fixed image drag and drop bug (#5657) * Database tweaks for performance (#5575) * Database tweaks for performance * Reduce innodb buffer pool size because of low memory * Reduce RAM burden * Reduce memory consumption following mysqltuner advice. * Even more conservative limits for RAM * Update home.html.erb * Corrected the number of notes appearing on one line (#5661) * Some mistakes corrected in notes.html.erb * Wait 4 * Issue 5259: Used logged_in_as method to replace current_user.role condition (#5660) * Update subscriptions.html.erb * fix logged_in_as in controllers (#5677) * fix logged_in_as in controllers * add wait 4 to system test... odd * Update subscriptions.html.erb * Update subscriptions.html.erb * Bump cytoscape from 3.5.4 to 3.6.0 (#5662) Bumps [cytoscape](https://github.com/cytoscape/cytoscape.js) from 3.5.4 to 3.6.0. - [Release notes](https://github.com/cytoscape/cytoscape.js/releases) - [Commits](cytoscape/cytoscape.js@v3.5.4...v3.6.0) Signed-off-by: dependabot[bot] <[email protected]> * Dashboard system test (#5682) * Dashboard system test * Update dashboard_test.rb * Capybara.default_max_wait_time = 5 * fix
* 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
…clab#5640) * OAuth route creation for MK and SWB * OAuth routes created * Github working properly * Modified the route to accept the provider * OAuth completed * removed codeclimate issues * Documentation added * test modified * tests modified * modified test to have roles * Travis is passing * Added OAuth tests * made travis pass * username removed from CDSM * Removed redundant test * Fixing date issue in subscription mailer (publiclab#5638) * add nid to rss titles (publiclab#5644) * Fix scraped image system test bug (publiclab#5646) * Fix scraped image system test bug * Update node_test.rb * 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 * fixed image drag and drop bug (publiclab#5657) * Database tweaks for performance (publiclab#5575) * Database tweaks for performance * Reduce innodb buffer pool size because of low memory * Reduce RAM burden * Reduce memory consumption following mysqltuner advice. * Even more conservative limits for RAM * Update home.html.erb * Corrected the number of notes appearing on one line (publiclab#5661) * Some mistakes corrected in notes.html.erb * Wait 4 * Issue 5259: Used logged_in_as method to replace current_user.role condition (publiclab#5660) * Update subscriptions.html.erb * fix logged_in_as in controllers (publiclab#5677) * fix logged_in_as in controllers * add wait 4 to system test... odd * Update subscriptions.html.erb * Update subscriptions.html.erb * Bump cytoscape from 3.5.4 to 3.6.0 (publiclab#5662) Bumps [cytoscape](https://github.com/cytoscape/cytoscape.js) from 3.5.4 to 3.6.0. - [Release notes](https://github.com/cytoscape/cytoscape.js/releases) - [Commits](cytoscape/cytoscape.js@v3.5.4...v3.6.0) Signed-off-by: dependabot[bot] <[email protected]> * Dashboard system test (publiclab#5682) * Dashboard system test * Update dashboard_test.rb * Capybara.default_max_wait_time = 5 * fix
For #5316