Meteor-Community-Packages / meteor-user-status

Track user connection state and inactivity in Meteor.
MIT License
557 stars 85 forks source link

Best way to create some test Users that are always "online"? #45

Open fuzzybabybunny opened 9 years ago

fuzzybabybunny commented 9 years ago

Since I'm developing on my own, I would like to create several test user accounts (created initially in fixtures) that are always "online." What's the best way to do this? Even if I set status.online: true in the fixtures (via Accounts.onCreateUser()) I bet it would just get changed to false as soon as the package runs.

fuzzybabybunny commented 9 years ago

Haha, I guess I could just have like 5 browser tabs open at the same time each with a different user logged in.

mizzao commented 9 years ago

Yep, multiple browsers are the way to go. You can't actually use the same browser with different tabs because they will share a login token through local storage.

fuzzybabybunny commented 9 years ago

Hmmm... well, the issue is that I'm building a geo-location app. The online users all should have a different GPS coordinate. So if we have multiple online users via the multiple-browser method, all of the "users" would have the exact same GPS coordinate, haha, which is of limited use.

mizzao commented 9 years ago

In the tests for this package, we can create and change the status of connected users. However, I'm not sure that Meteor allows accessing test code of other packages yet. You can take a look at how that is done, and maybe do the same for the situation you are trying to create.

illuminaut commented 9 years ago

incognito mode doesn't share storage with the regular mode, so that's one extra user you can use per browser. I have tested with quite a few simultaneous logins that way, running on chrome and firefox on the desktop, phone and tablet.

mizzao commented 9 years ago

@illuminaut yep, I do that too.

mizzao commented 9 years ago

@fuzzybabybunny you can always have your test fixtures create and delete accounts in the setup and teardown phases of your test, too. UserStatus only clears stuff when it's starting up. I think some of the tests in this package also rely on that to work.

mizzao commented 9 years ago

As a follow-up to this, see https://github.com/mizzao/cooperation-loadtest for a way to use one Meteor app to use DDP to connect to another Meteor app and mimic real connections. This is probably about as good as it gets without actually using real browser tabs.