Skip to content

Commit

Permalink
New Console: Maps support complex keys (#7598)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Aug 23, 2022
1 parent 0599093 commit 5de15c6
Show file tree
Hide file tree
Showing 53 changed files with 47 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ValueRenderer from "../ValueRenderer";

import styles from "./shared.module.css";
import { ObjectPreviewRendererProps } from "./types";
import KeyValueRenderer from "../KeyValueRenderer";

const MAX_PROPERTIES_TO_PREVIEW = 5;

Expand All @@ -25,37 +26,26 @@ export default function MapRenderer({ object, pauseId }: ObjectPreviewRendererPr
} else {
let propertiesList: ReactNode[] | null = null;
if (!isWithinPreview) {
propertiesList = slice.map(({ key, value }, index) => {
let keyToDisplay = "";
if (key != null && key.hasOwnProperty("value") != null) {
switch (key.value) {
case false:
keyToDisplay = "false";
break;
case null:
keyToDisplay = "null";
break;
case undefined:
keyToDisplay = "undefined";
break;
default:
keyToDisplay = key.value;
break;
}
}
return (
<span key={index} className={styles.Value}>
{keyToDisplay !== "" && (
<>
<span className={styles.MapKey}>{keyToDisplay}</span>
<span className={styles.Separator}></span>
</>
)}
<ValueRenderer isNested={true} pauseId={pauseId} protocolValue={value} />
{index < slice.length - 1 && <span className={styles.Separator}>, </span>}
</span>
);
});
propertiesList = slice.map(({ key, value }, index) => (
<span key={index} className={styles.Value}>
{key != null && (
<>
<span className={styles.MapKey}>
<KeyValueRenderer
enableInspection={false}
isNested={true}
layout="horizontal"
pauseId={pauseId}
protocolValue={key}
/>
</span>
<span className={styles.Separator}></span>
</>
)}
<ValueRenderer isNested={true} pauseId={pauseId} protocolValue={value} />
{index < slice.length - 1 && <span className={styles.Separator}>, </span>}
</span>
));

if (showOverflowMarker) {
propertiesList.push(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
[false, "false"],
[0, "zero"],
]);
const mapWithComplexKeys = new Map([
[{ foo: "bar" }, "object"],
[[1, 2, 3], "array"],
[new Set([1, 2, 3]), "Set"],
[
new Map([
["one", 123],
["two", true],
]),
"map",
],
]);
const weakMap = new WeakMap([
[regex, "abc"],
[map, 123],
Expand Down Expand Up @@ -267,6 +279,7 @@
weakMap,
overflowingMap,
mapWithFalsyKeys,
mapWithComplexKeys,
emptySet,
simpleSet: set,
weakSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = {
use: {
browserName: "chromium",
launchOptions: {
slowMo: process.env.VISUAL_DEBUG ? 500 : 5,
slowMo: process.env.VISUAL_DEBUG ? 500 : 50,
},
trace: "on-first-retry",
video: process.env.RECORD_VIDEO ? "on" : "off",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ testSetup(async function regeneratorFunction({ page }) {
"mapWithFalsyKeys",
"render-and-inspect-map-with-falsy-keys"
);
await inspectAndTakeScreenshotOf(
page,
"mapWithComplexKeys",
"render-and-inspect-map-with-complex-keys"
);
});

test("should render simple values", async ({ page }) => {
Expand Down Expand Up @@ -135,6 +140,11 @@ test("should render and inspect maps", async ({ page }) => {
"mapWithFalsyKeys",
"render-and-inspect-map-with-falsy-keys"
);
await inspectAndTakeScreenshotOf(
page,
"mapWithComplexKeys",
"render-and-inspect-map-with-complex-keys"
);
});

test("should render and inspect regular expressions", async ({ page }) => {
Expand Down

1 comment on commit 5de15c6

@vercel
Copy link

@vercel vercel bot commented on 5de15c6 Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

devtools – ./

devtools-git-main-recordreplay.vercel.app
devtools-recordreplay.vercel.app
app.replay.io

Please sign in to comment.