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
Original file line number Diff line number Diff line change
@@ -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(<ConfigureReplayCard isMobile replayRecord={replayRecord} />, {
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(<ConfigureReplayCard isMobile replayRecord={replayRecord} />, {
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(<ConfigureReplayCard isMobile replayRecord={replayRecord} />, {
organization: OrganizationFixture(),
});

expect(captureSpy).toHaveBeenCalledWith(
'Unknown mobile platform in configure card: sentry.unknown.platform'
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
Loading