diff options
| author | zyoshoka <107108195+zyoshoka@users.noreply.github.com> | 2024-02-29 20:42:02 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 20:42:02 +0900 |
| commit | 16f16e6b0879199a78f0f9ef2da7e1e44ee8d355 (patch) | |
| tree | 87a4cc793674350420d41bf42bb8b9eca2960875 /packages/backend/test/e2e/note.ts | |
| parent | enhance: 通知の履歴をリセットできるように (#13335) (diff) | |
| download | sharkey-16f16e6b0879199a78f0f9ef2da7e1e44ee8d355.tar.gz sharkey-16f16e6b0879199a78f0f9ef2da7e1e44ee8d355.tar.bz2 sharkey-16f16e6b0879199a78f0f9ef2da7e1e44ee8d355.zip | |
fix(backend): ダイレクトなノートに対してはダイレクトでしか返信できないように (#13477)
* fix(backend): ダイレクトなノートに対してはダイレクトでしか返信できないように
* Update CHANGELOG.md
* test(backend): `notes/create`とWebSocket関連のテストを追加
Diffstat (limited to 'packages/backend/test/e2e/note.ts')
| -rw-r--r-- | packages/backend/test/e2e/note.ts | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/packages/backend/test/e2e/note.ts b/packages/backend/test/e2e/note.ts index a5742d6e77..23de94889d 100644 --- a/packages/backend/test/e2e/note.ts +++ b/packages/backend/test/e2e/note.ts @@ -176,6 +176,87 @@ describe('Note', () => { assert.strictEqual(deleteRes.status, 204); }); + test('visibility: followersなノートに対してフォロワーはリプライできる', async () => { + await api('/following/create', { + userId: alice.id, + }, bob); + + const aliceNote = await api('/notes/create', { + text: 'direct note to bob', + visibility: 'followers', + }, alice); + + assert.strictEqual(aliceNote.status, 200); + + const replyId = aliceNote.body.createdNote.id; + const bobReply = await api('/notes/create', { + text: 'reply to alice note', + replyId, + }, bob); + + assert.strictEqual(bobReply.status, 200); + assert.strictEqual(bobReply.body.createdNote.replyId, replyId); + + await api('/following/delete', { + userId: alice.id, + }, bob); + }); + + test('visibility: followersなノートに対してフォロワーでないユーザーがリプライしようとすると怒られる', async () => { + const aliceNote = await api('/notes/create', { + text: 'direct note to bob', + visibility: 'followers', + }, alice); + + assert.strictEqual(aliceNote.status, 200); + + const bobReply = await api('/notes/create', { + text: 'reply to alice note', + replyId: aliceNote.body.createdNote.id, + }, bob); + + assert.strictEqual(bobReply.status, 400); + assert.strictEqual(bobReply.body.error.code, 'CANNOT_REPLY_TO_AN_INVISIBLE_NOTE'); + }); + + test('visibility: specifiedなノートに対してvisibility: specifiedで返信できる', async () => { + const aliceNote = await api('/notes/create', { + text: 'direct note to bob', + visibility: 'specified', + visibleUserIds: [bob.id], + }, alice); + + assert.strictEqual(aliceNote.status, 200); + + const bobReply = await api('/notes/create', { + text: 'reply to alice note', + replyId: aliceNote.body.createdNote.id, + visibility: 'specified', + visibleUserIds: [alice.id], + }, bob); + + assert.strictEqual(bobReply.status, 200); + }); + + test('visibility: specifiedなノートに対してvisibility: follwersで返信しようとすると怒られる', async () => { + const aliceNote = await api('/notes/create', { + text: 'direct note to bob', + visibility: 'specified', + visibleUserIds: [bob.id], + }, alice); + + assert.strictEqual(aliceNote.status, 200); + + const bobReply = await api('/notes/create', { + text: 'reply to alice note with visibility: followers', + replyId: aliceNote.body.createdNote.id, + visibility: 'followers', + }, bob); + + assert.strictEqual(bobReply.status, 400); + assert.strictEqual(bobReply.body.error.code, 'CANNOT_REPLY_TO_SPECIFIED_VISIBILITY_NOTE_WITH_EXTENDED_VISIBILITY'); + }); + test('文字数ぎりぎりで怒られない', async () => { const post = { text: '!'.repeat(MAX_NOTE_TEXT_LENGTH), // 3000文字 |