@@ -3041,6 +3041,20 @@ describe('Config Tests', () => {
30413041 expect ( result [ 1 ] . source ) . to . equal ( 'manual' ) ;
30423042 } ) ;
30433043
3044+ it ( 'returns entries from both manual and moneyPages with correct source tags' , ( ) => {
3045+ const config = Config ( {
3046+ auditTargetURLs : {
3047+ manual : [ { url : 'https://example.com/manual1' } ] ,
3048+ moneyPages : [ { url : 'https://example.com/money1' } , { url : 'https://example.com/money2' } ] ,
3049+ } ,
3050+ } ) ;
3051+ const result = config . getAuditTargetURLs ( ) ;
3052+ expect ( result ) . to . have . lengthOf ( 3 ) ;
3053+ expect ( result [ 0 ] ) . to . deep . equal ( { url : 'https://example.com/manual1' , source : 'manual' } ) ;
3054+ expect ( result [ 1 ] ) . to . deep . equal ( { url : 'https://example.com/money1' , source : 'moneyPages' } ) ;
3055+ expect ( result [ 2 ] ) . to . deep . equal ( { url : 'https://example.com/money2' , source : 'moneyPages' } ) ;
3056+ } ) ;
3057+
30443058 describe ( 'getAuditTargetURLsBySource' , ( ) => {
30453059 it ( 'returns URLs for a specific source' , ( ) => {
30463060 const config = Config ( {
@@ -3054,9 +3068,22 @@ describe('Config Tests', () => {
30543068 expect ( manual [ 1 ] . url ) . to . equal ( 'https://example.com/m2' ) ;
30553069 } ) ;
30563070
3071+ it ( 'returns moneyPages URLs for moneyPages source' , ( ) => {
3072+ const config = Config ( {
3073+ auditTargetURLs : {
3074+ moneyPages : [ { url : 'https://example.com/mp1' } , { url : 'https://example.com/mp2' } ] ,
3075+ } ,
3076+ } ) ;
3077+ const moneyPages = config . getAuditTargetURLsBySource ( 'moneyPages' ) ;
3078+ expect ( moneyPages ) . to . have . lengthOf ( 2 ) ;
3079+ expect ( moneyPages [ 0 ] . url ) . to . equal ( 'https://example.com/mp1' ) ;
3080+ expect ( moneyPages [ 1 ] . url ) . to . equal ( 'https://example.com/mp2' ) ;
3081+ } ) ;
3082+
30573083 it ( 'returns empty array for source with no entries' , ( ) => {
30583084 const config = Config ( ) ;
30593085 expect ( config . getAuditTargetURLsBySource ( 'manual' ) ) . to . deep . equal ( [ ] ) ;
3086+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) ) . to . deep . equal ( [ ] ) ;
30603087 } ) ;
30613088
30623089 it ( 'rejects invalid source' , ( ) => {
@@ -3096,6 +3123,19 @@ describe('Config Tests', () => {
30963123 config . updateAuditTargetURLs ( 'manual' , [ ] ) ;
30973124 expect ( config . getAuditTargetURLsBySource ( 'manual' ) ) . to . deep . equal ( [ ] ) ;
30983125 } ) ;
3126+
3127+ it ( 'replaces URLs for moneyPages source' , ( ) => {
3128+ const config = Config ( {
3129+ auditTargetURLs : {
3130+ moneyPages : [ { url : 'https://old.com' } ] ,
3131+ } ,
3132+ } ) ;
3133+ config . updateAuditTargetURLs ( 'moneyPages' , [
3134+ { url : 'https://new1.com' } ,
3135+ { url : 'https://new2.com' } ,
3136+ ] ) ;
3137+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) ) . to . have . lengthOf ( 2 ) ;
3138+ } ) ;
30993139 } ) ;
31003140
31013141 describe ( 'addAuditTargetURL' , ( ) => {
@@ -3129,6 +3169,25 @@ describe('Config Tests', () => {
31293169 const config = Config ( ) ;
31303170 expect ( ( ) => config . addAuditTargetURL ( 'invalid' , { url : 'https://example.com' } ) ) . to . throw ( 'Invalid audit target source' ) ;
31313171 } ) ;
3172+
3173+ it ( 'appends a new URL to moneyPages source' , ( ) => {
3174+ const config = Config ( ) ;
3175+ config . addAuditTargetURL ( 'moneyPages' , { url : 'https://example.com/mp1' } ) ;
3176+ config . addAuditTargetURL ( 'moneyPages' , { url : 'https://example.com/mp2' } ) ;
3177+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) ) . to . have . lengthOf ( 2 ) ;
3178+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) [ 1 ] . url ) . to . equal ( 'https://example.com/mp2' ) ;
3179+ } ) ;
3180+
3181+ it ( 'deduplicates across manual and moneyPages sources' , ( ) => {
3182+ const config = Config ( {
3183+ auditTargetURLs : {
3184+ manual : [ { url : 'https://example.com/shared' } ] ,
3185+ } ,
3186+ } ) ;
3187+ config . addAuditTargetURL ( 'moneyPages' , { url : 'https://example.com/shared' } ) ;
3188+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) ) . to . have . lengthOf ( 0 ) ;
3189+ expect ( config . getAuditTargetURLs ( ) ) . to . have . lengthOf ( 1 ) ;
3190+ } ) ;
31323191 } ) ;
31333192
31343193 describe ( 'removeAuditTargetURL' , ( ) => {
@@ -3161,6 +3220,17 @@ describe('Config Tests', () => {
31613220 const config = Config ( ) ;
31623221 expect ( ( ) => config . removeAuditTargetURL ( 'invalid' , 'https://example.com' ) ) . to . throw ( 'Invalid audit target source' ) ;
31633222 } ) ;
3223+
3224+ it ( 'removes by url string from moneyPages source' , ( ) => {
3225+ const config = Config ( {
3226+ auditTargetURLs : {
3227+ moneyPages : [ { url : 'https://example.com/mp1' } , { url : 'https://example.com/mp2' } ] ,
3228+ } ,
3229+ } ) ;
3230+ config . removeAuditTargetURL ( 'moneyPages' , 'https://example.com/mp2' ) ;
3231+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) ) . to . have . lengthOf ( 1 ) ;
3232+ expect ( config . getAuditTargetURLsBySource ( 'moneyPages' ) [ 0 ] . url ) . to . equal ( 'https://example.com/mp1' ) ;
3233+ } ) ;
31643234 } ) ;
31653235
31663236 describe ( 'serialization' , ( ) => {
@@ -3173,6 +3243,7 @@ describe('Config Tests', () => {
31733243 const item = Config . toDynamoItem ( config ) ;
31743244 expect ( item . auditTargetURLs ) . to . deep . equal ( {
31753245 manual : [ { url : 'https://example.com/page1' } ] ,
3246+ moneyPages : [ ] ,
31763247 } ) ;
31773248 } ) ;
31783249
@@ -3189,6 +3260,31 @@ describe('Config Tests', () => {
31893260 const restored = Config . fromDynamoItem ( item ) ;
31903261 expect ( restored . getAuditTargetURLs ( ) ) . to . deep . equal ( config . getAuditTargetURLs ( ) ) ;
31913262 } ) ;
3263+
3264+ it ( 'includes moneyPages in toDynamoItem conversion' , ( ) => {
3265+ const config = Config ( {
3266+ auditTargetURLs : {
3267+ moneyPages : [ { url : 'https://example.com/mp1' } ] ,
3268+ } ,
3269+ } ) ;
3270+ const item = Config . toDynamoItem ( config ) ;
3271+ expect ( item . auditTargetURLs ) . to . deep . equal ( {
3272+ manual : [ ] ,
3273+ moneyPages : [ { url : 'https://example.com/mp1' } ] ,
3274+ } ) ;
3275+ } ) ;
3276+
3277+ it ( 'round-trips both manual and moneyPages through serialization' , ( ) => {
3278+ const config = Config ( {
3279+ auditTargetURLs : {
3280+ manual : [ { url : 'https://example.com/m1' } ] ,
3281+ moneyPages : [ { url : 'https://example.com/mp1' } ] ,
3282+ } ,
3283+ } ) ;
3284+ const item = Config . toDynamoItem ( config ) ;
3285+ const restored = Config . fromDynamoItem ( item ) ;
3286+ expect ( restored . getAuditTargetURLs ( ) ) . to . deep . equal ( config . getAuditTargetURLs ( ) ) ;
3287+ } ) ;
31923288 } ) ;
31933289
31943290 describe ( 'field validation' , ( ) => {
@@ -3200,17 +3296,20 @@ describe('Config Tests', () => {
32003296 } ) ) . to . throw ( ) ;
32013297 } ) ;
32023298
3203- it ( 'strips unknown source keys from auditTargetURLs' , ( ) => {
3299+ it ( 'strips unknown source keys from auditTargetURLs but keeps moneyPages ' , ( ) => {
32043300 const config = Config ( {
32053301 auditTargetURLs : {
32063302 manual : [ { url : 'https://example.com/page1' } ] ,
3303+ moneyPages : [ { url : 'https://example.com/mp1' } ] ,
32073304 unknown : [ { url : 'https://example.com/page2' } ] ,
32083305 } ,
32093306 } ) ;
32103307 const result = config . getAuditTargetURLs ( ) ;
3211- expect ( result ) . to . have . lengthOf ( 1 ) ;
3308+ expect ( result ) . to . have . lengthOf ( 2 ) ;
32123309 expect ( result [ 0 ] . url ) . to . equal ( 'https://example.com/page1' ) ;
32133310 expect ( result [ 0 ] . source ) . to . equal ( 'manual' ) ;
3311+ expect ( result [ 1 ] . url ) . to . equal ( 'https://example.com/mp1' ) ;
3312+ expect ( result [ 1 ] . source ) . to . equal ( 'moneyPages' ) ;
32143313 } ) ;
32153314 } ) ;
32163315 } ) ;
0 commit comments