Skip to content

Commit eb09cf3

Browse files
committed
test: fix broken PerpsMarketDetailsView tests, add AgenticService coverage
- Update 4 test assertions for new FIRST_ROW testID on compact order rows - Add tests for registerStepHudCallback, showStep, hideStep, findFiberByTestId - New code coverage: 93% (13/14 lines)
1 parent 5526ebe commit eb09cf3

2 files changed

Lines changed: 56 additions & 10 deletions

File tree

app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.test.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,7 +2791,7 @@ describe('PerpsMarketDetailsView', () => {
27912791
{ state: initialState },
27922792
);
27932793

2794-
expect(getByTestId('compact-order-parent-order')).toBeOnTheScreen();
2794+
expect(getByTestId('perps-compact-order-row-first')).toBeOnTheScreen();
27952795
expect(queryByTestId('compact-order-full-position-tpsl')).toBeNull();
27962796
});
27972797

@@ -2859,9 +2859,7 @@ describe('PerpsMarketDetailsView', () => {
28592859
{ state: initialState },
28602860
);
28612861

2862-
expect(
2863-
getByTestId('compact-order-standalone-during-loading'),
2864-
).toBeOnTheScreen();
2862+
expect(getByTestId('perps-compact-order-row-first')).toBeOnTheScreen();
28652863
expect(queryByTestId('compact-order-full-position-loading')).toBeNull();
28662864
});
28672865

@@ -3015,9 +3013,7 @@ describe('PerpsMarketDetailsView', () => {
30153013
{ state: initialState },
30163014
);
30173015

3018-
expect(
3019-
getByTestId('compact-order-parent-order-with-metadata'),
3020-
).toBeOnTheScreen();
3016+
expect(getByTestId('perps-compact-order-row-first')).toBeOnTheScreen();
30213017
expect(
30223018
getByTestId('compact-order-parent-order-with-metadata-synthetic-tp'),
30233019
).toBeOnTheScreen();
@@ -3107,9 +3103,7 @@ describe('PerpsMarketDetailsView', () => {
31073103
);
31083104

31093105
expect(queryByTestId('compact-order-fallback-full-size')).toBeNull();
3110-
expect(
3111-
getByTestId('compact-order-fallback-standalone'),
3112-
).toBeOnTheScreen();
3106+
expect(getByTestId('perps-compact-order-row-first')).toBeOnTheScreen();
31133107
});
31143108

31153109
it('handles empty order list', () => {

app/core/AgenticService/AgenticService.test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AgenticService, {
44
walkFiberRoots,
55
tryScroll,
66
toAccountSummary,
7+
registerStepHudCallback,
78
type FiberNode,
89
type ReactDevToolsHook,
910
} from './AgenticService';
@@ -420,6 +421,57 @@ describe('AgenticService.install', () => {
420421
expect(() => bridge().switchAccount('0xfff')).toThrow('No account found');
421422
});
422423

424+
describe('showStep / hideStep', () => {
425+
afterEach(() => {
426+
registerStepHudCallback(null);
427+
});
428+
429+
it('showStep calls registered HUD callback with step data', () => {
430+
const callback = jest.fn();
431+
registerStepHudCallback(callback);
432+
433+
bridge().showStep({ id: 'step-1', description: 'Navigate to market' });
434+
435+
expect(callback).toHaveBeenCalledWith({
436+
id: 'step-1',
437+
description: 'Navigate to market',
438+
});
439+
});
440+
441+
it('hideStep calls registered HUD callback with null', () => {
442+
const callback = jest.fn();
443+
registerStepHudCallback(callback);
444+
445+
bridge().hideStep();
446+
447+
expect(callback).toHaveBeenCalledWith(null);
448+
});
449+
450+
it('showStep is a no-op when no callback is registered', () => {
451+
registerStepHudCallback(null);
452+
expect(() =>
453+
bridge().showStep({ id: 'x', description: 'y' }),
454+
).not.toThrow();
455+
});
456+
});
457+
458+
describe('findFiberByTestId (bridge)', () => {
459+
it('returns true when testID exists in fiber tree', () => {
460+
const fiber = makeFiber({
461+
child: makeFiber({ testID: 'target-btn' }),
462+
});
463+
installFiberHook(fiber);
464+
465+
expect(bridge().findFiberByTestId('target-btn')).toBe(true);
466+
});
467+
468+
it('returns false when testID does not exist', () => {
469+
installFiberHook(makeFiber());
470+
471+
expect(bridge().findFiberByTestId('missing-id')).toBe(false);
472+
});
473+
});
474+
423475
describe('pressTestId', () => {
424476
it('presses a component found by testID', () => {
425477
const onPress = jest.fn();

0 commit comments

Comments
 (0)