QA
Senior~25 minAPI workflowsRole switchingAuthorization (403)State assertions

API: leave request workflow across two roles

App: PeopleDesk HR, a practice HR management portal (OrangeHRM-style). Login: Admin / admin123, or any employee as first.last / Welcome@1 (for example vikram.singh). REST API: tests call it as /api/... through the request fixture or page.request; GET /api lists every endpoint ↗.

Next scenario →

Interview scenario

"Leave is a two-actor workflow: an employee applies, an admin approves, and the balance moves. Automate it at the API with role switching: Vikram applies for three days of casual leave, cannot approve his own request, the admin approves it, and his available balance drops from 12 to 9."

Acceptance criteria

  1. Log in as the employee vikram.singh / Welcome@1 and assert GET /api/leave/balance shows Casual Leave available 12.
  2. POST /api/leave with toDate before fromDate returns 400 with error.details.toDate; a valid request for 2026-12-10 to 2026-12-12 is created with status Pending Approval and days 3.
  3. POST /api/leave/:id/approve as the employee returns 403.
  4. Log out, log in as Admin / admin123, find the request in GET /api/leave?status=Pending Approval, approve it, and assert status Scheduled and the employee's Casual Leave balance: used 3, available 9 (GET /api/leave/balance?employeeId=0004).

🔒 This lab is part of Pro

Pro unlocks the live editor, the scenario checks and the reference solutions in Playwright and Selenium Java for all 38 labs, plus every interview answer. One payment of ₹1,299, lifetime access. Already on a lower tier? Upgrade for the difference.