@@ -148,6 +148,8 @@ describe("Test paper detection and storage", function () {
148148 expect ( missingTests ) . toEqual ( [ ] ) ;
149149 } ) ;
150150 } ) ;
151+
152+ for ( const [ orderIdx , order ] of orders . entries ( ) ) {
151153 describe ( "Parsing order: " + order , function ( ) {
152154 before ( async function ( ) {
153155 // create browser
@@ -159,16 +161,17 @@ describe("Test paper detection and storage", function () {
159161 // visit all relevant urls
160162 // all abstracts then all pdfs
161163
162- const indices = order === "abs;pdf" ? [ 0 , 1 ] : [ 1 , 0 ] ;
164+ const sourceOrder = order === "abs;pdf" ? [ 0 , 1 ] : [ 1 , 0 ] ;
163165
164- for ( const t of indices ) {
165- for ( const [ idx , targets ] of Object . values ( urls ) . entries ( ) ) {
166+ for ( const sourceOrderIdx of sourceOrder ) {
167+ for ( const [ targetIdx , targets ] of Object . values ( urls ) . entries ( ) ) {
166168 // for each target url (abstract, pdf), visit the url
167169 // and wait a little for it to load
168-
170+ const isPDF = sourceOrderIdx === 1 ;
171+ if ( isPDF && targets [ 2 ] ?. noPdf ) continue ;
169172 // filter out the additional test configs
170173 const targetUrls = targets . filter ( ( u ) => typeof u === "string" ) ;
171- if ( t >= targetUrls . length ) {
174+ if ( sourceOrderIdx >= targetUrls . length ) {
172175 continue ;
173176 }
174177 if ( targets . length > 2 ) {
@@ -179,9 +182,14 @@ describe("Test paper detection and storage", function () {
179182 continue ;
180183 }
181184 }
182- const target = targetUrls [ t ] ;
185+ // TODO: handle no pdf but still check abstracts
186+ const target = targetUrls [ sourceOrderIdx ] ;
183187 // log prefix
184- const n = idx + ( o > 0 ? 1 - t : t ) * nUrls + 1 ;
188+ const n =
189+ targetIdx +
190+ ( orderIdx > 0 ? 1 - sourceOrderIdx : sourceOrderIdx ) *
191+ nUrls +
192+ 1 ;
185193 const prefix = `${ " " . repeat ( 6 ) } (${ n } /${ nUrls * 2 } )` ;
186194 console . log ( `${ prefix } Going to: ${ target } ` ) ;
187195
@@ -231,8 +239,11 @@ describe("Test paper detection and storage", function () {
231239 const filteredSources = sources . filter (
232240 ( s ) => ! ignoreSingleOrder ( s , urls , order )
233241 ) ;
234- const memoryCounts = allAttributes ( memoryPapers , "count" ) ;
235- expect ( memoryCounts . every ( ( c ) => c >= 2 ) ) . toBeTruthy ( ) ;
242+ for ( const paper of Object . values ( memoryPapers ) ) {
243+ let targetMinCount = 2 ;
244+ if ( urls [ paper . source ] [ 2 ] ?. noPdf ) targetMinCount -- ;
245+ expect ( paper . count ) . toBeGreaterThanOrEqual ( targetMinCount ) ;
246+ }
236247 } ) ;
237248
238249 it ( "No undefined keys" , async function ( ) {
@@ -265,10 +276,12 @@ describe("Test paper detection and storage", function () {
265276 expect ( papers ?. length ) . toBe ( 1 ) ;
266277 } ) ;
267278
268- it ( "#count is 2 " , function ( ) {
279+ it ( "#count is appropriate for the source " , function ( ) {
269280 const paper = paperForSource ( source , memoryPapers ) ;
270281 expect ( paper ) . toBeDefined ( ) ;
271- expect ( paper ?. count ) . toBeGreaterThanOrEqual ( 2 ) ;
282+ let sourceCount = 2 ;
283+ if ( urls [ source ] [ 2 ] ?. noPdf ) sourceCount -- ;
284+ expect ( paper ?. count ) . toBeGreaterThanOrEqual ( sourceCount ) ;
272285 } ) ;
273286
274287 // more tests parameterized in the 3rd item in the list for this source
0 commit comments