# Write Tests for a Filament Admin Panel

An agent writes Pest tests for the 11 Filament relation managers that had none, taking composer test:pest from 490 to 601 passing tests.

[Run this on Rush](https://cloud.getrush.ai/run/write-filament-tests/filament/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent lists every resource page and relation manager under `app/Filament` against `tests/Filament` first. In this panel every resource page already had a test; 11 relation managers across the HR and Shop resources had none.

Each new test mounts its manager with `Livewire::test(..., ['ownerRecord' => ..., 'pageClass' => ...])` as `CommentsRelationManagerTest` does and checks, with factory records, that the table lists only the owner's rows. Create, edit, delete and filter cases follow what each manager has: the Project `TasksRelationManager` filters by status, priority and assignee, the Brand and Category `ProductsRelationManager`s are tested through `applyTableFilters` on their query-builder filter, and read-only managers are checked for absent actions.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Write Pest tests with Filament's Livewire testing helpers for the parts of this panel that have none. First list every resource page and relation manager under app/Filament and the tests under tests/Filament, and work only on the ones without a test. For each relation manager, mount it with Livewire::test(..., ['ownerRecord' => ..., 'pageClass' => ...]) like CommentsRelationManagerTest and cover: it renders, the table shows only the owner's records, create with valid data and with each required field missing, edit and delete actions, and each table filter. Use the model factories. Set up the environment as .github/workflows/tests.yml does, run composer test:pest until it passes, and open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on filamentphp/demo at 124bdfd: 11 files changed, 1049 insertions(+), all new tests under `tests/Filament/Resources/`. `composer test:pest` went from `Tests:    10 skipped, 490 passed (2747 assertions)` to `Tests:    10 skipped, 601 passed (3353 assertions)`, exit 0, and Pint returned `{"tool":"pint","result":"passed"}`. The agent installed PHP 8.4.27 with `gd` itself to follow `.github/workflows/tests.yml`. Its Postgres reset step was not run, and no pull request was opened. The run copied the diff to `/workspace/.rush/artifacts/`, but capture keeps no `.diff` file, so it did not come back; the answer names only the 11 files.

For the reviewer: `DepartmentResource` has only `ManageDepartments`, which the test uses as `pageClass`, so its `EmployeesRelationManager` looks unreachable in the UI; keep the test or delete the manager. The Tasks delete action is a deliberate no-op, so its test asserts the notification and that the row stays.

## Run it on every night at 2 a.m. Pacific

The nightly tests automation has a `schedule` trigger on cron `0 2 * * *` in America/Los_Angeles, with this request as its prompt. Because the request starts by listing what under `app/Filament` has no test, a relation manager added during the day is picked up the next night.

## Why run it on Rush?

The panel looked fully tested because every resource page had a test, yet 11 relation managers had none. Writing them surfaced a manager with no page to host it. Without PHP's `gd` extension the untouched suite had 74 `CouldNotLoadImage` failures.

## Frequently asked questions

### What do the tests check on a manager with no required fields?

Both Addresses managers have no required fields and an empty filter list, so instead of missing-field cases their tests check that an empty create succeeds, alongside rendering and owner scoping.

### Was the full CI workflow reproduced?

All but its last step. The agent ran the workflow's setup, from `.env` and `composer install` through `npm run build` to the SQLite file. The `ResetDemoDatabaseTest` step on `pgsql` was skipped: the sandbox had no Postgres service or `pgsql` extension.

## More Filament jobs

- [Add an Audit Log to a Filament Admin Panel](https://getrush.ai/run/add-audit-log/filament/)
- [Add a Blog Dashboard to a Filament Admin Panel from a Linear Issue](https://getrush.ai/run/add-blog-dashboard/filament/)
- [Add a Bulk Export Action to a Filament Table from a Linear Issue](https://getrush.ai/run/add-bulk-export/filament/)

## More jobs like this: Write the missing tests

- [Validate a GitOps Repository Before Argo CD Syncs It](https://getrush.ai/run/write-gitops-validation/kustomize/)
- [Write Golden Tests for a Flutter App](https://getrush.ai/run/write-golden-tests/flutter/)
- [Write GraphQL API Tests for a Spring Boot App](https://getrush.ai/run/write-graphql-tests/spring-boot/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
