diff --git a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js
index 7cb7ebb77f5ae..193f4670d3781 100644
--- a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js
+++ b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js
@@ -65,7 +65,9 @@ describe('InspectedElement', () => {
.TreeContextController;
// Used by inspectElementAtIndex() helper function
- testRendererInstance = TestRenderer.create(null);
+ testRendererInstance = TestRenderer.create(null, {
+ unstable_isConcurrent: true,
+ });
});
afterEach(() => {
@@ -259,7 +261,9 @@ describe('InspectedElement', () => {
// from props like defaultSelectedElementID and it's easier to reset here than
// to read the TreeDispatcherContext and update the selected ID that way.
// We're testing the inspected values here, not the context wiring, so that's ok.
- testRendererInstance = TestRenderer.create(null);
+ testRendererInstance = TestRenderer.create(null, {
+ unstable_isConcurrent: true,
+ });
const inspectedElement = await inspectElementAtIndex(index);
@@ -1197,10 +1201,9 @@ describe('InspectedElement', () => {
"1": 2,
"2": 3,
},
- "1": Object {
- "0": "a",
- "1": "b",
- "2": "c",
+ "1": Dehydrated {
+ "preview_short": Set(3),
+ "preview_long": Set(3) {"a", "b", "c"},
},
},
}
@@ -1283,12 +1286,9 @@ describe('InspectedElement', () => {
},
"value": 1,
},
- "c": Object {
- "d": Dehydrated {
- "preview_short": {…},
- "preview_long": {e: {…}, value: 1},
- },
- "value": 1,
+ "c": Dehydrated {
+ "preview_short": {…},
+ "preview_long": {d: {…}, value: 1},
},
},
}
@@ -1377,6 +1377,143 @@ describe('InspectedElement', () => {
done();
});
+ it('should return a full update if a path is inspected for an object that has other pending changes', async done => {
+ const Example = () => null;
+
+ const container = document.createElement('div');
+ await utils.actAsync(() =>
+ ReactDOM.render(
+ ,
+ container,
+ ),
+ );
+
+ let inspectedElement = null;
+ let inspectElementPath = null;
+
+ // Render once to get a handle on inspectElementPath()
+ inspectedElement = await inspectElementAtIndex(0, () => {
+ inspectElementPath = useInspectElementPath();
+ });
+
+ async function loadPath(path) {
+ TestUtilsAct(() => {
+ TestRendererAct(() => {
+ inspectElementPath(path);
+ jest.runOnlyPendingTimers();
+ });
+ });
+
+ inspectedElement = await inspectElementAtIndex(0);
+ }
+
+ expect(inspectedElement.props).toMatchInlineSnapshot(`
+ Object {
+ "nestedObject": Object {
+ "a": Dehydrated {
+ "preview_short": {…},
+ "preview_long": {b: {…}, value: 1},
+ },
+ "c": Dehydrated {
+ "preview_short": {…},
+ "preview_long": {d: {…}, value: 1},
+ },
+ },
+ }
+ `);
+
+ await loadPath(['props', 'nestedObject', 'a']);
+
+ expect(inspectedElement.props).toMatchInlineSnapshot(`
+ Object {
+ "nestedObject": Object {
+ "a": Object {
+ "b": Object {
+ "value": 1,
+ },
+ "value": 1,
+ },
+ "c": Dehydrated {
+ "preview_short": {…},
+ "preview_long": {d: {…}, value: 1},
+ },
+ },
+ }
+ `);
+
+ TestRendererAct(() => {
+ TestUtilsAct(() => {
+ ReactDOM.render(
+ ,
+ container,
+ );
+ });
+ });
+
+ await loadPath(['props', 'nestedObject', 'c']);
+
+ expect(inspectedElement.props).toMatchInlineSnapshot(`
+ Object {
+ "nestedObject": Object {
+ "a": Object {
+ "b": Object {
+ "value": 2,
+ },
+ "value": 2,
+ },
+ "c": Object {
+ "d": Object {
+ "e": Dehydrated {
+ "preview_short": {…},
+ "preview_long": {value: 2},
+ },
+ "value": 2,
+ },
+ "value": 2,
+ },
+ },
+ }
+ `);
+
+ done();
+ });
+
it('should not tear if hydration is requested after an update', async done => {
const Example = () => null;
@@ -1936,6 +2073,7 @@ describe('InspectedElement', () => {
,
+ {unstable_isConcurrent: true},
);
}, false);
await utils.actAsync(() => {
diff --git a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
index 6d446ca481de9..5718c782a9aee 100644
--- a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
+++ b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
@@ -26,15 +26,14 @@ describe('InspectedElementContext', () => {
async function read(
id: number,
- inspectedPaths?: Object = {},
+ path?: Array = null,
): Promise