adding client notes
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-07-17 17:10:04 +02:00
parent feae470fba
commit 6b3cd0da17
8 changed files with 178 additions and 7 deletions

View File

@ -58,4 +58,42 @@ final class AppQuestionnairesTest extends QdbTestCase
$codes = array_column($payload['clients'], 'clientCode');
$this->assertContains($this->fixture()->clientCode, $codes);
}
public function testCoachClientNoteRoundTrip(): void
{
$this->submitFixtureQuestionnaire();
$login = $this->api()->loginMobileAndGetToken(
DatabaseSeeder::COACH_USERNAME,
DatabaseSeeder::PASSWORD
);
$code = $this->fixture()->clientCode;
$note = 'Bitte Rückruf nächste Woche';
$save = $this->api()->encryptedPost($login['token'], 'app_questionnaires', [
'action' => 'setClientNote',
'clientCode' => $code,
'note' => $note,
]);
$this->assertApiOk($save);
$this->assertTrue($save['data']['encrypted'] ?? false);
$savedPlain = qdb_decrypt_sensitive_envelope($save['data'], $login['token']);
$savedPayload = json_decode($savedPlain, true, 512, JSON_THROW_ON_ERROR);
$this->assertSame($note, $savedPayload['note']);
$list = $this->api()->withMobileToken($login['token'], 'GET', 'app_questionnaires', null, [
'clients' => '1',
]);
$this->assertApiOk($list);
$listPlain = qdb_decrypt_sensitive_envelope($list['data'], $login['token']);
$listPayload = json_decode($listPlain, true, 512, JSON_THROW_ON_ERROR);
$match = null;
foreach ($listPayload['clients'] as $row) {
if (($row['clientCode'] ?? '') === $code) {
$match = $row;
break;
}
}
$this->assertIsArray($match);
$this->assertSame($note, $match['note'] ?? null);
}
}

View File

@ -83,4 +83,18 @@ final class ResultsAnalyticsTest extends QdbTestCase
$this->assertIsArray($match);
$this->assertSame($note, $match['note']);
}
public function testFollowUpNoteRejectsTooLong(): void
{
$this->submitFixtureQuestionnaire();
$token = $this->adminToken();
$code = $this->fixture()->clientCode;
$note = str_repeat('a', 201);
$save = $this->api()->withToken($token, 'PUT', 'analytics', [
'clientCode' => $code,
'note' => $note,
]);
$this->assertFalse($save['ok'] ?? true);
$this->assertSame('INVALID_FIELD', $save['error']['code'] ?? null);
}
}