@@ -2,9 +2,9 @@ import { execFile } from "node:child_process";
22import { readFile } from "node:fs/promises" ;
33import { join , resolve } from "node:path" ;
44import { promisify } from "node:util" ;
5- import { afterEach , beforeEach , describe , expect , it } from "vitest" ;
6- import { simpleGit } from "simple-git" ;
75import type { SimpleGit } from "simple-git" ;
6+ import { simpleGit } from "simple-git" ;
7+ import { afterEach , beforeEach , describe , expect , it } from "vitest" ;
88import { validatePlan , writePlan } from "../../src/core/plan.js" ;
99import { applyPlan } from "../../src/git/plan-applier.js" ;
1010import type { StackPlan } from "../../src/types/index.js" ;
@@ -87,31 +87,37 @@ describe("demo E2E with cached AI response", () => {
8787 expect ( app5 ) . toContain ( "postRouter" ) ;
8888 } ) ;
8989
90- it ( "tests are colocated with their code (not in separate slice)" , { timeout : 30_000 } , async ( ) => {
91- await git . checkout ( "feat/full-rest-api" ) ;
92- await writePlan ( plan , demoDir ) ;
93- await applyPlan ( git , plan , demoDir ) ;
90+ it (
91+ "tests are colocated with their code (not in separate slice)" ,
92+ { timeout : 30_000 } ,
93+ async ( ) => {
94+ await git . checkout ( "feat/full-rest-api" ) ;
95+ await writePlan ( plan , demoDir ) ;
96+ await applyPlan ( git , plan , demoDir ) ;
9497
95- const testAssignments = plan . fileAssignments . filter (
96- ( fa ) => fa . path . includes ( "test" ) || fa . path . includes ( "spec" ) ,
97- ) ;
98-
99- for ( const testFile of testAssignments ) {
100- const targetSlice = testFile . targetSlice
101- ?? testFile . sliceContents ?. [ 0 ] ?. slice ;
102- expect ( targetSlice , `${ testFile . path } should have a slice assignment` ) . toBeDefined ( ) ;
103-
104- // The test file's slice should also contain non-test code
105- const sliceFiles = plan . fileAssignments . filter ( ( fa ) => {
106- if ( fa . targetSlice === targetSlice ) return true ;
107- return fa . sliceContents ?. some ( ( sc ) => sc . slice === targetSlice ) ?? false ;
108- } ) ;
109- const hasSourceCode = sliceFiles . some (
110- ( fa ) => ! fa . path . includes ( "test" ) && ! fa . path . includes ( "spec" ) ,
98+ const testAssignments = plan . fileAssignments . filter (
99+ ( fa ) => fa . path . includes ( "test" ) || fa . path . includes ( "spec" ) ,
111100 ) ;
112- expect ( hasSourceCode , `slice ${ targetSlice } (with ${ testFile . path } ) should also have source code` ) . toBe ( true ) ;
113- }
114- } ) ;
101+
102+ for ( const testFile of testAssignments ) {
103+ const targetSlice = testFile . targetSlice ?? testFile . sliceContents ?. [ 0 ] ?. slice ;
104+ expect ( targetSlice , `${ testFile . path } should have a slice assignment` ) . toBeDefined ( ) ;
105+
106+ // The test file's slice should also contain non-test code
107+ const sliceFiles = plan . fileAssignments . filter ( ( fa ) => {
108+ if ( fa . targetSlice === targetSlice ) return true ;
109+ return fa . sliceContents ?. some ( ( sc ) => sc . slice === targetSlice ) ?? false ;
110+ } ) ;
111+ const hasSourceCode = sliceFiles . some (
112+ ( fa ) => ! fa . path . includes ( "test" ) && ! fa . path . includes ( "spec" ) ,
113+ ) ;
114+ expect (
115+ hasSourceCode ,
116+ `slice ${ targetSlice } (with ${ testFile . path } ) should also have source code` ,
117+ ) . toBe ( true ) ;
118+ }
119+ } ,
120+ ) ;
115121
116122 it ( "verification data shows progressive test counts" , ( ) => {
117123 const verification = plan . metadata . verification ;
@@ -139,9 +145,7 @@ describe("demo E2E with cached AI response", () => {
139145 await writePlan ( plan , demoDir ) ;
140146 await applyPlan ( git , plan , demoDir ) ;
141147
142- const lastBranch = plan . slices
143- . sort ( ( a , b ) => a . order - b . order )
144- . at ( - 1 ) ?. branch ;
148+ const lastBranch = plan . slices . sort ( ( a , b ) => a . order - b . order ) . at ( - 1 ) ?. branch ;
145149 expect ( lastBranch ) . toBeDefined ( ) ;
146150
147151 const diff = await git . diff ( [ `${ lastBranch } ..feat/full-rest-api` ] ) ;
0 commit comments