anchor.diff:              <<"fields">> => [<<"name">>]
           }
       },
  -    {ok, AllChanges} = get_changes(Config, WorkerP1, SpaceId, Json),
  -    RelevantChanges = [Change || Change <- AllChanges, map_size(Change) > 4],
  -    ?assert(length(RelevantChanges) >= 2),
  -
  -    [LastChange, PreLastChange | _] = RelevantChanges,
  -
  -    ?assertMatch(#{
  -        <<"fileMeta">> := #{
  -            <<"changed">> := false,
  -            <<"fields">> := #{
  -                <<"name">> := Name
  +
  +    ?assertMatch(
  +        [
  +            % Update times event event
  +            #{
  +                <<"fileMeta">> := #{
  +                    <<"changed">> := false,
  +                    <<"fields">> := #{
  +                        <<"name">> := Name
  +                    }
  +                },
  +                <<"times">> := #{
  +                    <<"changed">> := true,
  +                    <<"fields">> := #{
  +                        <<"atime">> := Time,
  +                        <<"mtime">> := Time,
  +                        <<"ctime">> := Time
  +                    }
  +                }
  +            },
  +            % Set metadata event
  +            #{
  +                <<"fileMeta">> := #{
  +                    <<"changed">> := false,
  +                    <<"fields">> := #{
  +                        <<"name">> := Name
  +                    }
  +                },
  +                <<"customMetadata">> := #{
  +                    <<"changed">> := true,
  +                    <<"fields">> := #{
  +                        <<"name">> := <<"value">>
  +                    }
  +                }
               }
  -        },
  -        <<"customMetadata">> := #{
  -            <<"changed">> := true,
  -            <<"fields">> := #{
  -                <<"name">> := <<"value">>
  -            }
  -        }
  -    }, PreLastChange),
  -    ?assert(not maps:is_key(<<"times">>, PreLastChange)),
  -
  -    ?assertMatch(#{
  -        <<"fileMeta">> := #{
  -            <<"changed">> := false,
  -            <<"fields">> := #{
  -                <<"name">> := Name
  -            }
  -        },
  -        <<"times">> := #{
  -            <<"changed">> := true,
  -            <<"fields">> := #{
  -                <<"atime">> := Time,
  -                <<"mtime">> := Time,
  -                <<"ctime">> := Time
  -            }
  -        }
  -    }, LastChange),
  -    ?assert(not maps:is_key(<<"customMetadata">>, LastChange)).
  +        ],
  +        get_changes_for_file(Config, WorkerP1, SpaceId, ChangesSpec, {object_id, FileObjectId}),
  +        ?ATTEMPTS
  +    ).
   
   
   changes_stream_on_multi_provider_test(Config) ->
  
positive.code:         lfm_proxy:set_metadata(WorkerP1, SessionId, {guid, FileGuid}, json, OnedataJson, [])
      end),
  
      Json = #{<<"customMetadata">> => #{
          <<"fields">> => [<<"onedata_json">>]
      }},
      {ok, AllSpaceChanges} = get_changes(Config, WorkerP1, SpaceId, Json),
      FileChanges = filter_changes_for_file(AllSpaceChanges, FileObjectId),
  
      % Both custom_metadata and times docs are changed, but since only
      % custom_metadata doc is observed only its change should trigger event
  
negative.code:                 }
              }}
          ],
          get_changes_for_file(Config, WorkerP1, SpaceId, ChangesSpec, {path, FilePath}),
          ?ATTEMPTS
      ).
  
  
  