test_create_project.py 2.4 KB

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