freeCodeCamp / publish

> Content backend platform for /news
https://publish.freecodecamp.org
BSD 3-Clause "New" or "Revised" License
10 stars 9 forks source link

test(e2e): user becomes active on signin #359

Closed ojeytonwilliams closed 10 months ago

ojeytonwilliams commented 10 months ago

Checklist:

As well as testing the first sign in, I wanted to provide an example of the kinds of tests I think we should be writing.

The basic idea is that each suite should follow the form

  1. Prepare the server for the each test, via api calls (not seed scripts)
  2. Undo any changes to the server state after all tests haves run, again via api calls

This gives us a couple of nice benefits. Avoiding the relatively expensive seeding step means the tests should be faster. In principle these tests can be run against any version of the site that accepts the api calls. i.e. they could run against a deployed test site.

ojeytonwilliams commented 10 months ago

Sorry for the notification spam (last one...). It took me a while to understand how to test the effect of signing in with a new user (basically follow the playwright docs) but I'm finally happy with this.

Sembauke commented 10 months ago

I might have missed something, but the tests seem to be failing locally for me.

image
ojeytonwilliams commented 10 months ago

@Sembauke it looks like your db is missing the invited user. As we discussed in chat, a reset-db script would be helpful to resolve cases like this. Then you could run that script, then seed again and it should be resolved.

Regardless, dropping the db and seeding again should resolve this.

sidemt commented 10 months ago

Also, I get the same error as Sem even with seeding against a fresh DB. I'm not 100% sure but it seems the test run in parallel making the tests related to invited status fail. https://playwright.dev/docs/test-parallel

If I set --workers=1 those tests passed. But after all, I couldn't get rid of a timeout error (could be because of my machine) image