getPathname());
if (isModalOrForm($path)) {
continue;
}
$source = $file->getContents();
// Look only INSIDE
… | : a field in a table cell is an inline
// editor by definition. Fields elsewhere on the page are a form.
foreach (preg_split('##', $source) as $segment) {
$open = strrpos($segment, ' is page, not row. Without this the whole file counted as
// one cell and every ordinary form failed.
if ($open === false) {
continue;
}
$cell = substr($segment, $open);
if (preg_match('#<(input|textarea)\b(?![^>]*type="(checkbox|radio|hidden)")#', $cell, $m)) {
$offenders[$path][] = trim(strtok(ltrim($cell), "\n") ?: $m[0]);
}
}
}
expect($offenders)->toBe([]);
});
it('reaches every edit modal through openModal', function () {
// An edit button that calls a method on the page component instead of
// dispatching openModal is the inline editor coming back under a new name.
$modals = collect(File::allFiles(app_path('Livewire')))
->filter(fn ($f) => str_contains($f->getContents(), 'extends ModalComponent'))
->map(fn ($f) => $f->getFilenameWithoutExtension())
->values();
expect($modals)->toContain('EditSeat')
->and($modals)->toContain('EditDatacenter');
// And the seats table actually opens it.
$users = File::get(resource_path('views/livewire/users.blade.php'));
expect($users)->toContain("component: 'edit-seat'");
});
|