/laravel:e2e-filament-multitenantfrom laravel
Use this skill to write, expand, or structure Playwright end-to-end tests for a Laravel + Filament (Spatie-permission) application, especially multi-tenant apps with several panels/roles. Triggers when the user says "add e2e tests", "cover all roles", "write Playwright tests for the panels", "test each role", "e2e coverage per role", or asks to set up Playwright against a Filament admin/tenant panel. It covers the per-role storageState auth model, shared helpers, a per-role coverage matrix (CRUD / state-machine workflows / permission boundaries / tenant isolation), a deterministic test-data strategy, the CI job recipe, and Filament-specific selector conventions. Use it before scaffolding e2e/ so the suite stays maintainable and the role/permission boundaries are actually asserted.
Ships in laravel. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Build a Playwright E2E suite that proves each role can do what it should and cannot do what it shouldn't, across every Filament panel — including tenant isolation. Work phase by phase; do not jump to writing specs before the discovery and infrastructure phases are done.
Before writing any test, map the surface from source (never guess labels):
app/Providers/Filament/*PanelProvider.php to list panels,
their path prefixes, and whether they are tenant-scoped (->tenant(...)). Read the
roles/permissions source of truth (e.g. database/permissions.yaml + the
RolesAndPermissionsSeeder), and the seeders for the test users/workspaces.Select + email + password) for
tenant-scoped panels. Read the custom Login page class to learn the exact field
label and any post-auth membership check (and its error message).ViewRecord/EditRecord page, read getHeaderActions() and the resource's
canCreate()/canEdit()/canViewAny() overrides. Record the literal ->label()
strings, notification titles (Notification::make()->title(...)), form field labels,
and the ->visible(fn () => $state->is(...)) guards. These literals are the
contract your assertions check.spatie/laravel-model-states) — note the state order and
which transition each action performs. Watch for cross-role gates: a single role
often cannot drive the whole lifecycle because the next action is only visible in a
state that a different role produces. Plan to test transitions in isolation, not as
one long chain.Summarize findings as a per-role table before proceeding.
storageStateUse one Playwright setup project that logs each role in once and saves its session,
then one project per role that reuses it:
// playwright.config.ts (sketch)
projects: [
{ name: 'setup', testMatch: /auth\.setup\.ts/ },
{ name: 'admin', dependencies: ['setup'],
use: { ...devices['Desktop Chrome'], storageState: 'e2e/.auth/admin.json' },
testMatch: /admin\/.*\.spec\.ts/ },
// ...one per role; roles sharing a panel (e.g. jobcoach vs super-jobcoach)
// get separate projects pointing at the same spec glob and branch on
// test.info().project.name
]
Config conventions worth adopting:
forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 1,
workers: process.env.CI ? 1 : undefined, fullyParallel: true,
use.viewport: { width: 1920, height: 1080 }, use.trace: 'on-first-retry',
use.baseURL: process.env.APP_URL ?? 'http://localhost'.
Create e2e/helpers/:
auth.ts — loginStandard(page, url, email, pw) and loginTenant(page, url, email, pw, workspaceName) (open the Select, getByRole('option', { name })). The auth.setup.ts imports these; spec files never reach into the setup file.panels.ts — panelUrl(role, slug, path) builders + the known workspace slugs.filament.ts — clickHeaderAction(label), confirmModal() (scope to getByRole('dialog')), submitActionForm(fields), expectStateBadge(label), expectActionAbsent(label) (assert toHaveCount(0)), expectForbidden() (cross-tenant 403/redirect — confirm the app's actual behavior once and standardize).Split specs by role, then by resource within the role:
e2e/
helpers/{auth,panels,filament}.ts
auth.setup.ts
<role>/{<resource>,permissions-isolation}.spec.ts
Most seeders only create users — list pages pass while empty, so smoke tests give
false confidence. Add a dedicated E2eSeeder (factory-built) that creates one record
per pivotal state so each workflow test gets a forward-only, single-consumer record
with a stable reference for deep-linking. Guard it behind an env/--seeder flag so it
doesn't pollute normal seeds. Three data buckets:
For every role, cover four categories. Add package scripts to package.json:
test:e2e:install (playwright install --with-deps chromium), test:e2e,
test:e2e:ui, test:e2e:headed, test:e2e:debug, test:e2e:report, test:e2e:codegen.
| Category | What to assert |
|---|---|
| HP Happy-path CRUD | Create/edit/view each resource the role may manage; assert the row/toast appears. |
| WF State workflows | One isolated test per transition action — load a record already in the required state, click the action (handle confirm/form modals), assert the exact notification title + the new state badge. Required-comment forms ⇒ also assert empty submit is blocked. |
| NEG Permission boundaries | For things the role must NOT do, assert the nav item / create button / header action is absent (toHaveCount(0)), not merely hidden. |
| ISO Tenant isolation | Deep-link to another tenant's URL and a record the role shouldn't see ⇒ assert 403/redirect. Plus: logging in with a workspace the user isn't a member of ⇒ assert the membership error. |
Roles that share a panel but differ in scope (e.g. a "super" variant with view-any):
reuse the spec and branch extra assertions on test.info().project.name.
<pm> is the project's Node package manager (npm, pnpm or yarn), detected as described in the "Node
package manager" section of the executing-commands skill (php plugin). Never assume npm.
Specs projects run E2E through Docker and Task, against the real stack — not artisan serve. Add a
job to the existing CI workflow that mirrors .taskfiles/Taskfile.e2e.yml. The task names below are
the Specs template's; in other projects use their equivalents (see "Specs task names and project
equivalents" in executing-commands), and name the commands that actually ran in the workflow and
the report.
go-task/setup-task), create auth.json from COMPOSER_AUTH_JSON, warm the package
manager cache with actions/setup-node (its cache: must match the project's package manager:
npm, pnpm or yarn; pnpm also needs pnpm/action-setup before it).task ci:up, or the project's equivalent — the CI variant of task up: env files, composer:install, <pm>:install, compose
up, key:generate, storage:link, wait for the DB, db:migrate-fresh:local, <pm>:script:build.
Filament won't render without that asset build.task 'artisan:run:db:seed' -- --class='Database\Seeders\E2ETestSeeder'.task e2e:docker:test — runs <pm> run test:e2e inside the e2e-playwright compose service, so
the browsers come from the image and need no playwright install step.playwright-report/ with if: always(); upload traces on failure.Locally (or with the project's equivalents): task e2e:setup once for host browsers, then task e2e:test (UI) or
task e2e:test:headless; task e2e:docker:test reproduces CI exactly.
Start with --workers=1 for determinism; raise once the data strategy is proven parallel-safe.
getByRole('link'|'button', { name }), getByLabel(...), getByRole('heading', { name }), getByRole('option', { name }). Avoid CSS/XPath and generated wire: ids.getByRole('dialog'); for requiresConfirmation() actions click the confirm button inside it; for form-modal actions fill the labelled field then submit.toHaveCount(0), never not.toBeVisible() on an element that never renders.waitForTimeout.task e2e:test:headless, or the project's equivalent) and in CI (task e2e:docker:test).What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub specsnl/agent-skills --plugin laravel2 skills in this plugin