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

[System Tests] Increase System Tests Speed by Decreasing Coverage #9045

Merged
merged 4 commits into from Jan 20, 2021

Conversation

noi5e
Copy link
Contributor

@noi5e noi5e commented Jan 20, 2021

Currently, all the comment system tests are tested on the three main page types:

  • Research Notes
  • Questions
  • Wikis

In the past, this may have been necessary because the Comment Editor did sometimes behave differently, particularly on wiki pages.

However, with recent refactoring of editor.js, which I explained in this comment, I think we can be confident that comments will behave pretty similarly across all three page types. After all, they all derive from the notes/comments partial.

So I'm reducing test coverage and just running some system tests on only research notes, and other tests on all three (wikis, notes, and questions). This way, we can keep the multi-page testing block just in case we want to test on all 3 in the future.


(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)

@gitpod-io
Copy link

gitpod-io bot commented Jan 20, 2021

@noi5e
Copy link
Contributor Author

noi5e commented Jan 20, 2021

This is how the tests were run on all three page types:

# page_types are wiki, research note, question:
page_types.each do |page_type, node_name|
page_type_string = page_type.to_s
comment_text = 'woot woot'
comment_response_text = 'wooly woot'
test "#{page_type_string}: addComment(comment_text)" do
visit get_path(page_type, nodes(node_name).path)
page.evaluate_script("addComment('#{comment_text}')")
assert_selector('#comments-list .comment-body p', text: comment_text)
end

page_types is defined in test_helper.rb here:

# used in comment_test.rb
def page_types
{
:note => :comment_note,
:question => :comment_question,
:wiki => :wiki_page
}
end


# other comment tests can ALSO be tested on Wikis and Questions.
# scroll past this block for those tests.
{ :note => :comment_note }.each do |page_type, node_name|
test "#{page_type_string}: addComment(comment_text)" do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block just runs tests on research notes (most tests will now live in this block).

# check for comment text
assert_selector("#{parent_id} .comment .comment-body p", text: 'no you can\'t')
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this test (which I wrote early on in the internship), because it doesn't seem so necessary now.

@codecov
Copy link

codecov bot commented Jan 20, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@f82a11c). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9045   +/-   ##
=======================================
  Coverage        ?   82.05%           
=======================================
  Files           ?      100           
  Lines           ?     5939           
  Branches        ?        0           
=======================================
  Hits            ?     4873           
  Misses          ?     1066           
  Partials        ?        0           

#
# the page_types are: Wikis, Research Notes, and Questions
# defined in test/test_helper.rb
page_types.each do |page_type, node_name|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this block, tests are run on all three page types. Keeping the cross-wiring and image upload tests here for now, but perhaps they can be moved out soon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 16m is pretty good. Are there other places we could obviously speed things up? For example, i wonder if caching dependencies would make a significant difference; i wasn't sure the Yarn deps were getting correctly cached...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll definitely do another re-assessment after the internship is over... I think if the editor code is overhauled, maybe we really won't need to do so many cross-wiring tests?

I don't know much about caching dependencies, do you have a link to read up on that?

@noi5e noi5e added outreachy testing issues are usually for adding unit tests, integration tests or any other tests for a feature labels Jan 20, 2021
@codeclimate
Copy link

codeclimate bot commented Jan 20, 2021

Code Climate has analyzed commit d95e62e and detected 0 issues on this pull request.

View more on Code Climate.

@noi5e
Copy link
Contributor Author

noi5e commented Jan 20, 2021

System tests passed in 16 minutes... My last two PRs had system tests passing in 25 minutes, but also 19 minutes. Seems like a slight improvement in speed!

Ready to merge with review!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great. I really appreciate that you're at a point where you can remove tests due to refactors or better understanding of the code. Nice!!

@jywarren jywarren merged commit fa85af4 into publiclab:main Jan 20, 2021
@noi5e noi5e deleted the test/comment-system-test-cleanup branch January 20, 2021 17:42
@noi5e noi5e changed the title Increase System Tests Speed by Decreasing Coverage [System Tests] Increase System Tests Speed by Decreasing Coverage Jan 23, 2021
manchere pushed a commit to manchere/plots2 that referenced this pull request Feb 13, 2021
* reduce most test coverage to just notes

* oops, added page_type_string

* updated out-of-date selectors; moved tests around

* change selector
lagunasmel pushed a commit to lagunasmel/plots2 that referenced this pull request Mar 2, 2021
* reduce most test coverage to just notes

* oops, added page_type_string

* updated out-of-date selectors; moved tests around

* change selector
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* reduce most test coverage to just notes

* oops, added page_type_string

* updated out-of-date selectors; moved tests around

* change selector
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* reduce most test coverage to just notes

* oops, added page_type_string

* updated out-of-date selectors; moved tests around

* change selector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
outreachy testing issues are usually for adding unit tests, integration tests or any other tests for a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants