feat: checklist notifications

This commit is contained in:
2026-04-07 01:53:14 +03:00
parent ae217688d6
commit f9dc3d75da
14 changed files with 224 additions and 13 deletions

View File

@@ -125,6 +125,38 @@ class NotifierTest extends TestCase {
$this->assertSame($n, $result);
}
public function testItemAddedSetsRichSubject(): void {
$n = $this->makeNotification('pantry', 'item_added', [
'userId' => 'alice',
'userDisplayName' => 'Alice',
'houseId' => 1,
'houseName' => 'My House',
'itemName' => 'Milk',
'listName' => 'Groceries',
]);
$n->expects($this->once())->method('setRichSubject');
$n->expects($this->once())->method('setParsedSubject');
$result = $this->notifier->prepare($n, 'en');
$this->assertSame($n, $result);
}
public function testItemRecurredSetsRichSubject(): void {
$n = $this->makeNotification('pantry', 'item_recurred', [
'houseId' => 1,
'houseName' => 'My House',
'itemName' => 'Milk',
'listName' => 'Groceries',
]);
$n->expects($this->once())->method('setRichSubject');
$n->expects($this->once())->method('setParsedSubject');
$result = $this->notifier->prepare($n, 'en');
$this->assertSame($n, $result);
}
public function testParsedSubjectReplacesPlaceholders(): void {
$parsedSubject = '';
$n = $this->makeNotification('pantry', 'photo_uploaded', [

View File

@@ -57,7 +57,7 @@ class PrefsServiceTest extends TestCase {
$this->svc->setNotificationPref('bob', 5, 'notify_note_create', true);
}
public function testGetNotificationPrefsReturnsAllThree(): void {
public function testGetNotificationPrefsReturnsAll(): void {
$this->config->method('getUserValue')->willReturnCallback(
function (string $uid, string $app, string $key, string $default): string {
if ($key === 'notify_photo_1') {
@@ -69,6 +69,12 @@ class PrefsServiceTest extends TestCase {
if ($key === 'notify_note_edit_1') {
return '0';
}
if ($key === 'notify_item_add_1') {
return '1';
}
if ($key === 'notify_item_recur_1') {
return '0';
}
return $default;
}
);
@@ -78,6 +84,8 @@ class PrefsServiceTest extends TestCase {
'notifyPhoto' => false,
'notifyNoteCreate' => true,
'notifyNoteEdit' => false,
'notifyItemAdd' => true,
'notifyItemRecur' => false,
], $result);
}