-
Notifications
You must be signed in to change notification settings - Fork 334
Fix type graph viewer to display scopeless decorator state #9541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/fix-scopeless-clientname-bug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+192
−18
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
deb0a93
Initial plan
Copilot ee7970e
Fix ObjectInspector to display Symbol-keyed properties
Copilot 9386116
Simplify ObjectInspector tests for Symbol properties
Copilot 1329be4
Refactor to reduce code duplication and improve test coverage
Copilot d72b5d9
Add Symbol key sorting support for consistency
Copilot 3f44231
Address PR feedback: simplify code and remove nested describe
Copilot 74c0456
Add Symbol sorting test and fix empty string key handling consistency
Copilot c64db10
Fix Symbol properties to show in collapsed object preview
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
packages/html-program-viewer/src/react/js-inspector/object-inspector.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import { render } from "@testing-library/react"; | ||
| import { expect, it } from "vitest"; | ||
| import { ObjectInspector } from "./object-inspector.js"; | ||
|
|
||
| it("should display Symbol-keyed properties", () => { | ||
| const sym = Symbol("testSymbol"); | ||
| const data = { | ||
| stringProp: "value1", | ||
| [sym]: "symbolValue", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} />); | ||
|
|
||
| // Check that the Symbol property is displayed | ||
| expect(container.textContent).toContain("Symbol(testSymbol)"); | ||
| expect(container.textContent).toContain("symbolValue"); | ||
| }); | ||
|
|
||
| it("should display Symbol-keyed properties without description", () => { | ||
| const sym = Symbol(); | ||
| const data = { | ||
| [sym]: "symbolValue", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} />); | ||
|
|
||
| // Check that the Symbol property is displayed (even without description) | ||
| expect(container.textContent).toContain("Symbol()"); | ||
| expect(container.textContent).toContain("symbolValue"); | ||
| }); | ||
|
|
||
| it("should display both string and Symbol properties", () => { | ||
| const sym1 = Symbol("first"); | ||
| const sym2 = Symbol("second"); | ||
| const data = { | ||
| stringProp1: "value1", | ||
| stringProp2: "value2", | ||
| [sym1]: "symbolValue1", | ||
| [sym2]: "symbolValue2", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} />); | ||
|
|
||
| // Check that all properties are displayed | ||
| expect(container.textContent).toContain("stringProp1"); | ||
| expect(container.textContent).toContain("value1"); | ||
| expect(container.textContent).toContain("stringProp2"); | ||
| expect(container.textContent).toContain("value2"); | ||
| expect(container.textContent).toContain("Symbol(first)"); | ||
| expect(container.textContent).toContain("symbolValue1"); | ||
| expect(container.textContent).toContain("Symbol(second)"); | ||
| expect(container.textContent).toContain("symbolValue2"); | ||
| }); | ||
|
|
||
| it("should display non-enumerable Symbol properties when showNonenumerable is true", () => { | ||
| const sym = Symbol("nonEnumSymbol"); | ||
| const data = {}; | ||
| // Define a non-enumerable Symbol property | ||
| Object.defineProperty(data, sym, { | ||
| value: "nonEnumValue", | ||
| enumerable: false, | ||
| }); | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} showNonenumerable={true} />); | ||
|
|
||
| // Check that the non-enumerable Symbol property is displayed | ||
| expect(container.textContent).toContain("Symbol(nonEnumSymbol)"); | ||
| expect(container.textContent).toContain("nonEnumValue"); | ||
| }); | ||
|
|
||
| it("should not display non-enumerable Symbol properties when showNonenumerable is false", () => { | ||
| const sym = Symbol("nonEnumSymbol"); | ||
| const data = {}; | ||
| // Define a non-enumerable Symbol property | ||
| Object.defineProperty(data, sym, { | ||
| value: "nonEnumValue", | ||
| enumerable: false, | ||
| }); | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} showNonenumerable={false} />); | ||
|
|
||
| // Check that the non-enumerable Symbol property is NOT displayed | ||
| expect(container.textContent).not.toContain("Symbol(nonEnumSymbol)"); | ||
| expect(container.textContent).not.toContain("nonEnumValue"); | ||
| }); | ||
|
|
||
| it("should sort Symbol properties when sortObjectKeys is true", () => { | ||
| const sym1 = Symbol("zebra"); | ||
| const sym2 = Symbol("apple"); | ||
| const sym3 = Symbol("middle"); | ||
| const data = { | ||
| [sym1]: "value1", | ||
| [sym2]: "value2", | ||
| [sym3]: "value3", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectInspector data={data} sortObjectKeys={true} />); | ||
|
|
||
| const text = container.textContent || ""; | ||
| const appleIndex = text.indexOf("Symbol(apple)"); | ||
| const middleIndex = text.indexOf("Symbol(middle)"); | ||
| const zebraIndex = text.indexOf("Symbol(zebra)"); | ||
|
|
||
| // Symbols should be sorted alphabetically by their description | ||
| expect(appleIndex).toBeGreaterThan(-1); | ||
| expect(middleIndex).toBeGreaterThan(-1); | ||
| expect(zebraIndex).toBeGreaterThan(-1); | ||
| expect(appleIndex).toBeLessThan(middleIndex); | ||
| expect(middleIndex).toBeLessThan(zebraIndex); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/html-program-viewer/src/react/js-inspector/object-preview.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { render } from "@testing-library/react"; | ||
| import { expect, it } from "vitest"; | ||
| import { ObjectPreview } from "./object-preview.js"; | ||
|
|
||
| it("should display Symbol properties in object preview", () => { | ||
| const sym = Symbol("testSymbol"); | ||
| const data = { | ||
| stringProp: "value1", | ||
| [sym]: "symbolValue", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectPreview data={data} />); | ||
|
|
||
| // Check that both string and Symbol properties are displayed in preview | ||
| expect(container.textContent).toContain("stringProp"); | ||
| expect(container.textContent).toContain("value1"); | ||
| expect(container.textContent).toContain("Symbol(testSymbol)"); | ||
| expect(container.textContent).toContain("symbolValue"); | ||
| }); | ||
|
|
||
| it("should display Symbol properties without description in preview", () => { | ||
| const sym = Symbol(); | ||
| const data = { | ||
| [sym]: "value", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectPreview data={data} />); | ||
|
|
||
| expect(container.textContent).toContain("Symbol()"); | ||
| expect(container.textContent).toContain("value"); | ||
| }); | ||
|
|
||
| it("should respect max properties limit including Symbol properties", () => { | ||
| const sym1 = Symbol("first"); | ||
| const sym2 = Symbol("second"); | ||
| const data = { | ||
| prop1: "val1", | ||
| prop2: "val2", | ||
| prop3: "val3", | ||
| prop4: "val4", | ||
| [sym1]: "symVal1", | ||
| [sym2]: "symVal2", | ||
| }; | ||
|
|
||
| const { container } = render(<ObjectPreview data={data} />); | ||
|
|
||
| // Should show ellipsis when exceeding max properties (5) | ||
| expect(container.textContent).toContain("…"); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/html-program-viewer/src/react/js-inspector/utils/property-utils.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This is a good start but it doesn't show up in the collapsed object preview, only when expanded, why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c64db10. The issue was that
object-preview.tsxwas using afor...inloop which only iterates over enumerable string properties. Updated it to useObject.getOwnPropertyNames()andObject.getOwnPropertySymbols()to include Symbol keys, matching the approach inobject-inspector.tsx. Symbol properties now appear in both collapsed and expanded views.