@@ -152,3 +152,33 @@ def test_post_replay_viewed_by_not_exist(self):
152
152
with self .feature (REPLAYS_FEATURES ):
153
153
response = self .client .post (self .url , data = "" )
154
154
assert response .status_code == 404
155
+
156
+ @patch ("sentry.replays.endpoints.project_replay_viewed_by.publish_replay_event" )
157
+ def test_post_replay_viewed_by_not_in_org (self , publish_replay_event ):
158
+ with self .feature (REPLAYS_FEATURES ):
159
+ finished_at_dt = datetime .datetime .now () - datetime .timedelta (seconds = 20 )
160
+ self .store_replays (mock_replay (finished_at_dt , self .project .id , self .replay_id ))
161
+ self .login_as (user = self .create_user (is_superuser = True , is_staff = True ), superuser = True )
162
+ response = self .client .post (self .url , data = "" )
163
+ assert response .status_code == 204
164
+ assert not publish_replay_event .called
165
+
166
+ def test_get_replay_viewed_by_user_in_other_org (self ):
167
+ other_org_member = self .create_member (
168
+ organization = self .create_organization (), user = self .create_user ()
169
+ )
170
+ seq1_timestamp = datetime .datetime .now () - datetime .timedelta (seconds = 10 )
171
+ seq2_timestamp = datetime .datetime .now () - datetime .timedelta (seconds = 5 )
172
+ self .store_replays (mock_replay (seq1_timestamp , self .project .id , self .replay_id ))
173
+ self .store_replays (mock_replay (seq2_timestamp , self .project .id , self .replay_id ))
174
+
175
+ self .store_replays (
176
+ mock_replay_viewed (
177
+ time .time (), self .project .id , self .replay_id , other_org_member .user_id
178
+ )
179
+ )
180
+
181
+ with self .feature (REPLAYS_FEATURES ):
182
+ response = self .client .get (self .url )
183
+ assert response .status_code == 200
184
+ assert len (response .data ["data" ]["viewed_by" ]) == 0
0 commit comments