Closed weswalla closed 4 months ago
@pepoospina I am unable to run the tests fully since I am having issues with twitter developer account authentication (see discord message). But if all the tests pass I'd say this is ready to merge.
Note that I consolidated some environment variables, so now it expects TEST_USER_TWITTER_ACCOUNTS
which looks like:
TEST_USER_TWITTER_ACCOUNTS=[{"user_id": "1773032135814717440", "username": "sense_nets_bot","password": "PASSWORD"}, {"user_id": "1742000911797366784", "username": "sense_nets", "password": "PASSWORD"}]
I included the user_id in the end so that we can use just this environment variable when created test app users (which need a userId). I no longer use TEST_USERS_BEARER_TOKENS
This is also set up to be able to authenticate any number of twitter account that is specified in the environment variable along with the NUM_TWITTER_USERS
constant.
@weswalla, a few suggestions here:
1) maybe we can change a bit the structure so that the authenticateTwitterUsers.ts
is renamed to authenticate.users.ts
and, instead of returning the TwitterUserDetails[]
, it returns already an array of type AppUserCreate[]
.
This way we handle entire user profiles and not just twitter credentials as the thing that is computed and stored on a file.
2) createTestAppUsers
can receive a string[]
with the userIds
of the users that should be created. This way each test can decide which users are created that are relevant for them. Internally, createTestAppUsers
will read the users objects for thos userIds
from the global testTwitterAccountTokens
map, which can be renamed to testUsers
.
3) The files inside __test_support__
can be moved into utils
and __test_support__
can be removed.
WDYT?
@weswalla, Also, I suggest we keep the file's naming convention to lowercase with dots :)
Sure @pepoospina that all sounds good to me, I wasn't clear on conventions so just went ahead with this approach knowing we would change it with some feedback. Happy to use that file naming convention.
@pepoospina I have integrated your feedback. The only things that remain (which could be handled in another PR) are:
We can now use puppeteer to automatically go through the oauth authorization flow. However, it only seems to work if we run puppeteer NOT in headless mode (you will see a browser window open up and the information being put in to the form). It also takes ~10 seconds in total.![image](https://github.com/Common-SenseMakers/sensemakers/assets/39413655/9a760317-e955-497d-b651-3d4387562d4b)
You also need to store use credentials in the
.env.test
file, like so: