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: add coverage for Security Alerts API fallback (PPOM local) #28565

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Nov 20, 2024

Description

This PR enhances test coverage for the Security Alerts API by reusing the existing PPOM end-to-end (E2E) tests to validate the fallback mechanism. It also introduces a new equivalent E2E test in a dedicated folder to cover the API.

Key Changes

  • Reused and adapted existing PPOM E2E tests to validate the fallback mechanism.
  • Added a new E2E test to cover the API.

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3656

Manual testing steps

  1. pipeline

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.

@vinistevam vinistevam added the team-confirmations Push issues to confirmations team label Nov 20, 2024
@vinistevam vinistevam requested a review from a team as a code owner November 20, 2024 14:22
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.

@metamaskbot
Copy link
Collaborator

Builds ready [d70034a]
Page Load Metrics (1754 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29720031547519249
domContentLoaded1499192017268842
load1507199917549948
domInteractive12169533718
backgroundConnect978322010
firstReactRender48145942210
getState44511126
initialActions00000
loadScripts1072142512837436
setupStore65013147
uiStartup16502228193811053
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@@ -48,7 +50,7 @@ async function mockInfuraWithMaliciousResponses(mockServer) {

describe('PPOM Blockaid Alert - Multiple Networks Support @no-mmi', function () {
// eslint-disable-next-line mocha/no-skipped-tests
it.skip('should show banner alert after switchinig to another supported network', async function () {
it.skip('should show banner alert after switching to another supported network', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe reenable this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here.

@metamaskbot
Copy link
Collaborator

Builds ready [06c5c9c]
Page Load Metrics (1854 ± 93 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16232320185418790
domContentLoaded15972199181016680
load16282353185419393
domInteractive23184463617
backgroundConnect10188483818
firstReactRender562891094622
getState582272412
initialActions0442105
loadScripts11611789134516077
setupStore55511105
uiStartup183026492079232111
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [5d6baf0]
Page Load Metrics (2506 ± 133 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26530782165825396
domContentLoaded211329722471271130
load212829842506278133
domInteractive22119592412
backgroundConnect13105463014
firstReactRender963241464924
getState699322613
initialActions01000
loadScripts154622571858222107
setupStore784222210
uiStartup237533442819335161
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@vinistevam vinistevam force-pushed the test/add-coverage-fallback-tests-security-alerts-api branch from ff4de5b to 5c57a03 Compare November 27, 2024 15:21
@metamaskbot
Copy link
Collaborator

Builds ready [5c57a03]
Page Load Metrics (1537 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14131858154210450
domContentLoaded1393177115099747
load14131859153710550
domInteractive237236178
backgroundConnect1087252010
firstReactRender157427199
getState44411115
initialActions01000
loadScripts1017128211127335
setupStore65218189
uiStartup15802179171813263
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@vinistevam vinistevam requested a review from a team as a code owner December 4, 2024 13:25
@metamaskbot
Copy link
Collaborator

Builds ready [2698c02]
Page Load Metrics (1815 ± 91 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30222941689478229
domContentLoaded15192122177517584
load15392165181519091
domInteractive236538147
backgroundConnect7184414019
firstReactRender1497363115
getState8854319011957
initialActions01000
loadScripts10991648134315575
setupStore6211052
uiStartup177530892201351169
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [5f18b49]
Page Load Metrics (2176 ± 105 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint36525752081450216
domContentLoaded184625502147221106
load186425792176220105
domInteractive26111442010
backgroundConnect116432189
firstReactRender169925178
getState862941504019
initialActions00000
loadScripts13641997165419493
setupStore67813157
uiStartup211735542544339163
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)


async ({ driver }) => {
await unlockWallet(driver);
await openDapp(driver);
Copy link
Member

@matthewwalsh0 matthewwalsh0 Dec 12, 2024

Choose a reason for hiding this comment

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

If we're adding new E2E tests, should we be using page object models or creating new ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've changed the new tests to use the page object model approach.

await mockRequest(mockServer, maliciousTradeAlert);
}

describe('Security Alerts API - Set Trade farming order @no-mmi', function () {
Copy link
Member

@matthewwalsh0 matthewwalsh0 Dec 12, 2024

Choose a reason for hiding this comment

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

As many of these files have a single test in, would it be simpler to keep them in a single file to reduce the boilerplate overhead?

The duplication and final line count should be minimal if we rely on page object models to abstract the interactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've aggregated the new tests to reduce the number of files and boilerplate.

@metamaskbot
Copy link
Collaborator

Builds ready [4db2f73]
Page Load Metrics (1622 ± 58 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14141886162012158
domContentLoaded14061864160212359
load14151887162212158
domInteractive249844199
backgroundConnect75928188
firstReactRender1687482512
getState56811136
initialActions01000
loadScripts10421435120210148
setupStore648994
uiStartup16102188187816780
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@dbrans dbrans removed the request for review from a team December 12, 2024 16:59
@vinistevam vinistevam force-pushed the test/add-coverage-fallback-tests-security-alerts-api branch from 45eb8c3 to 4aaaa8b Compare January 7, 2025 11:42
@metamaskbot
Copy link
Collaborator

Builds ready [368489a]
Page Load Metrics (1841 ± 83 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15842353184217383
domContentLoaded15732298181117685
load15882355184117383
domInteractive268244178
backgroundConnect1185312210
firstReactRender1699493215
getState693262713
initialActions01000
loadScripts11781841135315273
setupStore76316178
uiStartup188426822206285137

],
})
.thenJson(201, response);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be possible to create a common function to avoid code repetition with method mockRequest .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, added here.


async function mockRequest(server, response) {
await server
.forPost(`${SECURITY_ALERTS_PROD_API_BASE_URL}/validate/0x1`)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we already have these tests implemented for security alerts api also.

jpuri
jpuri previously approved these changes Jan 8, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [49b8d41]
Page Load Metrics (1713 ± 134 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint143727311710278134
domContentLoaded142627211686282135
load143827321713279134
domInteractive24325626833
backgroundConnect1076302110
firstReactRender1697482512
getState5431184
initialActions01000
loadScripts105322501278259124
setupStore65917189
uiStartup166029121946283136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [e9b1657]
Page Load Metrics (1832 ± 130 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint157728491837273131
domContentLoaded151528121805269129
load156828461832271130
domInteractive2787492010
backgroundConnect970302210
firstReactRender1680412512
getState568192010
initialActions01000
loadScripts111623661356261126
setupStore65513126
uiStartup173731022075277133
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

OGPoyraz
OGPoyraz previously approved these changes Jan 15, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [53ce817]
Page Load Metrics (1817 ± 70 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34720671740350168
domContentLoaded15842046178714469
load16172066181714670
domInteractive22112412211
backgroundConnect56827189
firstReactRender16108492914
getState56622199
initialActions01000
loadScripts11501523133511856
setupStore6481094
uiStartup184727982129241116
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants