Skip to content
Draft
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
87 changes: 25 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,37 @@
expect(metrics.reactMountCount).toBe(0)
})

it('creates a new core when force remount is triggered (same story ID)', () => {
const ctx = makeCtx({id: 'story-a'} as Partial<StoryContext>)

withPerformanceMonitor(vi.fn(() => ''), ctx)

Check failure on line 231 in packages/storybook-addon-performance-panel/__tests__/performance-decorator-universal.browser.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `vi.fn(()·=>·''),·ctx` with `⏎······vi.fn(()·=>·''),⏎······ctx,⏎····`
const first = getActiveCore()

// Simulate force remount — same ID but forceRemount flag
const remountCtx = makeCtx({id: 'story-a', forceRemount: true} as Partial<StoryContext>)
withPerformanceMonitor(vi.fn(() => ''), remountCtx)

Check failure on line 236 in packages/storybook-addon-performance-panel/__tests__/performance-decorator-universal.browser.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `vi.fn(()·=>·''),·remountCtx` with `⏎······vi.fn(()·=>·''),⏎······remountCtx,⏎····`
const second = getActiveCore()

expect(second).not.toBe(first)
})

it('cleans up channel listeners when core is replaced by force remount', () => {
withPerformanceMonitor(
vi.fn(() => ''),
makeCtx({id: 'story-a'} as Partial<StoryContext>),
)

// Force remount replaces the core, which should stop the old one and call channel.off
withPerformanceMonitor(
vi.fn(() => ''),
makeCtx({id: 'story-a', forceRemount: true} as Partial<StoryContext>),
)

expect(mockChannel.off).toHaveBeenCalledWith(PERF_EVENTS.REQUEST_METRICS, expect.any(Function))
expect(mockChannel.off).toHaveBeenCalledWith(PERF_EVENTS.RESET, expect.any(Function))
expect(mockChannel.off).toHaveBeenCalledWith(PERF_EVENTS.INSPECT_ELEMENT, expect.any(Function))
})

it('cleans up channel listeners when core is replaced', () => {
withPerformanceMonitor(
vi.fn(() => ''),
Expand Down
Loading
Loading