test_create_project.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from unittest.mock import patch
  2. from sentry.models import Project
  3. from sentry.testutils import AcceptanceTestCase
  4. from sentry.testutils.silo import region_silo_test
  5. @region_silo_test
  6. class CreateProjectTest(AcceptanceTestCase):
  7. def setUp(self):
  8. super().setUp()
  9. self.user = self.create_user("foo@example.com")
  10. self.org = self.create_organization(name="Rowdy Tiger")
  11. self.login_as(self.user)
  12. self.path = f"/organizations/{self.org.slug}/projects/new/"
  13. @patch("django.db.models.signals.ModelSignal.send")
  14. def test_simple(self, mock_signal):
  15. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  16. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  17. self.browser.get(self.path)
  18. self.browser.wait_until_not(".loading")
  19. self.browser.click('[data-test-id="platform-java"]')
  20. self.browser.snapshot(name="create project")
  21. self.browser.click('[data-test-id="create-project"]')
  22. self.browser.wait_until_not(".loading")
  23. self.browser.wait_until("#installation")
  24. project = Project.objects.get(organization=self.org)
  25. assert project.name == "Java"
  26. assert project.platform == "java"
  27. assert project.teams.first() == self.team
  28. self.browser.snapshot(name="docs redirect")
  29. def test_no_teams(self):
  30. self.create_member(user=self.user, organization=self.org, role="owner", teams=[])
  31. self.browser.get(self.path)
  32. self.browser.wait_until_not(".loading")
  33. self.browser.click('[data-test-id="create-team"]')
  34. self.browser.wait_until("[role='dialog']")
  35. input = self.browser.element('input[name="slug"]')
  36. input.send_keys("new-team")
  37. self.browser.element("[role='dialog'] form").submit()
  38. # After creating team, should end up in onboarding screen
  39. self.browser.wait_until(xpath='//span[text()="#new-team"]')
  40. self.browser.snapshot(name="create project no teams - after create team")
  41. def test_many_teams(self):
  42. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  43. self.team2 = self.create_team(organization=self.org, name="team two")
  44. self.create_member(
  45. user=self.user, organization=self.org, role="owner", teams=[self.team, self.team2]
  46. )
  47. self.browser.get(self.path)
  48. self.browser.wait_until_not(".loading")
  49. self.browser.snapshot(name="create project many teams")