Letting AI Test the Work: Playwright, Build Guards and Live Verification
Three layers of testing, and the uncomfortable fact that an agent will test exactly what you told it to and nothing else
Post 39 split the author from the reviewer. This one is about what the reviewer has to prove, because “the qa agent approved it” means nothing on its own.
On the casting portal there are three layers, in the order I got burned.
Step by step
1. Guards in the build
The first layer is a handful of static checks behind npm run gates. The build refuses to start if they fail.
Three of them, I had already built into ppai. Permission coverage fails if a generated API endpoint reads a table with no table permission file next to it. The Web API exposure guard checks the field lists in the site settings against a denylist and against what the client requests: used but not exposed is a 404 in production, exposed but unused is a column someone will read in dev tools. The theme check fails on a colour token below the contrast threshold, because an agent doing an SCSS round will pick a gold that reads beautifully on nothing.
The fourth is specific to the portal. It fails if any Liquid comment block contains a tag. A fixer agent once wrapped a capture in a comment, the runtime parsed it anyway, and every API endpoint on Dev went down. The rule had been documented for months and two reviews read past it. A script does not, and never will.
Nobody removes or bypasses a guard, including an agent that finds it inconvenient. The guard commented out “just for this build” is the one you needed.
2. End-to-end with Playwright
The second layer is a Playwright suite that runs against Test after every deploy there. A release that fails it does not go to Prod.
I gave an agent the backlog for a module, the role model and the existing tests, and asked for named cases with the role, the starting page and the expected outcome. Editing that plan was the most valuable hour in the exercise. A qa agent then implemented it in rounds against the site, each round ending with a run and a list of failures.
The obstacle was authentication. Sign-in goes through an identity provider with multi-factor, which no test runner will click through. The tests use exported browser sessions instead, one for a talent and one for a caster, and nothing in the test code ever logs out. One test that signed out invalidated the session for every test after it, and the run was red for a morning before anyone read the first failure instead of the last.
3. Verify on the live site
The third layer is the one tooling can’t do for you: looking at the thing running.
The cheapest check comes first. Every generated endpoint answers /api/?type=casting&nodata=1 with a definitions_found envelope when the router, the permissions and the definitions are wired. No data query, so it proves the plumbing, not the content.
Two lessons forced the rest. The client bundle is TypeScript and compiles clean, but the DataTables API returns jQuery objects where the type definitions promised plain ones, so the code type-checked, built and did nothing in the browser. A green build proves the types agree with each other, not that the library agrees with the types.
The second is Liquid. Parameterised includes, extends and variable include paths behave the way the runtime decides, not the way the documentation hints. Each gets tested on a live site before it goes into a shared template, because an agent reading the docs will tell you it works.
The agent never runs the portal upload or the deploy workflow. I do. So an agent cannot see its own change on Dev, and its final report lists anything that needs the live site as outstanding, with what counts as a pass.
What the qa agent does
The qa agent gets a checklist, not a feeling. For a UI change: the gates pass, the relevant Playwright tests pass against Test or are listed as blocked, each acceptance criterion on the issue is marked met or not met with evidence, and the outstanding live checks are written down.
“Looks good” is not a status. The agent reports passed, failed or blocked, and the coordinator closes the task on nothing but the first.
The honest part
Tests written by an agent test what the brief said. If the brief says “cover the application form”, you get tests of the application form and none of the withdrawal on the same page. The agent is not lazy. It is precise about something you were vague about.
So the plan is where I spend the time. Which roles, which edge cases, which thing the casting director worried about. Get that into the plan and the tests are worth something. Skip it and you have a wall of green ticks and the same bug.
How to make a mess and fix it
The run is red and every test failed. Something logged out, or the exported session expired. Read the first failure, not the last.
Build is green, page is broken. The types lied. Open the browser.
A gate started failing on an unrelated change. Good. It found something. Fix the template, not the gate.
The agent reported “tested on Dev”. It cannot have. Ask what it ran.
All green, bug still shipped. The plan was missing the case. Fix the plan and the test follows.
Useful links
- Playwright authentication and storage state
- Playwright command line
- Power Pages Web API overview
- Liquid tags in Power Pages
- Power Platform CLI for Power Pages
Next: agents in the DevOps loop, reading workflows and environments instead of guessing.