Protected logic

Up to this point you have been testing authentication as a feature. That involved preparing the server-side state (e.g. creating test users, 2FA verifications, passkey records) and going through the login flow as they would.
But your users log in into your app to do something. To post a message, edit an invoice, delete an item from their cart. All of those intentions they want to express live behind authentication, regardless of what authentication option they've chosen.
In this one, you will learn how to test any behavior behind authentication using personas.

Your task

👨‍💼 The flow you will be testing in this exercise goes like this:
  1. Given the user is logged in;
  2. And they go to their "Notes" page;
  3. And create a new note;
  4. They should see that note in the list of their notes.
You have already tackled every single step from this user scenario in the previous exercises, even if they took a slightly different shape.
But this time, there's a catch.
This time, you should start from the authenticated state, treating it as a part of your test setup. And to help you with that, you will use a third-party library called Playwright Persona.
🐨 First, install that library:
npm i playwright-persona --save-dev
🐨 Next, head to
tests/test-extend.ts
and follow the instructions to define user personas.
🐨 Once you've defined the user persona and created the authenticate() fixture, continue to the
tests/e2e/notes-create.test.ts
test suite and finish the test case here.
Verify your solution by running the tests (npm test). The tests must pass!

Please set the playground first

Loading "Protected logic"
Loading "Protected logic"

No tests here 😢 Sorry.