Skip to content

Commit

Permalink
Use peerInfo.senderId instead of peerInfo.name to avoid key duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
asiia-trilitech committed Mar 12, 2024
1 parent 111dc16 commit ced9c34
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/utils/beacon/BeaconPeers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,34 @@ describe("<BeaconPeers />", () => {
}
});

it("resolves duplicating name for different peer connections", async () => {
jest.spyOn(beaconHelper, "usePeers").mockReturnValue({
data: [
{
name: "dApp",
publicKey: "e15835f5b7bb7fae5a3ddbe3c71b3cdd9ee0a5ea2586f04e7669e9040f61810c",
senderId: "2MqUhvyAJy3UY",
type: "p2p-pairing-request",
id: "test-id-1",
version: "v1",
},
{
name: "dApp",
publicKey: "e15835f5b7bb7fae5a3ddbe3c71b3cdd9ee0a5ea2586f04e7669e9040f61810b",
senderId: "2UJwaEUy23W3g",
type: "p2p-pairing-request",
id: "test-id-2",
version: "v1.5",
},
],
} as any);

render(<BeaconPeers />);

const rows = await screen.findAllByTestId("peer-row");
expect(rows).toHaveLength(2);
});

describe("for saved connections", () => {
it("displays address pill with acc label if connected acc is present", async () => {
store.dispatch(
Expand Down
2 changes: 1 addition & 1 deletion src/utils/beacon/BeaconPeers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const PeersDisplay = ({
}) => (
<Box>
{peerInfos.map(peerInfo => (
<Fragment key={peerInfo.name}>
<Fragment key={peerInfo.senderId}>
<Divider />
<PeerRow onRemove={() => removePeer(peerInfo)} peerInfo={peerInfo} />
</Fragment>
Expand Down

1 comment on commit ced9c34

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 84.53% 2940/3478
🟡 Branches 78.07% 993/1272
🟢 Functions 82.39% 898/1090
🟢 Lines 84.29% 2779/3297

Test suite run success

1183 tests passing in 162 suites.

Report generated by 🧪jest coverage report action from ced9c34

Please sign in to comment.