Files
breadcrumb-the-shire/tests/Architecture/ListUiSharedPartialsContractTest.php
fs 157eb18610 refactor(user-lifecycle): drop redundant titles and duplicate run-now button
Cleans up two leftover redundancies after the Phase-1 cockpit
foundation landed in cc2cf3a:

* The audit-list panel embedded inside the settings page rendered
  its own "User lifecycle logs" titlebar — a redundant heading
  below the page-level titlebar that already says exactly that.
  The embedded panel now renders the filter toolbar + grid
  directly. Page-level title carries the context.
* The Run-Now action existed twice — inline in a <details>-card
  inside the form and again in the aside Quick-Actions list. The
  inline version is gone; aside is the single discoverable home
  for policy-level danger actions, consistent with how Phase 1
  introduced Purge logs there too.
* The orphan $lastRunSummary string in the action and view stays
  removed accordingly. KPI tile "Last run" still carries the
  relative-time + status hint, so no information is lost — just
  surfaced once instead of twice.

Three architecture-test lists updated to match the panel's new
shape, each with an inline comment so future readers see why the
panel is intentionally absent:
* DetailActionPolicyContractFiles.migratedConfirmFiles drops the
  user-lifecycle settings view (its danger action delegates to the
  aside-actions partial, already in this list).
* ListUiSharedPartialsContractTest.purgeTitlebarTemplateFiles drops
  the panel (no titlebar of its own anymore).
* ListTitlebarContractFiles.titlebarTemplateFiles drops the panel
  for the same reason.

All six quality gates green; behaviour-identical to a user with the
required permission (purge + run-now both still available, just
sourced from the aside).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 20:38:15 +02:00

78 lines
3.3 KiB
PHP

<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
class ListUiSharedPartialsContractTest extends TestCase
{
use ProjectFileAssertionSupport;
/**
* @return list<string>
*/
private function listTabsTemplateFiles(): array
{
return [
'pages/admin/users/index(default).phtml',
'pages/admin/departments/index(default).phtml',
];
}
/**
* @return list<string>
*/
private function purgeTitlebarTemplateFiles(): array
{
// Note: settings-user-lifecycle-panel.phtml is intentionally absent.
// The panel is embedded inside the user-lifecycle settings page and
// delegates its purge action to the aside-actions partial — it has
// no titlebar of its own.
return [
'pages/admin/scheduled-jobs/index(default).phtml',
'modules/audit/pages/audit/api-audit/index(default).phtml',
'modules/audit/pages/audit/import-audit/index(default).phtml',
'modules/audit/pages/audit/system-audit/index(default).phtml',
];
}
public function testTabsTemplatesUseSharedTabsPartial(): void
{
foreach ($this->listTabsTemplateFiles() as $file) {
$content = $this->readProjectFile($file);
$this->assertStringContainsString("require templatePath('partials/app-list-tabs.phtml');", $content, $file);
$this->assertSame(0, preg_match('/<div\s+class=\"app-list-tabs\"/', $content), $file);
}
}
public function testPurgeTitlebarTemplatesUseSharedPurgePartial(): void
{
foreach ($this->purgeTitlebarTemplateFiles() as $file) {
$content = $this->readProjectFile($file);
$this->assertStringContainsString("require templatePath('partials/app-list-purge-action.phtml');", $content, $file);
$this->assertSame(0, preg_match('/<form\s+id=\"[^\"]*purge-form\"/', $content), $file);
$this->assertStringNotContainsString('onclick="return confirm(\'', $content, $file);
}
}
public function testTabsAndPurgePartialsExposeExpectedMarkupContract(): void
{
$tabsPartial = $this->readProjectFile('templates/partials/app-list-tabs.phtml');
$this->assertStringContainsString('class="app-list-tabs"', $tabsPartial);
$this->assertStringContainsString("class=\"<?php e(\$tabActive ? 'tab-link is-active' : 'tab-link'); ?>\"", $tabsPartial);
$purgePartial = $this->readProjectFile('templates/partials/app-list-purge-action.phtml');
$this->assertStringContainsString('method="post"', $purgePartial);
$this->assertStringContainsString('Session::getCsrfInput();', $purgePartial);
$this->assertStringContainsString('data-confirm-message="<?php e($listPurgeConfirmMessage); ?>"', $purgePartial);
$this->assertStringNotContainsString('onclick="return confirm(\'', $purgePartial);
}
public function testAppInitIncludesGlobalConfirmActionComponent(): void
{
$content = $this->readProjectFile('web/js/app-init.js');
$this->assertStringContainsString("import { initConfirmActions } from './components/app-confirm-actions.js';", $content);
$this->assertStringContainsString("runtime.register('confirm-actions', initConfirmActions", $content);
}
}