Просмотр исходного кода

chore(hybrid-cloud): Hide installation wizard for non-self-hosted (#62886)

Alberto Leal 1 год назад
Родитель
Сommit
bc8b456d42
2 измененных файлов с 23 добавлено и 3 удалено
  1. 21 1
      static/app/views/app/index.spec.tsx
  2. 2 2
      static/app/views/app/index.tsx

+ 21 - 1
static/app/views/app/index.spec.tsx

@@ -8,9 +8,13 @@ import ConfigStore from 'sentry/stores/configStore';
 import App from 'sentry/views/app';
 
 describe('App', function () {
+  const configState = ConfigStore.getState();
   const {routerProps} = initializeOrg();
 
   beforeEach(function () {
+    ConfigStore.init();
+    ConfigStore.loadInitialData(configState);
+
     MockApiClient.addMockResponse({
       url: '/organizations/',
       body: [OrganizationFixture({slug: 'billy-org', name: 'billy org'})],
@@ -98,9 +102,10 @@ describe('App', function () {
     expect(await screen.queryByText(/This organization is created in partnership/)).not.toBeInTheDocument();
   });
 
-  it('renders InstallWizard', async function () {
+  it('renders InstallWizard for self-hosted', async function () {
     ConfigStore.get('user').isSuperuser = true;
     ConfigStore.set('needsUpgrade', true);
+    ConfigStore.set('isSelfHosted', true);
 
     render(
       <App {...routerProps}>
@@ -114,6 +119,21 @@ describe('App', function () {
     expect(completeSetup).toBeInTheDocument();
   });
 
+  it('does not render InstallWizard for non-self-hosted', function () {
+    ConfigStore.get('user').isSuperuser = true;
+    ConfigStore.set('needsUpgrade', true);
+    ConfigStore.set('isSelfHosted', false);
+
+    render(
+      <App {...routerProps}>
+        <div>placeholder content</div>
+      </App>
+    );
+
+    expect(screen.getByText('placeholder content')).toBeInTheDocument();
+    expect(window.location.replace).not.toHaveBeenCalled();
+  });
+
   it('redirects to sentryUrl on invalid org slug', function () {
     const {sentryUrl} = ConfigStore.get('links');
     render(

+ 2 - 2
static/app/views/app/index.tsx

@@ -159,12 +159,12 @@ function App({children, params}: Props) {
     ConfigStore.set('user', {...config.user, flags});
   }
 
-  const needsUpgrade = config.user?.isSuperuser && config.needsUpgrade;
+  const displayInstallWizard = config.user?.isSuperuser && config.needsUpgrade && config.isSelfHosted;
   const newsletterConsentPrompt = config.user?.flags?.newsletter_consent_prompt;
   const partnershipAgreementPrompt = config.partnershipAgreementPrompt;
 
   function renderBody() {
-    if (needsUpgrade) {
+    if (displayInstallWizard) {
       return (
         <Suspense fallback={null}>
           <InstallWizard onConfigured={clearUpgrade} />;