diff --git a/app/src/__tests__/store-history.test.ts b/app/src/__tests__/store-history.test.ts index 6140b7b2..250adcd2 100644 --- a/app/src/__tests__/store-history.test.ts +++ b/app/src/__tests__/store-history.test.ts @@ -414,6 +414,25 @@ describe('Provider value', () => { expect(region.textContent).toContain('id:'); }); + it('sends the token id, and closes when another token with the same name takes the row', async () => { + const call = vi.fn(async () => ({ ok: true, type: 'Object', members: [] })); + const fixture = await mount(call); + fixture.componentRef.setInput('tokenId', 'tok-3'); + await settle(fixture); + const toggle = button(fixture, 'Show the value of CartService'); + toggle.click(); + await settle(fixture); + expect(call).toHaveBeenCalledWith('request-provider-value', { + pageId: 'p1', + request: { injectorId: 'inj-1', token: 'CartService', tokenId: 'tok-3', index: 2, path: [] }, + }); + expect(toggle.getAttribute('aria-expanded')).toBe('true'); + // Same name and index, different token (#367): the open value belonged to the other one. + fixture.componentRef.setInput('tokenId', 'tok-4'); + await settle(fixture); + expect(toggle.getAttribute('aria-expanded')).toBe('false'); + }); + it('shows only the latest read when it is closed and reopened while a read is pending', async () => { const pending: ((answer: unknown) => void)[] = []; const call = vi.fn(() => new Promise((resolve) => pending.push(resolve))); diff --git a/app/src/pages/di-inspector.ts b/app/src/pages/di-inspector.ts index 66f66fdc..6a910884 100644 --- a/app/src/pages/di-inspector.ts +++ b/app/src/pages/di-inspector.ts @@ -32,6 +32,8 @@ import { StartupSection } from './startup-section'; interface ProviderInfo { token: string; + /** The page's id for the token object; two tokens can share a name. Missing in older reports. */ + tokenId?: string; type: string; isViewProvider: boolean; multi?: boolean; @@ -42,6 +44,7 @@ interface ProviderInfo { interface DependencyInfo { from: string; token: string; + tokenId?: string; flags: string[]; providedBy: string | null; } @@ -457,7 +460,10 @@ function isTree(value: unknown): value is InjectorNode[] { } @if (sel.dependencies?.length) {