Skip to content

Commit 6b20557

Browse files
committed
fix(user): address Copilot review comments on PR #168
- Separate loadMoreError from initial error state to preserve existing items on pagination failure - Add migration for itineraries(created_at) index to optimize public feed ORDER BY performance - Add test case: password-protected itineraries excluded from public feed - Fix a11y label/id associations in login/register form inputs
1 parent 0b34d3c commit 6b20557

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add index on itineraries.created_at for public feed pagination performance
2+
CREATE INDEX IF NOT EXISTS idx_itineraries_created_at ON itineraries(created_at DESC);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,19 @@ describe('GET /api/v1/users (public feed)', () => {
385385
expect(json2.data.items).toHaveLength(1);
386386
expect(json2.data.hasMore).toBe(false);
387387
});
388+
389+
it('excludes password-protected itineraries from public feed', async () => {
390+
const token = await registerAndGetToken('feeduser5', 'feed5@example.com');
391+
392+
// Create a password-protected itinerary
393+
await app.request('/api/v1/itineraries', {
394+
method: 'POST',
395+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
396+
body: JSON.stringify({ title: 'パスワード付きしおり', password: 'secret123' }),
397+
}, env);
398+
399+
const res = await app.request('/api/v1/users', {}, env);
400+
const json = await res.json() as { data: { items: unknown[] } };
401+
expect(json.data.items).toHaveLength(0);
402+
});
388403
});

apps/web/src/routes/profile/+page.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@
234234
<form onsubmit={(e) => { e.preventDefault(); handleSubmit(); }} class="space-y-4">
235235
{#if mode === "register"}
236236
<div>
237-
<label class="block text-sm font-medium text-gray-700 mb-1">ユーザー名</label>
237+
<label for="auth-username" class="block text-sm font-medium text-gray-700 mb-1">ユーザー名</label>
238238
<input
239+
id="auth-username"
239240
type="text"
240241
bind:value={usernameInput}
241242
required
@@ -244,17 +245,19 @@
244245
</div>
245246
{/if}
246247
<div>
247-
<label class="block text-sm font-medium text-gray-700 mb-1">メールアドレス</label>
248+
<label for="auth-email" class="block text-sm font-medium text-gray-700 mb-1">メールアドレス</label>
248249
<input
250+
id="auth-email"
249251
type="email"
250252
bind:value={email}
251253
required
252254
class="w-full border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"
253255
/>
254256
</div>
255257
<div>
256-
<label class="block text-sm font-medium text-gray-700 mb-1">パスワード</label>
258+
<label for="auth-password" class="block text-sm font-medium text-gray-700 mb-1">パスワード</label>
257259
<input
260+
id="auth-password"
258261
type="password"
259262
bind:value={password}
260263
required

apps/web/src/routes/users/+page.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
let loadingMore = $state(false);
99
let hasMore = $state(false);
1010
let error = $state<string | null>(null);
11+
let loadMoreError = $state<string | null>(null);
1112
1213
onMount(async () => {
1314
try {
@@ -23,12 +24,13 @@
2324
2425
async function loadMore() {
2526
loadingMore = true;
27+
loadMoreError = null;
2628
try {
2729
const result = await userApi.getPublicFeed(items.length);
2830
items = [...items, ...result.items];
2931
hasMore = result.hasMore;
3032
} catch {
31-
error = "読み込みに失敗しました";
33+
loadMoreError = "追加の読み込みに失敗しました";
3234
} finally {
3335
loadingMore = false;
3436
}
@@ -74,6 +76,10 @@
7476
{/each}
7577
</div>
7678

79+
{#if loadMoreError}
80+
<p class="text-red-500 text-center mt-4 text-sm">{loadMoreError}</p>
81+
{/if}
82+
7783
{#if hasMore}
7884
<div class="mt-8 text-center">
7985
<button

0 commit comments

Comments
 (0)