Skip to content
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

Brainstorm a list of critical full-stack system tests we should add #5316

Open
jywarren opened this issue Mar 31, 2019 · 13 comments

Comments

Projects
None yet
4 participants
@jywarren
Copy link
Contributor

commented Mar 31, 2019

Once #4888 is merged (done!), we'll have system tests running in Travis! This means we can test a full running application on each PR, including javascript, ruby, and everything. We've had some recurring and difficult-to-test issues come up over the past few years, and this is a chance to monitor those delicate and highly integrated scenarios with tests!

Here's our initial test, which is passing, using documentation from https://guides.rubyonrails.org/testing.html#implementing-a-system-test :

require "application_system_test_case"
# https://guides.rubyonrails.org/testing.html#implementing-a-system-test
class SearchTest < ApplicationSystemTestCase
test 'searching an item from the homepage' do
visit '/'
fill_in("searchform_input", with: "Canon")
find('button.btn-default').click
assert_selector('h2', text: 'Results for Canon')
end
end

Based on this template, we can do things like interact with Javascript-driven features, click on things, etc. Let's brainstorm a list of the most critical things we should protect first with this powerful new testing system!

  • the basic login sequence -- ensuring that the login modal appears, accepts inputs, and logs us in #5682
  • posting a new note #5605
  • loading the dashboard #5682
  • using typeahead search in the navbar #5525
  • using /search #4888
  • signup
  • commenting on a post
  • uploading an image to a comment: #5526
  • drag-to-upload an image in a comment #5655
  • editing a wiki
  • uploading an image to a wiki: #5650
  • adding a tag
  • liking

What else has broken recently?

(Note: there is also a means for system tests to take screenshots and upload them as 'artifacts' in Travis... 😮 📸 so if anyone wants to try opening a PR for that we'd love to see it tried out - but maybe best open a new issue for it! -- update: testing here: #5320)

@gauravano

This comment has been minimized.

Copy link
Member

commented Mar 31, 2019

This seems awesome @jywarren! I will go through the ruby on rails guide first as I haven't written any system test till now 🙈

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Mar 31, 2019

😄

Example test:

require 'application_system_test_case'

class Users::CreateTest < ApplicationSystemTestCase
  test "adding a new user" do
    visit users_path
    click_on 'New User'

    fill_in 'Name', with: 'Arya'
    click_on 'Create User'

    assert_text 'Arya'
  end
end
@GettyOrawo

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

Nice 🛩 So every test will have it's own test file under plots2/test/system/ ?

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

Hi, @GettyOrawo -- i think we can put multiple tests in each file!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

Also, i believe it's possible to use anything from Capybara's DSL (domain specific language?) -- https://github.com/teamcapybara/capybara#the-dsl

It mentions attaching files: https://github.com/teamcapybara/capybara#interacting-with-forms

attach_file('Image', '/path/to/image.jpg')

And evaluating javascript functions: https://github.com/teamcapybara/capybara#scripting

result = page.evaluate_script('4 + 4');

I'm not /sure/ these will work, but for testing things like image upload, I'd love to try it!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

Attempted to use a JS function in #5525!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

And tried using attach_file here to test comment image upload! #5526

@Isssabel Isssabel referenced a pull request that will close this issue Apr 23, 2019

Open

Add some primitive system tests #5316 #5590

4 of 5 tasks complete
@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 26, 2019

I found this great Capybara cheatsheet!!! https://gist.github.com/zhengjia/428105

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Apr 28, 2019

And, I seem to see a chrome plugin that can generate -- even "record" capybara tests based on your interactions!

https://github.com/polarblau/capycorder/

We could use this to quickly generate tests.

@namangupta01

This comment has been minimized.

Copy link
Member

commented Apr 28, 2019

This seems interesting, I also want to contribute on this one.

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 2, 2019

OK! With help from Capycorder, I completed a system test of posting at /post -- it's really cool, and goes through the steps of:

  1. logging in
  2. filling out the posting form
  3. pressing Publish
  4. confirming that the page now shows the post

See it here:

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

We can use this as an example to make more system tests, like for #5526

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

also

within('comment-form') do

end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.