0

I have implemented flow to handle platform event on Order Status Changed Event , working fine with the flow, but it is not working with the Test Class, here is my test method

@IsTest
static void Test1(){

    Test.enableChangeDataCapture(); 
    Test.startTest();
    Order order = [SELECT Id, Status FROM Order Where Account.Name = 'TestAccount']; 
    order.Status = 'Dispatched';
    update order;
    Test.getEventBus().deliver(); 
    Test.stopTest(); 
}

I expected the flow will create Invoice after the card is dispatched. I have created another test for ContactChangeEvent works fine, here is the test method

 @IsTest
static void Test2()
{ 
    Test.enableChangeDataCapture();
    Test.startTest();
        Contact contact = [SELECT Id, Department FROM Contact WHERE   Email ='[email protected]'];
        contact.Department = 'IT Division';
        update contact;
    Test.getEventBus().deliver();
    Test.stopTest();
}

the only difference I found with the event is Changed the first one has Order Status Changed Event and another one ContactChangeEvent, may be I am missing something, any help will be appreciated. Thank you

2
  • is the first test class at v51 or higher? (I presume the mocked Order starts with a Status other than Dispatched
    – cropredy
    Dec 19, 2022 at 20:47
  • Both test class in V56, Order Status = Draft before updating.
    – jks
    Dec 20, 2022 at 8:50

1 Answer 1

0

Im currently having a similar issue where the Order Summary Created Event does not appear to be firing.

Thinking that I am going to refactor the Flow to be triggered off of record create versus platform event based as I've experienced inconsistency like this before where the platform event flows just seem to not fire.

When getting help from a support case, the solution provided to me was to Deactivate and Reactivate the flow. Not much of a solution/explanation for why this issue occurs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .