-
Notifications
You must be signed in to change notification settings - Fork 78
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
[WIP] Test indigeneous layers #222
Conversation
@sagarpreet-chadha @rexagod @jywarren , this is simple test to load the fixture and test. Also can someone pls explain this line of code
Thanks!! |
Okay so this piece of code basically tests the presence of rectangles on the PLpeople layer and it should be more than lets say 10 (maybe more than 100 depending on the zoom level) . Similarly you can test the presence of Polygon in the indigineous layers . Thanks |
Hey @sagarpreet-chadha is the PLpeople layer fixture file working ? The LBLD scrips are not loading due to which the PLpeople layer fixture doesn't work as it needs this script |
Hey @sagarpreet-chadha I see in some PR the changes you made in index.html for PLpeoples layer has been removed by mistake in the master branch. I guess this happened during index.html refactoring... |
Hey @sagarpreet-chadha @rexagod , I have written tests for these layers but while testing them locally I face these issues. I have followed a similar approach for the indigenous layers but it doesn't seem to work locally. |
Why is load fixture not defined ? |
Seems like a |
Hey @rexagod , no I am not using grunt to load this. |
It seems |
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.
Hey @ananyaarun ,
First try the possible solution by @rexagod , then do take a look at this PR (publiclab/leaflet-blurred-location-display#52) where i faced this exactly same issue and found a work way around 😄 !
This is so exciting to see!!!! Great work, all!
…On Sun, Jul 7, 2019 at 11:05 AM Sagarpreet Chadha ***@***.***> wrote:
***@***.**** commented on this pull request.
Hey @ananyaarun <https://github.com/ananyaarun> ,
First try the possible solution by @rexagod <https://github.com/rexagod>
, then do take a look at this PR (
publiclab/leaflet-blurred-location-display#52
<publiclab/leaflet-blurred-location-display#52>)
where i faced this exactly same issue and found a work way around 😄 !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=AAAF6J2RFEN6J7ZMIB5USQLP6IA25A5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB5VGL5A#pullrequestreview-258631156>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6JYGZASPDTB2QI7UNKLP6IA25ANCNFSM4H5GSSUA>
.
|
Hey Thanks everyone !! |
Hi @ananyaarun , what is the progress here? Do you need help here ? |
Hey @sagarpreet-chadha yes, So I have written tests for the 3 indigenous land layers which I suppose are correct (as per the html code I see once the polygons load). The thing is once you choose these layers, the polygons don't appear instantly like for example PLpeoples layer where grids appear instantly, and the childnode divs are only created after zooming in multiple times after a while. Hence the tests I have written fail , I am trying a lot of trial and error with the zoom values to get them to pass but they are failing atm. |
Here @jywarren , this is the PR for writing tests |
Great, thanks. Maybe copy in the Spy code I linked to from the Open Call
notes? I hope that was helpful? I /believe/ it can help in essentially
following an asynchronous event and allowing you to test something only
when it's complete:
https://jasmine.github.io/2.0/introduction.html#section-Spies
…On Tue, Jul 9, 2019 at 2:13 PM Ananya Arun ***@***.***> wrote:
Here @jywarren <https://github.com/jywarren> , this is the PR for writing
tests
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=AAAF6J6OKIVIXWSBDGDYECDP6TIJHA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZRCM6Q#issuecomment-509748858>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J4IZBQOBVCTKTBDRLLP6TIJHANCNFSM4H5GSSUA>
.
|
Sure @jywarren I'll give that and what @sagarpreet-chadha said a try :) |
Hey @sagarpreet-chadha Im really stuck on this one. Also you said something on the call the other day about loading only one marker in the fixture file.... Can you pls review this once if possible. |
|
||
it("Checks if layer polygons are present", function () { | ||
// There should be atleast one polygon in the Language layer always . | ||
expect($("#map").children()[0].childNodes[2].childNodes[0].childNodes[0].childNodes.length).toBeGreaterThan(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.
Hi...this is correct testing .
But you have to understand that these rectangles are made from a remote API, hence it takes time for these rectangles to appear on page, right?
So there are two things you should try in the following order:
-
Try to preempt the execution of test till the rectangles appear on website .
https://jasmine.github.io/tutorials/async -
If the asynchronous approach of testing does not works for some reason, what we can do is to look at what we have to actually test i.e the layer should be loaded when the respective function is called , right?
So what we can do is basically in the fixture add a L.polygon object on the map and test if it occurs on map .
In this way atleast we can test that the layer is being loaded or not . Later we can test if the actual data is getting loaded from remote API or not . Makes sense?
cc @jywarren
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.
Thanks,
I'll give this another try and get back to you.
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.
The async methods don't seem to work.
I'll try the 2nd method @sagarpreet-chadha
Hey @sagarpreet-chadha @rexagod I wrote a very basic test like this just to test and that is failing too I really don't know why.
PS: Over here i am just checking if it is greater than -1 Map is the div id whose child node we are accessing. Same is done in the PLpeople layer tests. Please let me know if You figure out, Thanks |
Okay i am going through it . Thanks!
…On Sunday, August 4, 2019, Ananya Arun ***@***.***> wrote:
Hey @sagarpreet-chadha <https://github.com/sagarpreet-chadha> @rexagod
<https://github.com/rexagod>
I am pretty sure my tests are correct now and I have used the second
method for testing.
I have added a polygon abject and I am testing.
There is a problem I am facing 3 days now which I really don't know how to
go about.
My tests still fail!!
[image: error]
<https://user-images.githubusercontent.com/32260628/62415619-4ef49e00-b64a-11e9-8f3d-47407d851ba4.png>
I wrote a very basic test like this just to test and that is failing too I
really don't know why.
it("Checks if layer polygons are present", function () {
expect($("#map").children()[0].childNodes.length).toBeGreaterThan(-1) ;
});
Map is the div id whose child node we are accessing. Same is done in the
PLpeople layer tests.
I really do not understand the undefined object error.
Please let me know if You figure out, Thanks
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=ADSCRRIFJBOBE23Z3MC52X3QCXGL3A5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PTVCY#issuecomment-517945995>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADSCRRMG54FBIVLZYIOHVGTQCXGL3ANCNFSM4H5GSSUA>
.
|
Sure Thanks @sagarpreet-chadha :) |
Yes lets start with this . Thanks!
…On Sunday, August 11, 2019, Ananya Arun ***@***.***> wrote:
Sure Thanks @sagarpreet-chadha <https://github.com/sagarpreet-chadha> :)
Can we start discussion on this issue ?
#175
<#175>
Or is there other issues that are priority ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=ADSCRRITJJ5VY2X6L24K3RDQD4OWVA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4AUI2I#issuecomment-520176745>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADSCRRJYO564BRV66PTCLR3QD4OWVANCNFSM4H5GSSUA>
.
|
@sagarpreet-chadha @rexagod can we discuss this in todays open call ? |
Okay yes we should!
…On Tue, 13 Aug 2019, 15:35 Ananya Arun, ***@***.***> wrote:
@sagarpreet-chadha <https://github.com/sagarpreet-chadha> @rexagod
<https://github.com/rexagod> can we discuss this in todays open call ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=ADSCRRIF363NTTYPA6LXHKTQEKBNNA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4FF7PA#issuecomment-520773564>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADSCRRNFNPZILZO3HNG2NCDQEKBNNANCNFSM4H5GSSUA>
.
|
@jywarren , i think we should change our testing framework if we need to test properly . Jasmine is giving a lot of issues . |
Hm, that's too bad. Would you suggest another? Mocha? Sounds frustrating!
If I read above will i learn about the issues and should i make any
suggestions here?
…On Tue, Aug 13, 2019 at 1:35 PM Sagarpreet Chadha ***@***.***> wrote:
@jywarren <https://github.com/jywarren> , i think we should change our
testing framework if we need to test properly . Jasmine is giving a lot of
issues .
Ping me when we should discuss this . Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=AAAF6J3MNDG6NP7JKYGRDT3QELWDLA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4GMU3I#issuecomment-520931949>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J6RL2BXHUV5GLUZ6PTQELWDLANCNFSM4H5GSSUA>
.
|
Yes the issue is described above, do give a look . Thanks
…On Wed, 14 Aug 2019, 19:20 Jeffrey Warren, ***@***.***> wrote:
Hm, that's too bad. Would you suggest another? Mocha? Sounds frustrating!
If I read above will i learn about the issues and should i make any
suggestions here?
On Tue, Aug 13, 2019 at 1:35 PM Sagarpreet Chadha <
***@***.***>
wrote:
> @jywarren <https://github.com/jywarren> , i think we should change our
> testing framework if we need to test properly . Jasmine is giving a lot
of
> issues .
> Ping me when we should discuss this . Thanks!
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#222?email_source=notifications&email_token=AAAF6J3MNDG6NP7JKYGRDT3QELWDLA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4GMU3I#issuecomment-520931949
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AAAF6J6RL2BXHUV5GLUZ6PTQELWDLANCNFSM4H5GSSUA
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=ADSCRRLN7NBCNAKXJHM6N4DQEQESHA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4I3I2Q#issuecomment-521253994>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADSCRRLV4HIRMWQCH3W4GSDQEQESHANCNFSM4H5GSSUA>
.
|
OK, i'm looking through this now -- @ananyaarun can you push up your latest changes so I can see the tests you're working with most recently? |
|
||
it("Checks if layer polygons are present", function () { | ||
// There should be atleast one polygon in the Territories layer always . | ||
expect($("#map").children()[0].childNodes[2].childNodes[0].childNodes[0].childNodes.length).toBeGreaterThan(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.
What I might do is to break this into different lines so we can narrow down what is undefined. So
expect($("#map").children()[0].childNodes[2].childNodes[0].childNodes[0].childNodes.length).toBeGreaterThan(1); | |
expect($("#map") | |
.children()[0] | |
.childNodes[2] | |
.childNodes[0] | |
.childNodes[0] | |
.childNodes.length) | |
.toBeGreaterThan(1); |
Maybe? Second, if you look at this example:
It does a pattern like you("walk west toward the torch and arrive there shortly after.", function(done) {
then when the function is supposed to be complete, it calls done()
. That allows us to peg completion of the test to something that may not complete immediately.
Here is a pattern for simulating a remote call and running tests on the result:
It may also be helpful!
Hey @jywarren , the latest tests are already pushed.
|
Also I wanted to apologize for not being available earlier to help with this. It sounds very frustrating. UI testing of remote and asynchronous events is quite complex and I really appreciate you tackling this! Another thing we can do is this: we can develop a local data source that is stored within the fixtures folder. We can create a test-only map layer that uses the standard layer code, but points at a local resource. Then, we can run tests more simply without requiring any remote data, and it'll be more deterministic and predictable, while still testing all the standardized layer code. Could this work as well? |
No Problem @jywarren Since the async method kept giving errors, i infact did the method you just suggested above. I wrote a very basic test like this just to test and that is failing too I really don't know why.
PS: Over here i am just checking if it is greater than -1 |
Hm. Are you sure it just seems immediate vs. is actually immediate from a
code perspective? Even for a local file there will be some asynchronicity
when compared to how fast the tests run. You may need to use the spy
technique i linked to - or are you saying you already tried that too?
Thanks!
…On Thu, Aug 15, 2019 at 4:59 PM Ananya Arun ***@***.***> wrote:
No Problem @jywarren <https://github.com/jywarren>
It was a nice challenge to work on this :)
Since the async method kept giving errors, i infact did the method you
just suggested above.
Right now in my fixture file i have a layer polygon object defined and
loaded. This does not cause any time lag problem on load. But the errors I
still get and I really cannot understand why.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=AAAF6J7FDPTNFRR2THXEHQ3QEW7QXA5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4M7OAI#issuecomment-521795329>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J4IAH2CDGG7UEUABPLQEW7QXANCNFSM4H5GSSUA>
.
|
I think (i may be wrong) if a polygon object is added in the fixture file itself it will not cause any asynchronicity related issues. |
Can you push up a PR with the spy code separately so I can see? Thanks! I'm
done today but can look into it tomorrow. Thank you!!!
…On Thu, Aug 15, 2019 at 5:06 PM Ananya Arun ***@***.***> wrote:
I think (i may be wrong) if a polygon object is added in the fixture file
itself it will not cause any asynchronicity related issues.
What is queer is why the tests fail in a case like my comment above.
I did give the spy method a try but was not able to get that working.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222?email_source=notifications&email_token=AAAF6J6SFRC64LSGYMIK6Y3QEXAK5A5CNFSM4H5GSSUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4M77LQ#issuecomment-521797550>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAF6J7XJZSXKDXKG3NLM73QEXAK5ANCNFSM4H5GSSUA>
.
|
Sure but try to look at this comment @jywarren whenever you have time tomorrow.
If we can figure this out , I know how to get the tests working with defining a polygon object and that would be a good start to have some tests in place. |
Hmm. @ananyaarun this is quite frustrating, indeed! What i found was that I can't tell why However, one clue I did find was this; I added a very simple test: it("initializes map", function () {
expect(map).not.toBeUndefined();
}); TO both the People test and to your new tests. It passed in the People test but not in yours! The second clue; I changed
Which is a different error altogether, and more like what you're looking for. So, my theory is that something is wrong with the fixtures. I haven't been able to determine what! But I'd start over with the People fixture and change it bit by bit to see what ultimately causes the |
AHA!!!!! |
Wheeeee!!!! 🎉 |
describe("Testing for indigenous Language layer", function() { | ||
|
||
beforeEach(function () { | ||
loadFixtures('indigenousLanguagesLayer.html'); |
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.
loadFixtures('indigenousLanguagesLayer.html'); | |
loadFixtures('indigenousLanguagesLayers.html'); |
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.
Oh my, I cannot believe this was my error !!
Thanks a lot @jywarren !!!!!!!!
I think that's it!!! |
Finally this PR is working @sagarpreet-chadha 🎉 |
AWESOME !!!! @jywarren and @ananyaarun 💯 🎉 |
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.
Superb 🎉
@jywarren Can you do a final review here , and this is good to merge :) |
It looks awesome. Let's merge and get these tests more universal! Thanks! |
Fixes #223
@publiclab/reviewers
for help, in a comment below