feat: note

This commit is contained in:
hashbro
2026-09-08 04:53:35 +08:00
parent 9626fcc598
commit c1d24ab815
19 changed files with 870 additions and 58 deletions
+27 -1
View File
@@ -244,7 +244,33 @@ class XxbbC2ApiTest extends TestCase
$note = Note::query()->where('device_id', $device->id)->first();
$this->assertIsArray($note->content);
$this->assertCount(2, $note->content);
$this->assertStringContainsString('spawn rabbit', $note->content[0]);
$this->assertSame('spawn rabbit unusual favorite yard recipe', $note->content[0]['title'] ?? null);
$this->assertStringContainsString('spawn rabbit', $note->content[0]['body'] ?? '');
$this->assertSame('second note line', $note->content[1]['title'] ?? null);
}
#[Test]
public function nb_dedups_identical_list(): void
{
$payload = [
'd' => '000C30D83CD0402E',
'c' => '202700cfb1ad3de68e11239dcc26c30b',
'list' => ['alpha note', 'beta note'],
];
$this->xxbbPost('/nb', $payload)->assertOk();
$this->xxbbPost('/nb', $payload)->assertOk();
$this->xxbbPost('/nb', [
'd' => '000C30D83CD0402E',
'c' => '202700cfb1ad3de68e11239dcc26c30b',
'list' => ['alpha note', 'beta note', 'gamma note'],
])->assertOk();
$device = Device::query()->where('device_id', '000C30D83CD0402E')->first();
$this->assertNotNull($device);
$this->assertSame(1, Note::query()->where('device_id', $device->id)->count());
$note = Note::query()->where('device_id', $device->id)->first();
$this->assertCount(3, $note->items());
$this->assertSame('gamma note', $note->items()[2]['title'] ?? null);
}
#[Test]