-
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
[System Tests] addComment(URL), Add New Question Fixture #8801
[System Tests] addComment(URL), Add New Question Fixture #8801
Conversation
Thank you @noi5e!!! great, incisive questions! I trust the maintainers will engage with you to answer these 🌳 |
Hi @noi5e - so, plots2/test/fixtures/nodes.yml Lines 122 to 134 in cbb807b
That means it's an OK place to test comments, but yeah, it's also not the most common place for commenting to happen. Commenting may be set up differently here than in other places, such as on a note or question. Or on a note with a comment, where we're responding to the comment. (think of our 8 scenarios). So i think you're right to want to do tests on a question page and a note page as well. You could look at the tests for questions and notes to see what an appropriate fixture page is to do these, or, better, add a new fixture, to reduce interdependence of tests (that way, if we remove another feature and its tests, we don't break this test). Also, i think that So, we could remove that conditional from the comment form and the corresponding lines using Hope this helps, thanks @noi5e for the great work here! |
Oh! And regarding that very involved system test above -- We can look at the poorly named Looks like it was @VladimirMikulic ! Hello Vladimir! Good to see you! Just curious about that segment using the clipboard! Thanks!!!! |
Hello @jywarren. Good to see you as well! That segment using clipboard is JavaScript hack/workaround to fake the actual user's interaction. My commit message suggests that this test exists because of an error that you had encountered with PL Editor as described here. It serves as a reinforcement that the error is spotted if occurs again in the future. |
@jywarren (Thanks for the explanation on fixtures BTW, very helpful) Okay, coming a little further along with this, hit a new roadblock debugging the test. I've created a new fixture in nodes.yml simulating a question:
The corresponding test looks like:
In particular the test seems to stall out at Here's the plots2/app/controllers/questions_controller.rb Lines 69 to 77 in c069cfb
With some good old-fashioned So it goes down the other leg of the conditional and
|
I added a missing piece here. Thanks to @cesswairimu on chat, I finally am getting what a
And a fixture that simulates a
This is all so that the note has a power tag of Unfortunately, I'm still getting the same error I was getting above when running the test. I have a feeling but can't confirm that the hang-up is happening on this line:
There might be something wrong with parsing the URL path for author, date, and ID that makes the query come up undefined... Not sure. Any insights would be appreciated, as well as ideas on how to debug Rails tests (something that is still pretty new for me) |
I will pull this up on my end and have a look |
@cesswairimu FYI, was able to understand this a little better. Here's a crucial mistake I was making in the fixture:
The path should lead with
Which looks like this in Lines 904 to 906 in c069cfb
Side-note: it looks like when a note is generated in Lines 144 to 160 in c069cfb
It looks like the method Lines 134 to 142 in c069cfb
But I'm thinking... There's no question in the database saved with a path that begins with So I have some more clarity there, but getting a new error when I change It looks like my fixture needs to have
I don't yet understand what |
@jywarren @cesswairimu Did some more research, it looks like
After that, the test passes. I think I actually... got there? Just pushed my commits, I think this one's ready for review! I'm still very new to everything here, so my work could use some double-checking. Thanks for reading my mountain of notes. |
You solved it! Sorry, this happened over a period i was mostly offline, but glad you dug deeply and got to the answers! You're totally right on all counts, regarding revisions especially.
That sounds right. Being a question or not is determined by the power tag, so we can assume no nodes actually have 'questions' in the path -- we can think of the /questions/ type paths as aliases, essentially, enabled by the power tag's presence. The whole system is a little odd, but it basically works. I think you go this all worked out, it's ready for a final code review and if it passes all tests (we can manually confirm this by running them in GitPod for now) we can mark this ready to merge! |
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.
This looks perfect, as long as all the tests pass! Thanks, @noi5e !!! Great work and your deep digging here is much appreciated! @RuthNjeri take a look in case you run into similar issues! Thanks, all, and thanks @cesswairimu for your help on this too!
Hi! I've tried running tests in GitPod, to confirm (as we're still a little stuck on the Travis migration), but I found that the gems and database setup aren't completing smoothly in there. Has our GitPod environment broken down a bit? Sometimes we find we need to check in and tweak things to make sure the newcomer experience stays smooth. @noi5e did you find GitPod to be working smoothly? Thanks! |
@jywarren You know, I have dev set up locally since I posted that comment about GitPod to chat! So I haven't been using GitPod since. |
Code Climate has analyzed commit bf2198c and detected 0 issues on this pull request. View more on Code Climate. |
Wow, good thing I tested this locally. Because I made a new question fixture, it invalidated the results of this unit test for nodes: Lines 360 to 364 in ff3417a
I updated the expected array to include the new fixture, Now there doesn't seem to be any added test failures or errors from this branch (I get the same numbers as when I test my Side-note: I've noticed some of the question tests are failing... I've looked into the issue and it doesn't seem to be caused by my fixture. I will make a new issue about it. |
|
@Sagarpreet Thank you, the failing tests I mentioned seem to be unrelated to my PR:
This is all happening on my local build. Travis and Gitpod are both down, so don't have a way of verifying. It seems like it's worth it to say something on Gitter, so I'll do that right now! |
This is great, and very cool to see you caught:
Glad to hear that no new test failures are caused by this. One thing to bear in mind is that there can be some test failures that are environment dependent, which is not ideal but is understandable in a complex app. For example, i think some tests rely on Redis, perhaps? But in general you can imagine that testing could get into the specifics of setup. Unit tests shouldn't if they're testing internal, fundamental behaviors of code, but even then maybe we test mails sent, or something, and get in trouble that way. And, we can get complacent about test consistency when we use a Continuous Integration service like Travis, so maybe this is good for us to confront, thinking in the long term. Thanks for your extra attention to the tests and i'll go ahead and merge this now! |
Just noting also that I'm also more OK with merging this as it only affects tests and not any new functionality. Thanks again! |
… Question Page via JS + URL (publiclab#8801) * add test for synchronous comments on question pages via JS & URL * changed test so it visits /questions, not /wiki/wiki-page-path * create new question fixture for testing complete with tags, node_tags, and revisions * Update "Find all questions" node unit test
… Question Page via JS + URL (publiclab#8801) * add test for synchronous comments on question pages via JS & URL * changed test so it visits /questions, not /wiki/wiki-page-path * create new question fixture for testing complete with tags, node_tags, and revisions * Update "Find all questions" node unit test
… Question Page via JS + URL (publiclab#8801) * add test for synchronous comments on question pages via JS & URL * changed test so it visits /questions, not /wiki/wiki-page-path * create new question fixture for testing complete with tags, node_tags, and revisions * Update "Find all questions" node unit test
… Question Page via JS + URL (publiclab#8801) * add test for synchronous comments on question pages via JS & URL * changed test so it visits /questions, not /wiki/wiki-page-path * create new question fixture for testing complete with tags, node_tags, and revisions * Update "Find all questions" node unit test
This is a draft PR, I'm not there yet. Feedback very welcome as I'm learning a lot about
plots2
, and a lot else.This adds a single new system test, testing for "User adds comment to a question page." In particular, this tests for commenting via
addComment(URL)
(a JS method that seemingly comes with comment forms).In my understanding, question pages seem to reuse the same form partial (below) that other nodes (wikis, notes) use. A crucial difference for question comments is that a
?type=question
parameter is added to the AJAX request URL. So that's the difference in this test:plots2/app/views/comments/_form.html.erb
Line 3 in cbb807b
Point of Concern
The other comment tests in
comment_test.rb
are testing comments on the page/wiki/wiki-page-path/comments
.wiki-page-path
seems to be a dummy article that exists only in the testing environment. It doesn't exist in development locally, nor in production at publiclab.org (navigating tohttps://site + /wiki/wiki-page-path
404s at both).My concern is that this test should probably be testing on an actual question page (
/question/{id-as-string}/comments
, or the equivalent). However, I don't know what the testing convention is.wiki-page-path
generated? Is it seeded into the development database somehow?post_question_test.rb
, it seems a little bit involved though:plots2/test/system/post_question_test.rb
Lines 23 to 71 in cbb807b
wiki-page-path
or creating a new question from scratch in the test, and posting the comment to it?(This PR is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)