feat(secretary): implement grouping of secretaries by doctor and sync profile data across links
This commit is contained in:
@@ -107,6 +107,36 @@ class ClinicSharedSecretaryTest extends ApiTestCase
|
||||
$this->assertSame(1, $body['data']['removed']); // doctor0
|
||||
}
|
||||
|
||||
public function testSyncCopiesProfileAndPermissionsToNewLinks(): void
|
||||
{
|
||||
[$owner, $clinic, $doctors] = $this->makeClinicWithDoctors(2);
|
||||
$mobile = $this->mobile();
|
||||
|
||||
$assigned = $this->authJson('POST', '/api/v1/secretary', $owner, [
|
||||
'mobile_number' => $mobile,
|
||||
'doctor_uuids' => [$doctors[0]->getUuid()],
|
||||
'national_code' => '1212121212',
|
||||
'address' => 'یزد، خیابان تست',
|
||||
'permissions' => ['version' => 1, 'resources' => ['patients' => ['view' => true]]],
|
||||
]);
|
||||
$secretaryUuid = $assigned['data']['secretary_uuid'];
|
||||
|
||||
// adding a second doctor must clone the person's profile onto the new link
|
||||
$this->authJson('PUT', '/api/v1/secretaries/clinic/' . $clinic->getUuid() . '/doctors', $owner, [
|
||||
'secretary_uuid' => $secretaryUuid,
|
||||
'doctor_uuids' => [$doctors[0]->getUuid(), $doctors[1]->getUuid()],
|
||||
]);
|
||||
$this->assertSame(200, $this->responseCode());
|
||||
|
||||
$rows = $this->authJson('GET', '/api/v1/secretaries/clinic/' . $clinic->getUuid(), $owner);
|
||||
$this->assertCount(2, $rows['data']);
|
||||
foreach ($rows['data'] as $row) {
|
||||
$this->assertSame('1212121212', $row['national_code']);
|
||||
$this->assertSame('یزد، خیابان تست', $row['address']);
|
||||
$this->assertTrue($row['permissions']['patients']['view']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testForeignOwnerCannotSync(): void
|
||||
{
|
||||
[, $clinic, ] = $this->makeClinicWithDoctors(1);
|
||||
|
||||
Reference in New Issue
Block a user