Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions static/app/components/frontendVersionContext.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import ConfigStore from 'sentry/stores/configStore';

import {FrontendVersionProvider, useFrontendVersion} from './frontendVersionContext';

// Mock constants to control test environment, the FrontendVersionProvider ony
// does anything in production SAAS.
jest.mock('sentry/constants', () => ({
__esModule: true,
DEPLOY_PREVIEW_CONFIG: undefined,
NODE_ENV: 'production',
}));

const originalNodeEnv = process.env.NODE_ENV;

function TestComponent() {
const {state, deployedVersion, runningVersion} = useFrontendVersion();

Expand All @@ -29,10 +28,12 @@ describe('FrontendVersionProvider', () => {
beforeEach(() => {
MockApiClient.clearMockResponses();
ConfigStore.set('sentryMode', 'SAAS');
process.env.NODE_ENV = 'production';
});

afterEach(() => {
jest.restoreAllMocks();
process.env.NODE_ENV = originalNodeEnv;
});

it('provides state="current" when server version matches current version', async () => {
Expand Down Expand Up @@ -133,7 +134,7 @@ describe('FrontendVersionProvider', () => {
});

it('provides state="disabled" when NODE_ENV is not production', async () => {
jest.mocked(constants).NODE_ENV = 'development';
process.env.NODE_ENV = 'development';

MockApiClient.addMockResponse({
url: '/internal/frontend-version/',
Expand Down
4 changes: 2 additions & 2 deletions static/app/components/frontendVersionContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createContext, useContext} from 'react';

import {DEPLOY_PREVIEW_CONFIG, NODE_ENV} from 'sentry/constants';
import {DEPLOY_PREVIEW_CONFIG} from 'sentry/constants';
import ConfigStore from 'sentry/stores/configStore';
import {useLegacyStore} from 'sentry/stores/useLegacyStore';
import {useApiQuery} from 'sentry/utils/queryClient';
Expand Down Expand Up @@ -78,7 +78,7 @@ export function FrontendVersionProvider({children, force, releaseVersion}: Props
//
// We only make stale version assessments when the frontend is running a
// production build.
NODE_ENV === 'production' &&
process.env.NODE_ENV === 'production' &&
//
// We do not make stale version assessments when running deployment
// previews, these are inherinetly a differning version from what is
Expand Down
Loading