diff --git a/static/app/components/replays/header/configureReplayCard.spec.tsx b/static/app/components/replays/header/configureReplayCard.spec.tsx new file mode 100644 index 000000000000..3e03d1070cfb --- /dev/null +++ b/static/app/components/replays/header/configureReplayCard.spec.tsx @@ -0,0 +1,69 @@ +import * as Sentry from '@sentry/react'; +import {OrganizationFixture} from 'sentry-fixture/organization'; +import {ReplayRecordFixture} from 'sentry-fixture/replayRecord'; + +import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; + +import {ConfigureReplayCard} from 'sentry/components/replays/header/configureReplayCard'; + +describe('ConfigureReplayCard', () => { + let captureSpy: jest.SpyInstance; + + beforeEach(() => { + captureSpy = jest.spyOn(Sentry, 'captureMessage').mockImplementation(() => ''); + }); + + afterEach(() => { + captureSpy.mockRestore(); + }); + + describe('getPath — mobile SDK routing', () => { + it('enables menu items for sentry.cocoa (iOS)', async () => { + const replayRecord = ReplayRecordFixture({ + sdk: {name: 'sentry.cocoa', version: '8.0.0'}, + }); + render(, { + organization: OrganizationFixture(), + }); + + await userEvent.click(screen.getByRole('button', {name: 'Configure Replay'})); + + expect(captureSpy).not.toHaveBeenCalled(); + expect(screen.getAllByRole('menuitemradio')).not.toHaveLength(0); + }); + + it('enables menu items for sentry.cocoa.unreal (iOS Unreal via embedded Cocoa SDK)', async () => { + const replayRecord = ReplayRecordFixture({ + sdk: {name: 'sentry.cocoa.unreal', version: '1.0.0'}, + }); + render(, { + organization: OrganizationFixture(), + }); + + await userEvent.click(screen.getByRole('button', {name: 'Configure Replay'})); + + // Should NOT fall through to the default case — no captureMessage call + expect(captureSpy).not.toHaveBeenCalled(); + + // All menu items should be enabled (not aria-disabled) + const items = screen.getAllByRole('menuitemradio'); + expect(items.length).toBeGreaterThan(0); + items.forEach(item => { + expect(item).not.toHaveAttribute('aria-disabled', 'true'); + }); + }); + + it('logs and disables menu items for unknown mobile platforms', () => { + const replayRecord = ReplayRecordFixture({ + sdk: {name: 'sentry.unknown.platform', version: '0.0.0'}, + }); + render(, { + organization: OrganizationFixture(), + }); + + expect(captureSpy).toHaveBeenCalledWith( + 'Unknown mobile platform in configure card: sentry.unknown.platform' + ); + }); + }); +}); diff --git a/static/app/components/replays/header/configureReplayCard.tsx b/static/app/components/replays/header/configureReplayCard.tsx index 2eb1753ac36b..c42125140d2c 100644 --- a/static/app/components/replays/header/configureReplayCard.tsx +++ b/static/app/components/replays/header/configureReplayCard.tsx @@ -44,6 +44,7 @@ export function ConfigureReplayCard({ function getPath(sdkName: string | null | undefined) { switch (sdkName) { case 'sentry.cocoa': + case 'sentry.cocoa.unreal': // Session Replay on iOS builds of Unreal Engine games via the embedded Cocoa SDK return 'apple/guides/ios'; // https://docs.sentry.io/platforms/apple/guides/ios/session-replay/ case 'sentry.java.android': return 'android'; // https://docs.sentry.io/platforms/android/session-replay/