Browse Source

test(js): Remove projects / teams from organizations (#72756)

Our tests fixture was still using the very old "DetailedOrganization"
object. We no longer include the projects or teams fields on
organizations, this removes all usages of those fields in tests
Evan Purkhiser 9 months ago
parent
commit
cadf0c60d9

+ 1 - 1
static/app/actionCreators/navigation.spec.tsx

@@ -20,7 +20,7 @@ describe('navigation ActionCreator', () => {
       },
     });
     router = initialData.router;
-    ProjectsStore.loadInitialData(initialData.organization.projects);
+    ProjectsStore.loadInitialData(initialData.projects);
   });
 
   afterEach(() => {

+ 2 - 12
static/app/actionCreators/onboardingTasks.spec.tsx

@@ -1,6 +1,4 @@
 import {OrganizationFixture} from 'sentry-fixture/organization';
-import {ProjectFixture} from 'sentry-fixture/project';
-import {TeamFixture} from 'sentry-fixture/team';
 
 import {updateOnboardingTask} from 'sentry/actionCreators/onboardingTasks';
 import ConfigStore from 'sentry/stores/configStore';
@@ -15,10 +13,7 @@ describe('actionCreators/onboardingTasks', function () {
 
   describe('updateOnboardingTask', function () {
     it('Adds the task to the organization when task does not exists', async function () {
-      const detailedOrg = OrganizationFixture({
-        teams: [TeamFixture()],
-        projects: [ProjectFixture()],
-      });
+      const detailedOrg = OrganizationFixture({});
 
       // User is not passed into the update request
       const testTask = {
@@ -44,8 +39,6 @@ describe('actionCreators/onboardingTasks', function () {
 
     it('Updates existing onboarding task', async function () {
       const detailedOrg = OrganizationFixture({
-        teams: [TeamFixture()],
-        projects: [ProjectFixture()],
         onboardingTasks: [{task: OnboardingTaskKey.FIRST_EVENT, status: 'skipped'}],
       });
 
@@ -74,10 +67,7 @@ describe('actionCreators/onboardingTasks', function () {
     });
 
     it('Does not make API request without api object', async function () {
-      const detailedOrg = OrganizationFixture({
-        teams: [TeamFixture()],
-        projects: [ProjectFixture()],
-      });
+      const detailedOrg = OrganizationFixture({});
 
       const testTask = {
         task: OnboardingTaskKey.FIRST_EVENT,

+ 14 - 14
static/app/actionCreators/pageFilters.spec.tsx

@@ -17,7 +17,7 @@ import localStorage from 'sentry/utils/localStorage';
 
 jest.mock('sentry/utils/localStorage');
 
-const {organization} = initializeOrg({
+const {organization, projects} = initializeOrg({
   projects: [
     {id: '1', slug: 'project-1', environments: ['prod', 'staging']},
     {id: '2', slug: 'project-2', environments: ['prod', 'stage']},
@@ -59,7 +59,7 @@ describe('PageFilters ActionCreators', function () {
         organization,
         queryParams: {},
         router,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
       });
@@ -91,7 +91,7 @@ describe('PageFilters ActionCreators', function () {
         organization,
         queryParams: {},
         skipLoadLastUsed: true,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         router,
@@ -115,7 +115,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {},
         shouldPersist: false,
         router,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
       });
@@ -152,7 +152,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {
           project: '1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         router,
@@ -177,7 +177,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {
           project: '1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         defaultSelection: {
@@ -211,7 +211,7 @@ describe('PageFilters ActionCreators', function () {
           statsPeriod: '1h',
           project: '1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         defaultSelection: {
@@ -244,7 +244,7 @@ describe('PageFilters ActionCreators', function () {
           end: '2020-04-21T00:53:38',
           project: '1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         defaultSelection: {
@@ -276,7 +276,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {
           project: '1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         router,
@@ -312,7 +312,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {
           project: '-1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         router,
@@ -339,7 +339,7 @@ describe('PageFilters ActionCreators', function () {
         queryParams: {
           project: '-1',
         },
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         // User does not have access to global views
         shouldEnforceSingleProject: true,
@@ -382,7 +382,7 @@ describe('PageFilters ActionCreators', function () {
         organization,
         queryParams: {},
         router,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
       });
@@ -414,7 +414,7 @@ describe('PageFilters ActionCreators', function () {
         organization,
         queryParams: {},
         router,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
       });
@@ -448,7 +448,7 @@ describe('PageFilters ActionCreators', function () {
         organization,
         queryParams: {},
         router,
-        memberProjects: organization.projects,
+        memberProjects: projects,
         nonMemberProjects: [],
         shouldEnforceSingleProject: false,
         storageNamespace: 'starfish',

+ 1 - 1
static/app/components/contextPickerModal.spec.tsx

@@ -26,7 +26,7 @@ describe('ContextPickerModal', function () {
     MockApiClient.clearMockResponses();
 
     project = ProjectFixture();
-    org = OrganizationFixture({projects: [project]});
+    org = OrganizationFixture();
     project2 = ProjectFixture({slug: 'project2'});
     org2 = OrganizationFixture({
       slug: 'org2',

+ 2 - 5
static/app/components/events/eventReplay/replayClipPreview.spec.tsx

@@ -6,7 +6,7 @@ import {ReplayRecordFixture} from 'sentry-fixture/replayRecord';
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render as baseRender, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
-import type {DetailedOrganization} from 'sentry/types/organization';
+import type {Organization} from 'sentry/types/organization';
 import useReplayReader from 'sentry/utils/replays/hooks/useReplayReader';
 import ReplayReader from 'sentry/utils/replays/replayReader';
 import type RequestError from 'sentry/utils/requestError/requestError';
@@ -61,10 +61,7 @@ mockUseReplayReader.mockImplementation(() => {
   };
 });
 
-const render = (
-  children: React.ReactElement,
-  orgParams: Partial<DetailedOrganization> = {}
-) => {
+const render = (children: React.ReactElement, orgParams: Partial<Organization> = {}) => {
   const {router, organization} = initializeOrg({
     organization: {slug: mockOrgSlug, ...orgParams},
     router: {

+ 1 - 1
static/app/components/events/interfaces/spans/traceView.spec.tsx

@@ -23,7 +23,7 @@ import QuickTraceQuery from 'sentry/utils/performance/quickTrace/quickTraceQuery
 
 function initializeData(settings) {
   const data = _initializeData(settings);
-  ProjectsStore.loadInitialData(data.organization.projects);
+  ProjectsStore.loadInitialData(data.projects);
   return data;
 }
 

+ 1 - 1
static/app/components/modals/inviteMembersModal/index.spec.tsx

@@ -72,7 +72,7 @@ describe('InviteMembersModal', function () {
     orgTeams?: DetailedTeam[];
     roles?: object[];
   } = {}) => {
-    const org = OrganizationFixture({access: orgAccess, teams: orgTeams});
+    const org = OrganizationFixture({access: orgAccess});
     TeamStore.reset();
     TeamStore.loadInitialData(orgTeams);
 

+ 2 - 2
static/app/components/modals/inviteMissingMembersModal/index.spec.tsx

@@ -33,7 +33,7 @@ const mockRefObject = {
 
 describe('InviteMissingMembersModal', function () {
   const team = TeamFixture();
-  const org = OrganizationFixture({access: ['member:write'], teams: [team]});
+  const org = OrganizationFixture({access: ['member:write']});
   TeamStore.loadInitialData([team]);
   const missingMembers = MissingMembersFixture();
 
@@ -166,7 +166,7 @@ describe('InviteMissingMembersModal', function () {
     render(
       <InviteMissingMembersModal
         {...modalProps}
-        organization={OrganizationFixture({defaultRole: 'member', teams: [team]})}
+        organization={OrganizationFixture({defaultRole: 'member'})}
         missingMembers={missingMembers}
         allowedRoles={roles}
       />

+ 1 - 1
static/app/components/modals/widgetViewerModal.spec.tsx

@@ -562,7 +562,7 @@ describe('Modals -> WidgetViewerModal', function () {
       });
 
       it('renders transaction summary link', async function () {
-        ProjectsStore.loadInitialData(initialData.organization.projects);
+        ProjectsStore.loadInitialData(initialData.projects);
         MockApiClient.addMockResponse({
           url: '/organizations/org-slug/events/',
           body: {

+ 3 - 3
static/app/components/organizations/environmentPageFilter/index.spec.tsx

@@ -7,7 +7,7 @@ import OrganizationStore from 'sentry/stores/organizationStore';
 import PageFiltersStore from 'sentry/stores/pageFiltersStore';
 import ProjectsStore from 'sentry/stores/projectsStore';
 
-const {organization, router} = initializeOrg({
+const {organization, projects, router} = initializeOrg({
   organization: {features: ['global-views', 'open-membership']},
   projects: [
     {id: '1', slug: 'project-1', environments: ['prod', 'staging']},
@@ -37,7 +37,7 @@ describe('EnvironmentPageFilter', function () {
     );
 
     OrganizationStore.onUpdate(organization, {replace: true});
-    ProjectsStore.loadInitialData(organization.projects);
+    ProjectsStore.loadInitialData(projects);
   });
 
   afterEach(() => PageFiltersStore.reset());
@@ -149,7 +149,7 @@ describe('EnvironmentPageFilter', function () {
 
     PageFiltersStore.reset();
     initializeUrlState({
-      memberProjects: organization.projects,
+      memberProjects: projects,
       nonMemberProjects: [],
       organization: desyncOrganization,
       queryParams: {project: ['1'], environment: 'staging'},

Some files were not shown because too many files changed in this diff