feat(helpdesk): add domain linking, bulk actions, and revision polish to handovers
Adds domain selection (cascaded from debitor) to handover creation and edit, bulk delete with confirmation dialog, and various UI improvements to the handover wizard and list page. Includes migration for domain columns, domain-select AJAX endpoint, and updated tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -153,8 +153,11 @@ class HandoverRevisionServiceTest extends TestCase
|
||||
'field_values' => '{"name":"Current value"}',
|
||||
'schema_snapshot' => '{"version":1,"fields":[]}',
|
||||
]);
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues');
|
||||
$handoverRepo->expects($this->once())->method('updateStatus');
|
||||
$handoverRepo->expects($this->once())->method('beginTransaction');
|
||||
$handoverRepo->expects($this->once())->method('commitTransaction');
|
||||
$handoverRepo->expects($this->never())->method('rollbackTransaction');
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues')->willReturn(true);
|
||||
$handoverRepo->expects($this->once())->method('updateStatus')->willReturn(true);
|
||||
|
||||
$service = $this->createService($revisionRepo, $handoverRepo);
|
||||
$result = $service->restoreRevision(self::TENANT_ID, self::HANDOVER_ID, 2, self::USER_ID, HandoverService::PERMISSION_MANAGE);
|
||||
@@ -181,7 +184,10 @@ class HandoverRevisionServiceTest extends TestCase
|
||||
'field_values' => '{"name":"Current"}',
|
||||
'schema_snapshot' => '{"version":1,"fields":[]}',
|
||||
]);
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues');
|
||||
$handoverRepo->expects($this->once())->method('beginTransaction');
|
||||
$handoverRepo->expects($this->once())->method('commitTransaction');
|
||||
$handoverRepo->expects($this->never())->method('rollbackTransaction');
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues')->willReturn(true);
|
||||
$handoverRepo->expects($this->never())->method('updateStatus');
|
||||
|
||||
$service = $this->createService($revisionRepo, $handoverRepo);
|
||||
@@ -189,4 +195,66 @@ class HandoverRevisionServiceTest extends TestCase
|
||||
|
||||
$this->assertTrue($result['ok']);
|
||||
}
|
||||
|
||||
public function testRestoreRevisionRollsBackWhenFieldUpdateFails(): void
|
||||
{
|
||||
$revisionRepo = $this->createMock(HandoverRevisionRepository::class);
|
||||
$revisionRepo->method('findByRevision')->willReturn([
|
||||
'id' => 1,
|
||||
'revision' => 1,
|
||||
'field_values' => '{"name":"Old"}',
|
||||
'status' => 'draft',
|
||||
]);
|
||||
$revisionRepo->expects($this->never())->method('insert');
|
||||
|
||||
$handoverRepo = $this->createMock(HandoverRepository::class);
|
||||
$handoverRepo->method('findById')->willReturn([
|
||||
'id' => self::HANDOVER_ID,
|
||||
'status' => 'draft',
|
||||
'field_values' => '{"name":"Current"}',
|
||||
'schema_snapshot' => '{"version":1,"fields":[]}',
|
||||
]);
|
||||
$handoverRepo->expects($this->once())->method('beginTransaction');
|
||||
$handoverRepo->expects($this->once())->method('rollbackTransaction');
|
||||
$handoverRepo->expects($this->never())->method('commitTransaction');
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues')->willReturn(false);
|
||||
$handoverRepo->expects($this->never())->method('updateStatus');
|
||||
|
||||
$service = $this->createService($revisionRepo, $handoverRepo);
|
||||
$result = $service->restoreRevision(self::TENANT_ID, self::HANDOVER_ID, 1, self::USER_ID, HandoverService::PERMISSION_MANAGE);
|
||||
|
||||
$this->assertFalse($result['ok']);
|
||||
$this->assertArrayHasKey('general', $result['errors']);
|
||||
}
|
||||
|
||||
public function testRestoreRevisionRollsBackWhenRevisionInsertFails(): void
|
||||
{
|
||||
$revisionRepo = $this->createMock(HandoverRevisionRepository::class);
|
||||
$revisionRepo->method('findByRevision')->willReturn([
|
||||
'id' => 1,
|
||||
'revision' => 1,
|
||||
'field_values' => '{"name":"Old"}',
|
||||
'status' => 'draft',
|
||||
]);
|
||||
$revisionRepo->method('getLatestRevisionNumber')->willReturn(3);
|
||||
$revisionRepo->expects($this->once())->method('insert')->willReturn(null);
|
||||
|
||||
$handoverRepo = $this->createMock(HandoverRepository::class);
|
||||
$handoverRepo->method('findById')->willReturn([
|
||||
'id' => self::HANDOVER_ID,
|
||||
'status' => 'draft',
|
||||
'field_values' => '{"name":"Current"}',
|
||||
'schema_snapshot' => '{"version":1,"fields":[]}',
|
||||
]);
|
||||
$handoverRepo->expects($this->once())->method('beginTransaction');
|
||||
$handoverRepo->expects($this->once())->method('rollbackTransaction');
|
||||
$handoverRepo->expects($this->never())->method('commitTransaction');
|
||||
$handoverRepo->expects($this->once())->method('updateFieldValues')->willReturn(true);
|
||||
$handoverRepo->expects($this->never())->method('updateStatus');
|
||||
|
||||
$service = $this->createService($revisionRepo, $handoverRepo);
|
||||
$result = $service->restoreRevision(self::TENANT_ID, self::HANDOVER_ID, 1, self::USER_ID, HandoverService::PERMISSION_MANAGE);
|
||||
|
||||
$this->assertFalse($result['ok']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user