feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
99
apps/web/tests/team-client.test.ts
Normal file
99
apps/web/tests/team-client.test.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
aggregateTeamMemberCounts,
|
||||
buildTeamRowsWithCounts,
|
||||
loadUserTeamsWithCounts,
|
||||
type SupabaseTeamReader,
|
||||
} from '@/lib/team-client'
|
||||
|
||||
describe('웹 팀 목록 멤버 수 집계 (05-web-app.md)', () => {
|
||||
it('aggregateTeamMemberCounts_팀별멤버행수를정확히합산하고비정상행은무시한다', () => {
|
||||
const counts = aggregateTeamMemberCounts([
|
||||
{ team_id: 'team-a' },
|
||||
{ team_id: 'team-a' },
|
||||
{ team_id: 'team-a' },
|
||||
{ team_id: 'team-b' },
|
||||
{ team_id: '' },
|
||||
null,
|
||||
])
|
||||
|
||||
expect(counts.get('team-a')).toBe(3)
|
||||
expect(counts.get('team-b')).toBe(1)
|
||||
expect(counts.has('')).toBe(false)
|
||||
})
|
||||
|
||||
it('buildTeamRowsWithCounts_멤버십과멤버집계를결합해실제member_count를반환한다', () => {
|
||||
const rows = buildTeamRowsWithCounts(
|
||||
[
|
||||
{
|
||||
team_id: 'team-a',
|
||||
role: 'owner',
|
||||
teams: { id: 'team-a', name: 'Core Platform', avatar_url: null },
|
||||
},
|
||||
{
|
||||
team_id: 'team-b',
|
||||
role: 'member',
|
||||
teams: { id: 'team-b', name: 'Design Ops', avatar_url: 'https://example.com/a.png' },
|
||||
},
|
||||
{
|
||||
team_id: 'team-orphan',
|
||||
role: 'member',
|
||||
teams: null,
|
||||
},
|
||||
],
|
||||
[{ team_id: 'team-a' }, { team_id: 'team-a' }, { team_id: 'team-a' }, { team_id: 'team-a' }],
|
||||
)
|
||||
|
||||
expect(rows).toEqual([
|
||||
{
|
||||
id: 'team-a',
|
||||
name: 'Core Platform',
|
||||
avatar_url: null,
|
||||
member_count: 4,
|
||||
role: 'owner',
|
||||
},
|
||||
{
|
||||
id: 'team-b',
|
||||
name: 'Design Ops',
|
||||
avatar_url: 'https://example.com/a.png',
|
||||
member_count: 1,
|
||||
role: 'member',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('loadUserTeamsWithCounts_Supabase쿼리결과로부터팀별멤버수를조회한다', async () => {
|
||||
const fakeClient: SupabaseTeamReader = {
|
||||
from: () => ({
|
||||
select: (columns: string) => {
|
||||
const basePromise = Promise.resolve({
|
||||
data: columns.includes('teams(')
|
||||
? [
|
||||
{
|
||||
team_id: 'team-1',
|
||||
role: 'admin',
|
||||
teams: { id: 'team-1', name: 'Voice Team', avatar_url: null },
|
||||
},
|
||||
]
|
||||
: [],
|
||||
error: null,
|
||||
})
|
||||
return Object.assign(basePromise, {
|
||||
in: (_col: string, ids: string[]) =>
|
||||
Promise.resolve({
|
||||
data: ids.includes('team-1')
|
||||
? [{ team_id: 'team-1' }, { team_id: 'team-1' }, { team_id: 'team-1' }]
|
||||
: [],
|
||||
error: null,
|
||||
}),
|
||||
})
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
const teams = await loadUserTeamsWithCounts(fakeClient)
|
||||
expect(teams).toHaveLength(1)
|
||||
expect(teams[0]?.member_count).toBe(3)
|
||||
expect(teams[0]?.role).toBe('admin')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue