Skip to content

Commit 7be1900

Browse files
CopilotBitoviAI
authored andcommitted
Address code review feedback: remove password fields, fix spinner overlap, update tests
Co-authored-by: BitoviAI <[email protected]>
1 parent b9dda67 commit 7be1900

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

app/(dashboard)/tasks/actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export async function getAllTasks() {
4646
try {
4747
const tasks = await prisma.task.findMany({
4848
include: {
49-
assignee: { select: { id: true, name: true, email: true, password: true } },
50-
creator: { select: { id: true, name: true, email: true, password: true } },
49+
assignee: { select: { id: true, name: true, email: true } },
50+
creator: { select: { id: true, name: true, email: true } },
5151
},
5252
orderBy: [
5353
{ createdAt: "desc" },
@@ -75,8 +75,8 @@ export async function searchTasks(query: string) {
7575
],
7676
},
7777
include: {
78-
assignee: { select: { id: true, name: true, email: true, password: true } },
79-
creator: { select: { id: true, name: true, email: true, password: true } },
78+
assignee: { select: { id: true, name: true, email: true } },
79+
creator: { select: { id: true, name: true, email: true } },
8080
},
8181
orderBy: [
8282
{ createdAt: "desc" },

components/tasks-page-client.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ export function TasksPageClient({ initialTasks }: TasksPageClientProps) {
112112
className="pl-9 pr-9"
113113
data-testid="search-input"
114114
/>
115-
{searchQuery && (
115+
{isPending && !searchQuery && (
116+
<div className="absolute right-3 top-1/2 -translate-y-1/2">
117+
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" data-testid="search-spinner" />
118+
</div>
119+
)}
120+
{searchQuery && !isPending && (
116121
<button
117122
onClick={handleClear}
118123
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
@@ -121,9 +126,16 @@ export function TasksPageClient({ initialTasks }: TasksPageClientProps) {
121126
<X className="h-4 w-4" />
122127
</button>
123128
)}
124-
{isPending && (
125-
<div className="absolute right-3 top-1/2 -translate-y-1/2">
129+
{searchQuery && isPending && (
130+
<div className="absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2">
126131
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" data-testid="search-spinner" />
132+
<button
133+
onClick={handleClear}
134+
className="text-muted-foreground hover:text-foreground"
135+
data-testid="clear-search"
136+
>
137+
<X className="h-4 w-4" />
138+
</button>
127139
</div>
128140
)}
129141
</div>

tests/e2e/search.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { test, expect, Page } from '@playwright/test';
22

3+
// Test credentials for seeded user
4+
const TEST_USER = {
5+
6+
password: 'password123'
7+
};
8+
39
// Helper to log in as a seeded user
4-
async function login(page: Page, email = '[email protected]', password = 'password123') {
10+
async function login(page: Page, email = TEST_USER.email, password = TEST_USER.password) {
511
await page.goto('/login');
612
await page.fill('input#email', email);
713
await page.fill('input#password', password);

tests/unit/search-tasks.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const mockTasks = [
3636
updatedAt: new Date(),
3737
creatorId: 1,
3838
assigneeId: 1,
39-
assignee: { id: 1, name: "John Doe", email: "[email protected]", password: "hashed" },
40-
creator: { id: 1, name: "John Doe", email: "[email protected]", password: "hashed" },
39+
assignee: { id: 1, name: "John Doe", email: "[email protected]" },
40+
creator: { id: 1, name: "John Doe", email: "[email protected]" },
4141
},
4242
{
4343
id: 2,
@@ -50,8 +50,8 @@ const mockTasks = [
5050
updatedAt: new Date(),
5151
creatorId: 1,
5252
assigneeId: 1,
53-
assignee: { id: 1, name: "Jane Smith", email: "[email protected]", password: "hashed" },
54-
creator: { id: 1, name: "Jane Smith", email: "[email protected]", password: "hashed" },
53+
assignee: { id: 1, name: "Jane Smith", email: "[email protected]" },
54+
creator: { id: 1, name: "Jane Smith", email: "[email protected]" },
5555
},
5656
]
5757

@@ -92,8 +92,8 @@ describe("searchTasks", () => {
9292
],
9393
},
9494
include: {
95-
assignee: { select: { id: true, name: true, email: true, password: true } },
96-
creator: { select: { id: true, name: true, email: true, password: true } },
95+
assignee: { select: { id: true, name: true, email: true } },
96+
creator: { select: { id: true, name: true, email: true } },
9797
},
9898
orderBy: [
9999
{ createdAt: "desc" },

0 commit comments

Comments
 (0)