Browse Source

Revert "ref(ts): Prefer actionCreator for org updates (#63313)"

This reverts commit 0978a7303f2b8c435e29b65b30a95102a8f49152.

Co-authored-by: evanpurkhiser <1421724+evanpurkhiser@users.noreply.github.com>
getsentry-bot 1 year ago
parent
commit
acf230a544

+ 6 - 8
static/app/actionCreators/onboardingTasks.spec.tsx

@@ -3,18 +3,16 @@ import {ProjectFixture} from 'sentry-fixture/project';
 import {TeamFixture} from 'sentry-fixture/team';
 
 import {updateOnboardingTask} from 'sentry/actionCreators/onboardingTasks';
-import {updateOrganization} from 'sentry/actionCreators/organizations';
 import ConfigStore from 'sentry/stores/configStore';
+import OrganizationStore from 'sentry/stores/organizationStore';
 import {OnboardingTaskKey} from 'sentry/types';
 
-jest.mock('sentry/actionCreators/organizations', () => ({
-  updateOrganization: jest.fn(),
-}));
-
 describe('actionCreators/onboardingTasks', function () {
   const api = new MockApiClient();
   const user = ConfigStore.get('user');
 
+  jest.spyOn(OrganizationStore, 'onUpdate');
+
   describe('updateOnboardingTask', function () {
     it('Adds the task to the organization when task does not exists', async function () {
       const detailedOrg = OrganizationFixture({
@@ -39,7 +37,7 @@ describe('actionCreators/onboardingTasks', function () {
 
       expect(mockUpdate).toHaveBeenCalled();
 
-      expect(updateOrganization).toHaveBeenCalledWith({
+      expect(OrganizationStore.onUpdate).toHaveBeenCalledWith({
         onboardingTasks: [{...testTask, user}],
       });
     });
@@ -70,7 +68,7 @@ describe('actionCreators/onboardingTasks', function () {
 
       // NOTE: user is not passed as it is already associated to the existing
       // onboarding task.
-      expect(updateOrganization).toHaveBeenCalledWith({
+      expect(OrganizationStore.onUpdate).toHaveBeenCalledWith({
         onboardingTasks: [testTask],
       });
     });
@@ -95,7 +93,7 @@ describe('actionCreators/onboardingTasks', function () {
       await tick();
 
       expect(mockUpdate).not.toHaveBeenCalled();
-      expect(updateOrganization).toHaveBeenCalledWith({
+      expect(OrganizationStore.onUpdate).toHaveBeenCalledWith({
         onboardingTasks: [{...testTask, user}],
       });
     });

+ 2 - 3
static/app/actionCreators/onboardingTasks.tsx

@@ -1,9 +1,8 @@
 import type {Client} from 'sentry/api';
 import ConfigStore from 'sentry/stores/configStore';
+import OrganizationStore from 'sentry/stores/organizationStore';
 import type {OnboardingTask, OnboardingTaskStatus, Organization} from 'sentry/types';
 
-import {updateOrganization} from './organizations';
-
 interface UpdatedTask extends Partial<Pick<OnboardingTask, 'status' | 'data'>> {
   task: OnboardingTask['task'];
   /**
@@ -42,5 +41,5 @@ export function updateOnboardingTask(
       )
     : [...organization.onboardingTasks, {...updatedTask, user} as OnboardingTaskStatus];
 
-  updateOrganization({onboardingTasks});
+  OrganizationStore.onUpdate({onboardingTasks});
 }