@@ -154,11 +154,28 @@ export function makeModRenderTests(modId: string): void {
154154 renderCaseTuplesByMod . get ( modId ) ! . push ( [ type , id ] ) ;
155155 }
156156
157+ const renderPriority = ( rawType : string ) : number => {
158+ const mappedType = mapType ( rawType as any ) ;
159+ if ( mappedType === "overmap_special" ) return 0 ;
160+ if ( mappedType === "item" ) return 2 ;
161+ return 1 ;
162+ } ;
163+
157164 afterEach ( cleanup ) ;
158165
159166 for ( const [ modId , mod ] of modSubset ) {
160167 const modData = mod . data ?? [ ] ;
161- const tuples = renderCaseTuplesByMod . get ( modId ) ?? [ ] ;
168+ const tuples = [ ...( renderCaseTuplesByMod . get ( modId ) ?? [ ] ) ] . sort (
169+ ( [ typeA , idA ] , [ typeB , idB ] ) => {
170+ const p = renderPriority ( typeA ) - renderPriority ( typeB ) ;
171+ if ( p !== 0 ) return p ;
172+ const typeCmp = mapType ( typeA as any ) . localeCompare (
173+ mapType ( typeB as any ) ,
174+ ) ;
175+ if ( typeCmp !== 0 ) return typeCmp ;
176+ return idA . localeCompare ( idB ) ;
177+ } ,
178+ ) ;
162179 let Thing : any ;
163180 let data : CBNData | undefined ;
164181
@@ -224,18 +241,21 @@ export function makeModRenderTests(modId: string): void {
224241 { timeout : MOD_RENDER_TIMEOUT_MS } ,
225242 async ( type , id ) => {
226243 ( globalThis as any ) . __isTesting__ = true ;
227- const { container } = render ( Thing , {
244+ const { container, unmount } = render ( Thing , {
228245 item : { type : mapType ( type as any ) , id } ,
229246 data : data ! ,
230247 } ) ;
231248 await act ( ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ) ;
232249 expect ( screen . queryByTestId ( "loading-indicator" ) ) . toBe ( null ) ;
233250 if ( type !== "technique" ) {
234- expect (
235- container . textContent ,
236- `Rendered output for ${ modId } :${ type } :${ id } contains invalid placeholder text.` ,
237- ) . not . toMatch ( / u n d e f i n e d | N a N | o b j e c t O b j e c t / ) ;
251+ const renderedText = container . textContent ?? "" ;
252+ if ( / u n d e f i n e d | N a N | o b j e c t O b j e c t / . test ( renderedText ) ) {
253+ throw new Error (
254+ `Rendered output for ${ modId } :${ type } :${ id } contains invalid placeholder text.` ,
255+ ) ;
256+ }
238257 }
258+ unmount ( ) ;
239259 } ,
240260 ) ;
241261 } ) ;
0 commit comments