Hi guys. Oh man, am I at my wits end. I have been working on what I originally thought would be a simple problem for more than a week. I have tried every combination of done, before, after, describe, it, waitFor, setTimeout, custom methods, custom classes, Deps.autoruns, nested Deps.autoruns, and more that I can think of. Nothing works. The architecture is basically this:
Parent server (like Tomcat) sends HTTP headers to Meteor, who then uses those headers to identify the user. In production, meteor would just Meteor.call('MySystem.getSelf'), and on the server it gets the headers, identifies the user based on connection id and returns the appropriate database record.
The problem is in TESTING. I have to have a fixture, which is a Meteor.method('/fixtures/client/setheaders'), where in the package I hijack the headers calls on the server. OK, easy enough.
But here's the problem. I have various describes/its, like
describe('Getting info on self',
describe('no valid headers
it(should only get basic info from getSelf
describe("normal user logged on
it(should get certain useful information about self
describe("admin user
it(should get everything available about self
The problem is that I have to logon by invoking both the fixtures call and then the getself call, both with callbacks. Any type of "logon" causes all of the describe functions to step all over each other, no matter what I do. For example, if I use beforeEach(done), what will happen is guest will logon, be marked as done, then normal user will logon, be marked as done, then guest will fail the "it" test because it's got user information for the normal user.
Each of these describe tests must be run, with callbacks available, serially. I need some way to logon, run my tests, then logoff. The callbacks cannot interfere with each other, as there is only one connection and only one connection id.
The only other thing I can think of at this point is to actually integrate testing code into my production code, so that the server-side "getSelf" somehow knows to send the correct data back. Since it currently uses a connection id, and there is only one connection id for the client side tests, there just doesn't seem to be any way to do this, much less a good way.
Help! Does anyone have any good ideas?
Thank you,
David Logan