Protected logic
Summary
- Install
playwright-persona. Why it's needed. - In
test-extend.ts, usedefinePersonato define a new authentication persona. Explain what a persona is and what steps it has when defining. - Go through the
createSession,verifySession, anddestroySessionimplementation steps. Summarize when persona will call these methods during the test life-cycle. - Create a new fixture called
authenticateusing thecombinePersonasutility fromplaywright-persona.
- Create a new test at
tests/e2e/notes-create.test.ts. - Use the new
authenticatefixture to authenticate as auserpersona. Get the returneduserobject to use its data in the test. - Go to a protected route, e.g. to create a new note.
- Fill in the new note form and submit it.
- Verify the new note is visible and has the correct content.
npm run test:e2e.
- Talk a bit more about personas and testing authentication-dependent logic, how it differs from testing authentication itself (where you don't need personas).