test_onboarding.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. from unittest import mock
  2. from selenium.common.exceptions import TimeoutException
  3. from sentry.models import Project
  4. from sentry.testutils import AcceptanceTestCase
  5. from sentry.utils.retries import TimedRetryPolicy
  6. class OrganizationOnboardingTest(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", owner=None)
  11. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  12. self.member = self.create_member(
  13. user=self.user, organization=self.org, role="owner", teams=[self.team]
  14. )
  15. self.login_as(self.user)
  16. @mock.patch("sentry.models.ProjectKey.generate_api_key", return_value="test-dsn")
  17. def test_onboarding(self, generate_api_key):
  18. self.browser.get("/onboarding/%s/" % self.org.slug)
  19. # Welcome step
  20. self.browser.wait_until('[data-test-id="onboarding-step-welcome"]')
  21. self.browser.snapshot(name="onboarding - welcome")
  22. # Platform selection step
  23. self.browser.click('[aria-label="Start"]')
  24. self.browser.wait_until('[data-test-id="onboarding-step-select-platform"]')
  25. self.browser.snapshot(name="onboarding - select platform")
  26. # Select and create node JS project
  27. self.browser.click('[data-test-id="platform-node"]')
  28. self.browser.wait_until_not('[data-test-id="platform-select-next"][aria-disabled="true"]')
  29. self.browser.wait_until('[data-test-id="platform-select-next"][aria-disabled="false"]')
  30. @TimedRetryPolicy.wrap(timeout=5, exceptions=((TimeoutException,)))
  31. def click_platform_select_name(browser):
  32. browser.click('[data-test-id="platform-select-next"]')
  33. # Project getting started
  34. browser.wait_until('[data-test-id="onboarding-step-get-started"]')
  35. click_platform_select_name(self.browser)
  36. self.browser.snapshot(name="onboarding - get started")
  37. # Verify project was created for org
  38. project = Project.objects.get(organization=self.org)
  39. assert project.name == "rowdy-tiger"
  40. assert project.platform == "node"
  41. self.browser.click('[data-test-id="onboarding-getting-started-invite-members"]')
  42. self.browser.wait_until("[role='dialog']")
  43. self.browser.snapshot(name="onboarding - invite members")
  44. @mock.patch("sentry.models.ProjectKey.generate_api_key", return_value="test-dsn")
  45. @mock.patch(
  46. "sentry.experiments.all", return_value={"TargetedOnboardingMultiSelectExperiment": 1}
  47. )
  48. def test_onboarding_new(self, generate_api_key, all_experiments):
  49. self.browser.get("/onboarding/%s/" % self.org.slug)
  50. # Welcome step
  51. self.browser.wait_until('[data-test-id="onboarding-step-welcome"]')
  52. self.browser.snapshot(name="onboarding - new - welcome")
  53. # Platform selection step
  54. self.browser.click('[aria-label="Start"]')
  55. self.browser.wait_until('[data-test-id="onboarding-step-select-platform"]')
  56. self.browser.snapshot(name="onboarding - new - select platform")
  57. # Select and create node JS project
  58. self.browser.click('[data-test-id="platform-node"]')
  59. self.browser.wait_until_not('[data-test-id="platform-select-next"][aria-disabled="true"]')
  60. self.browser.wait_until('[data-test-id="platform-select-next"][aria-disabled="false"]')
  61. @TimedRetryPolicy.wrap(timeout=5, exceptions=((TimeoutException,)))
  62. def click_platform_select_name(browser):
  63. browser.click('[data-test-id="platform-select-next"]')
  64. # Project getting started
  65. browser.wait_until('[data-test-id="onboarding-step-setup-docs"]')
  66. click_platform_select_name(self.browser)
  67. self.browser.snapshot(name="onboarding - new - setup docs")
  68. # Verify project was created for org
  69. project = Project.objects.get(organization=self.org)
  70. assert project.name == "node"
  71. assert project.platform == "node"
  72. # The homepage should redirect to onboarding
  73. self.browser.get("/")
  74. self.browser.wait_until('[data-test-id="onboarding-step-setup-docs"]')