@@ -12,10 +12,6 @@ describe('Team Status & Overview', () => {
1212 await seedTeam ( ) ;
1313 } ) ;
1414
15- afterAll ( async ( ) => {
16- await teardownTestDb ( ) ;
17- } ) ;
18-
1915 it ( 'returns team status with intents grouped by status' , async ( ) => {
2016 const intent = await seedOpenIntent ( { title : 'Open task' } ) ;
2117 const intent2 = await seedOpenIntent ( { title : 'Claimed task' } ) ;
@@ -99,3 +95,109 @@ describe('Team Status & Overview', () => {
9995 expect ( overview . recently_completed [ 0 ] . title ) . toBe ( 'Will complete' ) ;
10096 } ) ;
10197} ) ;
98+
99+ describe ( 'Board View' , ( ) => {
100+ beforeAll ( async ( ) => {
101+ await setupTestDb ( ) ;
102+ } ) ;
103+
104+ beforeEach ( async ( ) => {
105+ await cleanTestDb ( ) ;
106+ await seedTeam ( ) ;
107+ } ) ;
108+
109+ afterAll ( async ( ) => {
110+ await teardownTestDb ( ) ;
111+ } ) ;
112+
113+ it ( 'returns empty columns with zero counts when no intents exist' , async ( ) => {
114+ const board = await db . getBoard ( ) ;
115+
116+ expect ( board . columns . open ) . toEqual ( [ ] ) ;
117+ expect ( board . columns . claimed ) . toEqual ( [ ] ) ;
118+ expect ( board . columns . blocked ) . toEqual ( [ ] ) ;
119+ expect ( board . columns . done ) . toEqual ( [ ] ) ;
120+ expect ( board . columns . cancelled ) . toEqual ( [ ] ) ;
121+ expect ( board . summary . open ) . toBe ( 0 ) ;
122+ expect ( board . summary . claimed ) . toBe ( 0 ) ;
123+ expect ( board . summary . blocked ) . toBe ( 0 ) ;
124+ expect ( board . summary . done ) . toBe ( 0 ) ;
125+ expect ( board . summary . cancelled ) . toBe ( 0 ) ;
126+ } ) ;
127+
128+ it ( 'groups intents into correct status columns' , async ( ) => {
129+ const openIntent = await seedOpenIntent ( { title : 'Open task' } ) ;
130+ const claimedIntent = await seedOpenIntent ( { title : 'Claimed task' } ) ;
131+ await db . claimWork ( { intent_id : claimedIntent . id as string , claimed_by : 'alice' } ) ;
132+
133+ const board = await db . getBoard ( ) ;
134+
135+ expect ( board . columns . open ) . toHaveLength ( 1 ) ;
136+ expect ( board . columns . open [ 0 ] . title ) . toBe ( 'Open task' ) ;
137+ expect ( board . columns . claimed ) . toHaveLength ( 1 ) ;
138+ expect ( board . columns . claimed [ 0 ] . title ) . toBe ( 'Claimed task' ) ;
139+ } ) ;
140+
141+ it ( 'includes claimed_by and claim_id for claimed intents' , async ( ) => {
142+ const intent = await seedOpenIntent ( { title : 'In progress' } ) ;
143+ const { claim } = await db . claimWork ( {
144+ intent_id : intent . id as string ,
145+ claimed_by : 'pawel' ,
146+ } ) ;
147+
148+ const board = await db . getBoard ( ) ;
149+
150+ const claimedCard = board . columns . claimed [ 0 ] ;
151+ expect ( claimedCard . claimed_by ) . toBe ( 'pawel' ) ;
152+ expect ( claimedCard . claim_id ) . toBe ( claim . id ) ;
153+ } ) ;
154+
155+ it ( 'includes blocked_by for blocked intents' , async ( ) => {
156+ const blocker = await seedOpenIntent ( { title : 'Blocker' } ) ;
157+
158+ await testQuery (
159+ `INSERT INTO intents (title, created_by, team_id, status, priority, acceptance_criteria)
160+ VALUES ('Blocked task', 'alice', 'backend', 'blocked', 'medium', '["Done"]') RETURNING *`
161+ ) ;
162+ const blockedRes = await testQuery (
163+ `SELECT id FROM intents WHERE title = 'Blocked task'`
164+ ) ;
165+ const blockedId = blockedRes . rows [ 0 ] . id ;
166+ await testQuery (
167+ 'INSERT INTO intent_dependencies (intent_id, depends_on) VALUES ($1, $2)' ,
168+ [ blockedId , blocker . id ]
169+ ) ;
170+
171+ const board = await db . getBoard ( ) ;
172+
173+ expect ( board . columns . blocked ) . toHaveLength ( 1 ) ;
174+ expect ( board . columns . blocked [ 0 ] . blocked_by ) . toContain ( blocker . id ) ;
175+ } ) ;
176+
177+ it ( 'filters by team_id when provided' , async ( ) => {
178+ await seedTeam ( 'frontend' , 'Frontend Team' ) ;
179+ await seedOpenIntent ( { title : 'Backend task' , team_id : 'backend' } ) ;
180+ await seedOpenIntent ( { title : 'Frontend task' , team_id : 'frontend' } ) ;
181+
182+ const board = await db . getBoard ( 'frontend' ) ;
183+
184+ expect ( board . columns . open ) . toHaveLength ( 1 ) ;
185+ expect ( board . columns . open [ 0 ] . title ) . toBe ( 'Frontend task' ) ;
186+ } ) ;
187+
188+ it ( 'excludes drafts from all columns' , async ( ) => {
189+ await testQuery (
190+ `INSERT INTO intents (title, created_by, team_id, status, priority, acceptance_criteria)
191+ VALUES ('Draft task', 'alice', 'backend', 'draft', 'medium', '["Done"]')`
192+ ) ;
193+ await seedOpenIntent ( { title : 'Open task' } ) ;
194+
195+ const board = await db . getBoard ( ) ;
196+
197+ const allCards = Object . values ( board . columns ) . flat ( ) ;
198+ expect ( allCards . every ( c => c . title !== 'Draft task' ) ) . toBe ( true ) ;
199+ expect ( board . columns . open ) . toHaveLength ( 1 ) ;
200+ expect ( board . columns ) . not . toHaveProperty ( 'draft' ) ;
201+ expect ( board . summary ) . not . toHaveProperty ( 'draft' ) ;
202+ } ) ;
203+ } ) ;
0 commit comments