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

test: Adding e2e for SIWE and re-enabling redesign for SIWE #25831

Merged
merged 12 commits into from
Jul 22, 2024

Conversation

pnarayanaswamy
Copy link
Contributor

@pnarayanaswamy pnarayanaswamy commented Jul 15, 2024

Description

Open in GitHub Codespaces

Related issues

Fixes: #24679

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@pnarayanaswamy pnarayanaswamy requested a review from a team as a code owner July 15, 2024 12:01
@pnarayanaswamy pnarayanaswamy added the team-confirmations Push issues to confirmations team label Jul 15, 2024
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link
Contributor

@pedronfigueiredo pedronfigueiredo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

Looking good! One thing is that I'm not sure if this checks that it presents a Sign-in With Ethereum UI rather than a personal sign UI. To do this we could check the "Signing in with" row exists

another thing that might be good to check here is that domain binding (Domain alert) displays. We should be able to trigger this clicking on the "Bad Account" button. This is unique to SIWE and does not exist for personal sign

jpuri
jpuri previously approved these changes Jul 15, 2024
@digiwand
Copy link
Contributor

p.s. adding more tests for SIWE could be done in a future PR and does not block this PR

there are also lint errors here. This oftentimes can be fixed using 'yarn lint:fix'
CleanShot 2024-07-15 at 18 54 10@2x

@pnarayanaswamy pnarayanaswamy dismissed stale reviews from pedronfigueiredo and jpuri via 9199ebe July 16, 2024 12:47
@pnarayanaswamy
Copy link
Contributor Author

pnarayanaswamy commented Jul 16, 2024

Looking good! One thing is that I'm not sure if this checks that it presents a Sign-in With Ethereum UI rather than a personal sign UI. To do this we could check the "Signing in with" row exists

another thing that might be good to check here is that domain binding (Domain alert) displays. We should be able to trigger this clicking on the "Bad Account" button. This is unique to SIWE and does not exist for personal sign

Added a test for bad domain @digiwand

@metamaskbot
Copy link
Collaborator

Builds ready [a12218b]
Page Load Metrics (178 ± 224 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint641481072210
domContentLoaded106127157
load482206178466224
domInteractive96127157
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [e3cb93b]
Page Load Metrics (263 ± 265 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint842091173115
domContentLoaded105728115
load591965263552265
domInteractive105728115
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.66%. Comparing base (5540fdf) to head (b603beb).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25831      +/-   ##
===========================================
- Coverage    69.66%   69.66%   -0.00%     
===========================================
  Files         1402     1402              
  Lines        49659    49656       -3     
  Branches     13722    13719       -3     
===========================================
- Hits         34594    34591       -3     
  Misses       15065    15065              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pnarayanaswamy pnarayanaswamy requested a review from a team as a code owner July 22, 2024 15:18
@pnarayanaswamy pnarayanaswamy changed the title test: Adding e2e for SIWE test: Adding e2e for SIWE and re-enabling redesign for SIWE Jul 22, 2024
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

Nice!

side note: aside from verifying the domain binding which is unique to SIWE and not personal-sign, we check the "Signing in with" row is displayed in the unit test
ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.test.tsx

Copy link

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request introduces end-to-end tests for the Sign-In with Ethereum (SIWE) feature and re-enables the redesigned confirmation UI for SIWE messages.

  • New E2E Tests: Added test/e2e/tests/confirmations/signatures/siwe.spec.ts to cover SIWE request scenarios.
  • Updated Hook Tests: Modified ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts to expect specific object structures for SIWE messages.
  • Hook Logic Simplification: Simplified ui/pages/confirmations/hooks/useCurrentConfirmation.ts by removing the isSIWE check from the shouldUseRedesign condition.
  • Potential Pitfalls: Ensure all mocked endpoints and fixtures are correctly set up to avoid false positives/negatives in tests.

3 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings

@@ -0,0 +1,161 @@
import { strict as assert } from 'assert';
Copy link

Choose a reason for hiding this comment

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

Info: Imported necessary modules and helper functions for the tests.

assertAccountDetailsMetrics,
} from './signature-helpers';

describe('Confirmation Signature - SIWE @no-mmi', function (this: Suite) {
Copy link

Choose a reason for hiding this comment

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

Info: Test for initiating and confirming a SIWE request.

);
});

it('initiates and rejects', async function () {
Copy link

Choose a reason for hiding this comment

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

Info: Test for initiating and rejecting a SIWE request.

);
});

it('displays alert for domain binding and confirms', async function () {
Copy link

Choose a reason for hiding this comment

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

Info: Test for handling domain mismatch alerts and confirming a SIWE request.

Comment on lines +145 to +153
async function assertInfoValues(driver: Driver) {
const origin = driver.findElement({ text: DAPP_HOST_ADDRESS });
const message = driver.findElement({
text: 'I accept the MetaMask Terms of Service: https://community.metamask.io/tos',
});

assert.ok(await origin);
assert.ok(await message);
}
Copy link

Choose a reason for hiding this comment

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

Info: Helper function to assert information values in the SIWE request.

Comment on lines +155 to +161
async function assertVerifiedSiweMessage(driver: Driver, message: string) {
await driver.waitUntilXWindowHandles(2);
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);

const verifySigUtil = await driver.findElement('#siweResult');
assert.equal(await verifySigUtil.getText(), message);
}
Copy link

Choose a reason for hiding this comment

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

Info: Helper function to assert the verified SIWE message.

@@ -204,7 +204,7 @@ describe('useCurrentConfirmation', () => {
expect(currentConfirmation).toBeUndefined();
});

it('returns undefined if message is SIWE', () => {
it('returns if message is SIWE', () => {
Copy link

Choose a reason for hiding this comment

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

Info: Updated test description to reflect the new expected behavior for SIWE messages.

Comment on lines +217 to +220
expect(currentConfirmation).toStrictEqual({
id: APPROVAL_MOCK.id,
msgParams: { siwe: { isSIWEMessage: true } },
});
Copy link

Choose a reason for hiding this comment

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

Info: Updated expectation to check for the correct structure of the returned SIWE message.

Comment on lines 68 to +70
const shouldUseRedesign =
isRedesignedConfirmationsUserSettingEnabled &&
(isCorrectApprovalType || isCorrectTransactionType) &&
!isSIWE;
(isCorrectApprovalType || isCorrectTransactionType);
Copy link

Choose a reason for hiding this comment

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

Info: Removed isSIWE check from shouldUseRedesign condition.

@metamaskbot
Copy link
Collaborator

Builds ready [b603beb]
Page Load Metrics (278 ± 292 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint732071123115
domContentLoaded95830168
load442205278608292
domInteractive95829168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: -330 Bytes (-0.00%)
  • common: 0 Bytes (0.00%)

@pnarayanaswamy pnarayanaswamy merged commit edb401a into develop Jul 22, 2024
77 checks passed
@pnarayanaswamy pnarayanaswamy deleted the siwe-e2e branch July 22, 2024 18:26
@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[e2e] Signature redesign - create Permit and SIWE Signature tests
5 participants