AlwaysOn availability group and replication – expected behavior

I am currently doing some testing with alwayson and replication. I currently have the following:

  • Cluster fully functional and always in environment; DCTEST1, DCTEST2 and the name of the listener DCTEST_L. The cluster is healthy.
    • Fully functional transactional replication on another server: DCREPL
    • Everything is SQL2017 Enterprise

Replication to DCREPL works regardless of which node is the primary. I make data changes in DCTEST_L and they are successfully passed to the subscriber.

The problem I have is when I turn off the primary (DCTEST1). The availability group fails successfully. However, when I make data changes in the listener – DCTEST_L; they do not replicate to DCREPL.
When DCTEST1 is turned on again, the changes are replicated correctly.
Is this the expected behavior? I would like replication to continue if the primary fails, and it does not have to stop until the node turns on again.

Is there a step that I have lost? I have followed the microsoft documentation: 2017