@@ -507,6 +507,13 @@ describe("BackendClient", () => {
507507 } ) ;
508508
509509 describe ( "invokeWorkflow" , ( ) => {
510+ beforeEach ( ( ) => {
511+ client = new BackendClient ( {
512+ ...clientParams ,
513+ workflowDomain : "example.com" ,
514+ } ) ;
515+ } ) ;
516+
510517 it ( "should invoke a workflow with provided URL and body, with no auth type" , async ( ) => {
511518 fetchMock . mockResponseOnce (
512519 JSON . stringify ( {
@@ -675,15 +682,10 @@ describe("BackendClient", () => {
675682 let client : BackendClient ;
676683
677684 beforeEach ( ( ) => {
678- client = new BackendClient (
679- {
680- credentials : {
681- clientId : "test-client-id" ,
682- clientSecret : "test-client-secret" ,
683- } ,
684- projectId,
685- } ,
686- ) ;
685+ client = new BackendClient ( {
686+ ...clientParams ,
687+ workflowDomain : "example.com" ,
688+ } ) ;
687689 } ) ;
688690
689691 it ( "should include externalUserId and environment headers" , async ( ) => {
@@ -729,6 +731,22 @@ describe("BackendClient", () => {
729731 } ) ;
730732
731733 describe ( "BackendClient - buildWorkflowUrl" , ( ) => {
734+ describe ( "Validations" , ( ) => {
735+ it ( "should throw an error when the input is blank" , ( ) => {
736+ expect ( ( ) => client [ "buildWorkflowUrl" ] ( " " ) ) . toThrow ( "URL or endpoint ID is required" ) ;
737+ } ) ;
738+
739+ it ( "should throw an error when the URL doesn't match the workflow domain" , ( ) => {
740+ const url = "https://example.com" ;
741+ expect ( ( ) => client [ "buildWorkflowUrl" ] ( url ) ) . toThrow ( "Invalid workflow domain" ) ;
742+ } ) ;
743+
744+ it ( "should throw an error when the endpoint ID doesn't match the expected format" , ( ) => {
745+ const input = "foo123" ;
746+ expect ( ( ) => client [ "buildWorkflowUrl" ] ( input ) ) . toThrow ( "Invalid endpoint ID format" ) ;
747+ } ) ;
748+ } ) ;
749+
732750 describe ( "Default domain (m.pipedream.net)" , ( ) => {
733751 it ( "should return full URL if input is a full URL with protocol" , ( ) => {
734752 const input = "https://en123.m.pipedream.net" ;
0 commit comments