22 CloudWatchLogsClient ,
33 FilterLogEventsCommand ,
44} from "@aws-sdk/client-cloudwatch-logs" ;
5- import { envName } from "tests/constants/api-constants" ;
5+ import { AWS_REGION , envName } from "tests/constants/api-constants" ;
66
77const sleep = ( ms : number ) =>
88 new Promise ( ( resolve ) => {
@@ -16,7 +16,7 @@ export async function pollSupplierAllocatorLogForResolvedSpec(
1616 const startTimeMs = Date . now ( ) - 5 * 60_000 ;
1717 const timeoutMs = 120_000 ;
1818
19- const client = new CloudWatchLogsClient ( { } ) ;
19+ const client = new CloudWatchLogsClient ( { region : AWS_REGION } ) ;
2020 const logGroupName = `/aws/lambda/nhs-${ envName } -supapi-supplier-allocator` ;
2121 const deadline = Date . now ( ) + timeoutMs ;
2222
@@ -42,7 +42,6 @@ export async function pollSupplierAllocatorLogForResolvedSpec(
4242 ( ! domainId || message . includes ( domainId ) )
4343 ) ;
4444 } ) ;
45-
4645 if ( foundEvent ?. message ) {
4746 return foundEvent . message ;
4847 }
@@ -57,12 +56,13 @@ export async function pollSupplierAllocatorLogForResolvedSpec(
5756
5857export async function pollUpsertLetterLogForError (
5958 msgToCheck : string ,
59+ domainId ?: string ,
6060) : Promise < string > {
6161 const intervalMs = 5000 ;
6262 const startTimeMs = Date . now ( ) - 5 * 60_000 ;
6363 const timeoutMs = 120_000 ;
6464
65- const client = new CloudWatchLogsClient ( { } ) ;
65+ const client = new CloudWatchLogsClient ( { region : AWS_REGION } ) ;
6666 const logGroupName = `/aws/lambda/nhs-${ envName } -supapi-upsertletter` ;
6767 const deadline = Date . now ( ) + timeoutMs ;
6868
@@ -73,7 +73,9 @@ export async function pollUpsertLetterLogForError(
7373 startTime : startTimeMs ,
7474 interleaved : true ,
7575 limit : 100 ,
76- filterPattern : `"Error processing upsert of record"` ,
76+ filterPattern : domainId
77+ ? `"Error processing upsert of record" "${ domainId } "`
78+ : `"Error processing upsert of record"` ,
7779 } ) ,
7880 ) ;
7981
@@ -94,6 +96,6 @@ export async function pollUpsertLetterLogForError(
9496 }
9597
9698 throw new Error (
97- `Timed out waiting for resolved supplier spec log in ${ logGroupName } ` ,
99+ `Timed out waiting for upsert letter error log in ${ logGroupName } ` ,
98100 ) ;
99101}
0 commit comments