Skip to content

Commit 80d8608

Browse files
committed
fix(user): syncBookmarks のデフォルト is_visible を 0 に修正、テスト強化 (SOR-18)
- syncBookmarks の INSERT も is_visible=1 → 0 に変更 - makeVisible ヘルパーにステータスアサーション追加 - デフォルト非公開を直接検証するテスト追加
1 parent 3402fca commit 80d8608

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

apps/api/src/services/user.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class UserService {
205205
const now = getCurrentTimestamp();
206206
const stmts = validIds.map(id =>
207207
this.db
208-
.prepare('INSERT OR IGNORE INTO user_bookmarks (user_id, itinerary_id, is_visible, created_at, updated_at) VALUES (?, ?, 1, ?, ?)')
208+
.prepare('INSERT OR IGNORE INTO user_bookmarks (user_id, itinerary_id, is_visible, created_at, updated_at) VALUES (?, ?, 0, ?, ?)')
209209
.bind(userId, id, now, now)
210210
);
211211
const results = await this.db.batch(stmts);

apps/api/test/users-profile.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ async function registerAndGetToken(username: string, email: string, password = '
8383
}
8484

8585
async function makeVisible(token: string, itineraryId: string): Promise<void> {
86-
await app.request(`/api/v1/users/me/bookmarks/${itineraryId}/visibility`, {
86+
const res = await app.request(`/api/v1/users/me/bookmarks/${itineraryId}/visibility`, {
8787
method: 'PATCH',
8888
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
8989
body: JSON.stringify({ is_visible: true }),
9090
}, env);
91+
expect(res.status).toBe(200);
9192
}
9293

9394
describe('PATCH /api/v1/users/me/profile', () => {
@@ -313,6 +314,20 @@ describe('GET /api/v1/users (public feed)', () => {
313314
expect(json.data.hasMore).toBe(false);
314315
});
315316

317+
it('new itinerary is private by default (not visible in public feed)', async () => {
318+
const token = await registerAndGetToken('defaultprivateuser', 'defaultprivate@example.com');
319+
320+
await app.request('/api/v1/itineraries', {
321+
method: 'POST',
322+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
323+
body: JSON.stringify({ title: 'デフォルト非公開しおり' }),
324+
}, env);
325+
326+
const res = await app.request('/api/v1/users', {}, env);
327+
const json = await res.json() as { data: { items: unknown[] } };
328+
expect(json.data.items).toHaveLength(0);
329+
});
330+
316331
it('returns public bookmarks with username', async () => {
317332
const token = await registerAndGetToken('feeduser', 'feed@example.com');
318333

0 commit comments

Comments
 (0)