Skip to content

Commit

Permalink
Merge branch 'master' into dn-chore/remove-prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin committed Mar 21, 2024
2 parents 54aa113 + da97985 commit b2a56fd
Show file tree
Hide file tree
Showing 50 changed files with 861 additions and 666 deletions.
46 changes: 8 additions & 38 deletions ee/api/test/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from rest_framework import status

from ee.api.test.base import APILicensedTest
from ee.api.test.fixtures.available_product_features import AVAILABLE_PRODUCT_FEATURES
from ee.models.explicit_team_membership import ExplicitTeamMembership
from ee.models.license import License
from posthog.constants import AvailableFeature
from posthog.models import OrganizationMembership
from posthog.models.dashboard import Dashboard
from posthog.models.sharing_configuration import SharingConfiguration
Expand Down Expand Up @@ -269,7 +267,12 @@ def test_sharing_edits_limited_to_collaborators(self):
self.permission_denied_response("You don't have edit permissions for this dashboard."),
)

def test_cannot_edit_dashboard_description_when_collaboration_not_available(self):
def test_can_edit_dashboard_description_when_collaboration_not_available(self):
"""
Team collaboration feature is only available on some plans, but if the feature is
not available, the user should still be able to read/write for migration purposes.
The access to the feature is blocked in the UI, so this is unlikely to be truly abused.
"""
self.client.logout()

self.organization.available_features = []
Expand All @@ -288,49 +291,16 @@ def test_cannot_edit_dashboard_description_when_collaboration_not_available(self
name="example dashboard",
)

response = self.client.patch(
f"/api/projects/{self.team.id}/dashboards/{dashboard.id}",
{
"description": "i should not be allowed to edit this",
"name": "even though I am allowed to edit this",
},
)

self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

dashboard.refresh_from_db()
self.assertEqual(dashboard.description, "")
self.assertEqual(dashboard.name, "example dashboard")

def test_can_edit_dashboard_description_when_collaboration_is_available(self):
self.client.logout()

self.organization.available_features = [AvailableFeature.TEAM_COLLABORATION]
self.organization.available_product_features = AVAILABLE_PRODUCT_FEATURES
self.organization.save()
self.team.access_control = True
self.team.save()

user_with_collaboration = User.objects.create_and_join(
self.organization, "[email protected]", None
)
self.client.force_login(user_with_collaboration)

dashboard: Dashboard = Dashboard.objects.create(
team=self.team,
name="example dashboard",
)

response = self.client.patch(
f"/api/projects/{self.team.id}/dashboards/{dashboard.id}",
{
"description": "i should be allowed to edit this",
"name": "and so also to edit this",
"name": "as well as this",
},
)

self.assertEqual(response.status_code, status.HTTP_200_OK)

dashboard.refresh_from_db()
self.assertEqual(dashboard.description, "i should be allowed to edit this")
self.assertEqual(dashboard.name, "and so also to edit this")
self.assertEqual(dashboard.name, "as well as this")
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# serializer version: 1
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results
'''
/* user_id:108 celery:posthog.tasks.tasks.sync_insight_caching_state */
/* user_id:107 celery:posthog.tasks.tasks.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
Expand Down
Loading

0 comments on commit b2a56fd

Please sign in to comment.