If you refresh a materialized view in a transaction and rollback the transaction, the view remains in the state before the transaction (i.e. not refreshed). You have to commit the transaction to get all its commands to be completed.
Example setup:
create table my_table(id int);
create materialized view mat_view as
select * from my_table;
Transaction:
begin;
insert into my_table
select i from generate_series(1, 3) i;
refresh materialized view mat_view;
select * from mat_view;
-- inside the transaction the view is refreshed
id
----
1
2
3
(3 rows)
rollback;
Outside the transaction:
select * from mat_view;
-- but after rollback the view is empty again
id
----
(0 rows)