This commit is contained in:
@ -54,4 +54,58 @@ final class QuestionnaireEditingTest extends QdbTestCase
|
||||
$res = $this->api()->withToken($token, 'GET', 'answer_options');
|
||||
$this->assertApiError($res, 'MISSING_PARAM', 400);
|
||||
}
|
||||
|
||||
public function testSavingNoteBeforeBumpsStructureRevisionAndExportsKey(): void
|
||||
{
|
||||
$adminToken = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$coachLogin = $this->api()->loginMobileAndGetToken(
|
||||
DatabaseSeeder::COACH_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$f = $this->fixture();
|
||||
|
||||
$before = $this->api()->withMobileToken($coachLogin['token'], 'GET', 'app_questionnaires', null, [
|
||||
'id' => $f->questionnaireId,
|
||||
]);
|
||||
$this->assertApiOk($before);
|
||||
$revBefore = (int)($before['data']['structureRevision'] ?? 1);
|
||||
|
||||
$put = $this->api()->withToken($adminToken, 'PUT', 'questions', [
|
||||
'questionID' => $f->questionId,
|
||||
'questionKey' => 'consent_q',
|
||||
'defaultText' => 'Consent?',
|
||||
'type' => 'single_choice_question',
|
||||
'isRequired' => 1,
|
||||
'configJson' => json_encode(['questionKey' => 'consent_q'], JSON_UNESCAPED_UNICODE),
|
||||
'noteBefore' => 'Bitte dem Klienten deutlich machen: Ohne Einwilligung keine Teilnahme.',
|
||||
'noteAfter' => '',
|
||||
]);
|
||||
$this->assertApiOk($put);
|
||||
$revAfter = (int)($put['data']['structureRevision'] ?? 0);
|
||||
$this->assertGreaterThan($revBefore, $revAfter, 'note-only edit must bump structureRevision for app sync');
|
||||
|
||||
$detail = $this->api()->withMobileToken($coachLogin['token'], 'GET', 'app_questionnaires', null, [
|
||||
'id' => $f->questionnaireId,
|
||||
]);
|
||||
$this->assertApiOk($detail);
|
||||
$questions = $detail['data']['questions'] ?? [];
|
||||
$this->assertIsArray($questions);
|
||||
$matched = null;
|
||||
foreach ($questions as $q) {
|
||||
if (($q['question'] ?? '') === 'consent_q' || ($q['id'] ?? '') === 'q1') {
|
||||
$matched = $q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertNotNull($matched, 'expected consent question in app export');
|
||||
$this->assertSame('consent_q_note_before', $matched['noteBeforeKey'] ?? null);
|
||||
$de = $detail['data']['translations']['de'] ?? [];
|
||||
$this->assertSame(
|
||||
'Bitte dem Klienten deutlich machen: Ohne Einwilligung keine Teilnahme.',
|
||||
$de['consent_q_note_before'] ?? null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user