Skip to content
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

fix: Automatically expand first insight #27872

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 3 additions & 41 deletions test/e2e/snaps/test-snap-siginsights.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,15 @@ describe('Test Snap Signature Insights', function () {
tag: 'p',
});

// click down arrow
await driver.waitForSelector({
text: 'Signature Insights Example Snap',
tag: 'span',
});
await driver.clickElement({
text: 'Signature Insights Example Snap',
tag: 'span',
});

// look for returned signature insights data
await driver.waitForSelector({
text: '0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765',
tag: 'p',
});

// Click down arrow
await driver.clickElementSafe('[aria-label="Scroll down"]');

// click sign button
await driver.clickElementAndWaitForWindowToClose(
'[data-testid="confirm-footer-button"]',
Expand Down Expand Up @@ -125,22 +118,11 @@ describe('Test Snap Signature Insights', function () {
});

// click down arrow
// await driver.waitForSelector('[aria-label="Scroll down"]');
await driver.clickElementSafe('[aria-label="Scroll down"]');

// required: delay for scroll to render
await driver.delay(500);

// click down arrow
await driver.waitForSelector({
text: 'Signature Insights Example Snap',
tag: 'span',
});
await driver.clickElement({
text: 'Signature Insights Example Snap',
tag: 'span',
});

// look for returned signature insights data
await driver.waitForSelector({
text: '1',
Expand Down Expand Up @@ -188,16 +170,6 @@ describe('Test Snap Signature Insights', function () {
// required: delay for scroll to render
await driver.delay(500);

// click signature insights
await driver.waitForSelector({
text: 'Signature Insights Example Snap',
tag: 'span',
});
await driver.clickElement({
text: 'Signature Insights Example Snap',
tag: 'span',
});

// look for returned signature insights data
await driver.waitForSelector({
text: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC has been identified as a malicious verifying contract.',
Expand Down Expand Up @@ -245,16 +217,6 @@ describe('Test Snap Signature Insights', function () {
// required: delay for scroll to render
await driver.delay(500);

// click signature insights
await driver.waitForSelector({
text: 'Signature Insights Example Snap',
tag: 'span',
});
await driver.clickElement({
text: 'Signature Insights Example Snap',
tag: 'span',
});

// look for returned signature insights data
await driver.waitForSelector({
text: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC has been identified as a malicious verifying contract.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export type SnapInsightProps = {
snapId: string;
interfaceId: string;
loading: boolean;
isExpanded?: boolean | undefined;
};

export const SnapInsight: React.FunctionComponent<SnapInsightProps> = ({
snapId,
interfaceId,
loading,
isExpanded,
}) => {
const t = useI18nContext();
const { name: snapName } = useSelector((state) =>
Expand Down Expand Up @@ -57,6 +59,7 @@ export const SnapInsight: React.FunctionComponent<SnapInsightProps> = ({
<Delineator
headerComponent={headerComponent}
isLoading={loading}
isExpanded={isExpanded}
contentBoxProps={
loading
? undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import { Text } from '@metamask/snaps-sdk/jsx';
import { fireEvent } from '@testing-library/react';

import {
getMockPersonalSignConfirmState,
Expand Down Expand Up @@ -58,8 +57,6 @@ describe('SnapsSection', () => {
mockStore,
);

fireEvent.click(getByText('Insights from'));

expect(container).toMatchSnapshot();
expect(getByText('Hello world!')).toBeDefined();
});
Expand All @@ -79,8 +76,6 @@ describe('SnapsSection', () => {
mockStore,
);

fireEvent.click(getByText('Insights from'));

expect(container).toMatchSnapshot();
expect(getByText('Hello world again!')).toBeDefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ export const SnapsSection = () => {
gap={4}
marginBottom={4}
>
{data.map(({ snapId, interfaceId, loading }) => (
{data.map(({ snapId, interfaceId, loading }, index) => (
<SnapInsight
key={snapId}
snapId={snapId}
interfaceId={interfaceId}
loading={loading}
isExpanded={index === 0}
/>
))}
</Box>
Expand Down