-
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
Tests for Simple-Data-Grapher #6104
Conversation
PS: I would be fixing the linting soon! |
Here only the test file bears important, rest all is from #5993 https://github.com/publiclab/plots2/pull/6104/files#diff-b6813d8a7c58e0cf4118a4a9e17873cd |
|
||
} | ||
function graphMaker(data,divId){ | ||
var obj = data["sdgobject"]; |
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 think it would be possible to use let
instead of var
here, because limiting the scope could avoid future global variable-related bugs :) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
@@ -38,6 +43,10 @@ def rich | |||
image if params[:i] | |||
end | |||
|
|||
# def tempfunc |
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 there any reason to leave this commented code?
@@ -0,0 +1,2 @@ | |||
module CsvfilesHelper |
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.
More changes in the future I guess
var headerContainer = document.getElementsByClassName("body-container")[0]; | ||
SimpleDataGrapherObject = new SimpleDataGrapher("first"); | ||
var value = '<%= current_user %>'; | ||
<% if current_user %> |
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.
Sorry, I did not understand why you have JS code in an embedded ruby file. Would it make sense to move the JS code to a separate file?
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.
Actually, this file is very much like the rich.html.erb , which integrates the PL Editor in the same way as Simple-Data-Grapher, that is why it's required here!
</table> | ||
|
||
<style> | ||
.main_heading_data{ |
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.
A separate file for these css styles would be great I think
assert_redirected_to '/login' | ||
end | ||
|
||
test 'should save graph object' do |
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.
Can you think of other unhappy path tests for this? For example, is there any circumstance in which the save/fetch graph object should fail? (e.g. user not logged 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.
For fetching, maybe yes! But for saving, I have checked for the login redirect!
Thank you @IshaGupta18 ! I left some comments, I hope they are helpful :) |
Hi!!! Does this include all the commits from #5993? If so, I'd prefer to merge this instead of that, to do it all in one. That way the tests and functionality are linked! |
Yes this does, however I have a couple of bugs to fix in this one, then
it's good for merge! Thanks a lot!
…On Mon, Aug 5, 2019, 11:09 AM Jeffrey Warren ***@***.***> wrote:
Hi!!! Does this include all the commits from #5993
<#5993>? If so, I'd prefer to
merge this instead of that, to do it all in one. That way the tests and
functionality are linked!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6104?email_source=notifications&email_token=AJXHQZ6CW3NCM2YY6X2G6P3QC64KVA5CNFSM4IJFYZLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QXQ5Y#issuecomment-518092919>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJXHQZ6EL3CYM734YF3OHADQC64KVANCNFSM4IJFYZLA>
.
|
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.
Just wondering a bit about the flow and left a question above, but also would you consider adding some system tests to protect the basic workflow here?
if params[:id] && params[:uid] | ||
@graphobject = [params[:id],params[:uid]] | ||
end | ||
# byebug |
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.
Hm, is this required?
</div> | ||
<% else %> | ||
<div class="ple-module-content col-lg-9"> | ||
<% x = "Power Tag: simple-data-grapher: i/" + @graphobject[0] + "/" + @graphobject[1] %> |
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.
Hm, can you walk me through exactly what's happening here, or link to the previous PR where it's explained? Thanks!
Yes, I am will write a comment explaining the entire flow and also why both
these code snippets highlighted by you are necessary!
…On Mon, Aug 5, 2019, 11:21 AM Jeffrey Warren ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Just wondering a bit about the flow and left a question above, but also
would you consider adding some system tests to protect the basic workflow
here?
------------------------------
In app/controllers/editor_controller.rb
<#6104 (comment)>:
> @@ -20,6 +20,11 @@ def editor
end
def post
+ @graphobject = ""
+ if params[:id] && params[:uid]
+ @graphobject = [params[:id],params[:uid]]
+ end
+ # byebug
Hm, is this required?
------------------------------
In app/views/editor/rich.html.erb
<#6104 (comment)>:
> </div>
-
- <div class="ple-module-content col-lg-9">
- <textarea id="text-input" class="ple-textarea form-control"><% if @node && @node.latest && @node.latest.body_rich %><%= @node.latest.body %><% else %><%= params[:body] %><% end %></textarea>
- </div>
+ <% if @graphobject=="" %>
+ <div class="ple-module-content col-lg-9">
+ <textarea id="text-input" class="ple-textarea form-control"><% if @node && @node.latest && @node.latest.body_rich %><%= @node.latest.body %><% else %><%= params[:body] %><% end %></textarea>
+ </div>
+ <% else %>
+ <div class="ple-module-content col-lg-9">
+ <% x = "Power Tag: simple-data-grapher: i/" + @graphobject[0] + "/" + @graphobject[1] %>
Hm, can you walk me through exactly what's happening here, or link to the
previous PR where it's explained? Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6104?email_source=notifications&email_token=AJXHQZ2P2KSZF7U4WFL3LJTQC65VNA5CNFSM4IJFYZLKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCAQH6YY#pullrequestreview-270565219>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJXHQZYCF3KWHQH3GGQYKQ3QC65VNANCNFSM4IJFYZLA>
.
|
Okay so here is the flow of things, a part of which I will be borrowing from my comment in publiclab/simple-data-grapher#65. The User clicks on "Publish as a Research Note" button We need this Once we get this, we give the control to the The global variable There, we just use a simple if condition, to check if we need to insert a power tag for simple-data-grapher or not. The remaining flow is as described in this comment And voila! We have a chart here! I know this sounds a little complicated at first, but throughout my research in being able to accomplish this, this is the best method I have been able to find, without hampering much of the existing code. The remaining flow is pretty standard, I have just introduced 2-3 extra lines in editor controller and rih.html.erb. Let me know if you follow this! |
This looks great; can you actually merge these commits into the PR #5993, so that the tests and functionality are linked into one PR that shows both the functionality and the tests that secure them? |
OK, great, good to know, and we can close this then, right? THat way people finding this PR aren't confused (as I was! lol) |
Yes, I will be closing that one! |
Here are a few of the tests I have written for
csvfiles_controller.rb
file and I will add more as and when required.Since I have done most of my testing (logical and UI) in Simple-Data-Grapher as well, I think these will be good to go for now.
Also, this gives more confidence to #5993 which can be merged soon, now that we have tests to back it up.
@jywarren @gauravano @sagarpreet-chadha @namangupta01 kindly review this and let me know what else can be done!