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] Comment On Question, Then Immediately Respond #8851

Merged
merged 3 commits into from Dec 15, 2020

Conversation

noi5e
Copy link
Contributor

@noi5e noi5e commented Dec 15, 2020

Added new test for Question pages:

  • post comment to a Question page
  • respond to the freshly posted comment
    • I understand the comment box is freshly made by JS...
    • so this is testing an asynchronous comment action

Small concerns:

  • I ran all the tests locally, so this shouldn't be introducing any new failures/errors
  • there may be merge conflicts bc the commits include fixtures that have already been merged into main
  • please review the new test below, it's a little more complex than usual.
    • in particular I used XPath to find a parent element. I know XPath is a bit slower than CSS, but don't know if there's a CSS workaround.
  test 'question page: reply to freshly posted comment' do
    visit nodes(:question4).path
    # post new comment
    comment_text = 'woot woot'
    page.evaluate_script("addComment('#{comment_text}', '/comment/create/#{nodes(:question4).nid}')")
    # we need the ID of parent div that contains <p>comment_text</p>:
    parent_id = page.find('p', text: comment_text).find(:xpath, '..')[:id]
    # regex to strip the ID number out of string. ID format is comment-body-4231
    parent_id_num = /comment-body-(\d+)/.match(parent_id)[1]
    # reply to comment
    comment_response_text = 'wooly woot!'
    # addComment(comment text, submitURL, comment's parent ID)
    page.evaluate_script("addComment('#{comment_response_text}', '/comment/create/#{nodes(:question4).nid}', #{parent_id_num})")
    # assert that <div id="c1show"> has child div[div[p[text="wooly woot!"]]]
    assert_selector("#{'#c' + parent_id_num + 'show'} div div div p", text: comment_response_text)
  end

(This PR 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 Dec 15, 2020

@noi5e noi5e added outreachy testing issues are usually for adding unit tests, integration tests or any other tests for a feature labels Dec 15, 2020
@codeclimate
Copy link

codeclimate bot commented Dec 15, 2020

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

View more on Code Climate.

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.

This looks great. It passes locally? Awesome work!

@noi5e
Copy link
Contributor Author

noi5e commented Dec 15, 2020

Ah yeah, I didn't make that clear: yep the tests look good locally!

@jywarren jywarren merged commit 4bf41ff into publiclab:main Dec 15, 2020
@jywarren
Copy link
Member

Fantastic!!

@noi5e noi5e deleted the test/question-fresh-comment-response branch December 15, 2020 23:15
@noi5e noi5e changed the title [Outreachy Comment Editor] New test: Post comment on question, then respond to it Testing: Comment On Question, Then Immediately Respond Dec 27, 2020
@noi5e noi5e changed the title Testing: Comment On Question, Then Immediately Respond [System Tests] Comment On Question, Then Immediately Respond Jan 23, 2021
manchere pushed a commit to manchere/plots2 that referenced this pull request Feb 13, 2021
…espond to it (publiclab#8851)

* add test for question: comment then respond

* fixtures for question w/ comment
lagunasmel pushed a commit to lagunasmel/plots2 that referenced this pull request Mar 2, 2021
…espond to it (publiclab#8851)

* add test for question: comment then respond

* fixtures for question w/ comment
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
…espond to it (publiclab#8851)

* add test for question: comment then respond

* fixtures for question w/ comment
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
…espond to it (publiclab#8851)

* add test for question: comment then respond

* fixtures for question w/ comment
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