From dba74efa89bb533a16f9a1619408e35c255ba4d9 Mon Sep 17 00:00:00 2001
From: Pedro Figueiredo
Date: Fri, 6 Sep 2024 14:29:50 +0100
Subject: [PATCH] Update revoke flow logic
---
.../erc20-approve-redesign.spec.ts | 26 ++------
.../increase-token-allowance-redesign.spec.ts | 59 ++-----------------
.../__snapshots__/approve.test.tsx.snap | 4 +-
.../confirm/info/approve/approve.test.tsx | 13 ++--
.../confirm/info/approve/approve.tsx | 28 ++++++---
.../info/approve/spending-cap-context.tsx | 33 -----------
.../components/confirm/title/title.test.tsx | 41 +++++++------
.../components/confirm/title/title.tsx | 25 +++++++-
ui/pages/confirmations/confirm/confirm.tsx | 45 +++++++-------
9 files changed, 108 insertions(+), 166 deletions(-)
delete mode 100644 ui/pages/confirmations/components/confirm/info/approve/spending-cap-context.tsx
diff --git a/test/e2e/tests/confirmations/transactions/erc20-approve-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/erc20-approve-redesign.spec.ts
index e07fb26955ba..baa3638330b6 100644
--- a/test/e2e/tests/confirmations/transactions/erc20-approve-redesign.spec.ts
+++ b/test/e2e/tests/confirmations/transactions/erc20-approve-redesign.spec.ts
@@ -1,11 +1,6 @@
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
import { MockttpServer } from 'mockttp';
-import {
- getEventPayloads,
- tinyDelayMs,
- veryLargeDelayMs,
- WINDOW_TITLES,
-} from '../../../helpers';
+import { tinyDelayMs, veryLargeDelayMs, WINDOW_TITLES } from '../../../helpers';
import { Driver } from '../../../webdriver/driver';
import { scrollAndConfirmAndAssertConfirm } from '../helpers';
import {
@@ -13,7 +8,6 @@ import {
TestSuiteArguments,
toggleAdvancedDetails,
} from './shared';
-import { MockedEndpoint } from '../../../mock-e2e';
const {
defaultGanacheOptions,
@@ -26,8 +20,8 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts');
describe('Confirmation Redesign ERC20 Approve Component', function () {
const smartContract = SMART_CONTRACTS.HST;
- describe.only('Submit an Approve transaction @no-mmi', function () {
- it.only('Sends a type 0 transaction (Legacy)', async function () {
+ describe('Submit an Approve transaction @no-mmi', function () {
+ it('Sends a type 0 transaction (Legacy)', async function () {
await withFixtures(
{
dapp: true,
@@ -45,24 +39,13 @@ describe('Confirmation Redesign ERC20 Approve Component', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
- async ({
- driver,
- contractRegistry,
- mockedEndpoint: mockedEndpoints,
- }: TestSuiteArguments) => {
+ async ({ driver, contractRegistry }: TestSuiteArguments) => {
await openDAppWithContract(driver, contractRegistry, smartContract);
await importTST(driver);
await createERC20ApproveTransaction(driver);
- const events = await getEventPayloads(
- driver,
- mockedEndpoints as MockedEndpoint[],
- );
-
- console.log('here '.repeat(42), { mockedEndpoints, events });
-
await assertApproveDetails(driver);
await confirmApproveTransaction(driver);
@@ -107,6 +90,7 @@ describe('Confirmation Redesign ERC20 Approve Component', function () {
export async function mocked4BytesApprove(mockServer: MockttpServer) {
return await mockServer
.forGet('https://www.4byte.directory/api/v1/signatures/')
+ .always()
.withQuery({ hex_signature: '0x095ea7b3' })
.thenCallback(() => ({
statusCode: 200,
diff --git a/test/e2e/tests/confirmations/transactions/increase-token-allowance-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/increase-token-allowance-redesign.spec.ts
index cd4c08a83297..3c1d695c3534 100644
--- a/test/e2e/tests/confirmations/transactions/increase-token-allowance-redesign.spec.ts
+++ b/test/e2e/tests/confirmations/transactions/increase-token-allowance-redesign.spec.ts
@@ -1,16 +1,13 @@
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
import {
- getEventPayloads,
largeDelayMs,
veryLargeDelayMs,
WINDOW_TITLES,
} from '../../../helpers';
-import { MockedEndpoint, Mockttp } from '../../../mock-e2e';
+import { Mockttp } from '../../../mock-e2e';
import { Driver } from '../../../webdriver/driver';
import { scrollAndConfirmAndAssertConfirm } from '../helpers';
import { openDAppWithContract, TestSuiteArguments } from './shared';
-import { mocked4BytesApprove } from './erc20-approve-redesign.spec';
-import { MockedEndpoint } from '../../../mock-e2e';
const {
defaultGanacheOptions,
@@ -42,22 +39,11 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
- async ({
- driver,
- contractRegistry,
- mockedEndpoint: mockedEndpoints,
- }: TestSuiteArguments) => {
+ async ({ driver, contractRegistry }: TestSuiteArguments) => {
await openDAppWithContract(driver, contractRegistry, smartContract);
await createERC20IncreaseAllowanceTransaction(driver);
- const events = await getEventPayloads(
- driver,
- mockedEndpoints as MockedEndpoint[],
- );
-
- console.log('here '.repeat(42), { mockedEndpoints, events });
-
const NEW_SPENDING_CAP = '3';
await editSpendingCap(driver, NEW_SPENDING_CAP);
@@ -86,22 +72,11 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
- async ({
- driver,
- contractRegistry,
- mockedEndpoint: mockedEndpoints,
- }: TestSuiteArguments) => {
+ async ({ driver, contractRegistry }: TestSuiteArguments) => {
await openDAppWithContract(driver, contractRegistry, smartContract);
await createERC20IncreaseAllowanceTransaction(driver);
- const events = await getEventPayloads(
- driver,
- mockedEndpoints as MockedEndpoint[],
- );
-
- console.log('here '.repeat(42), { mockedEndpoints, events });
-
const NEW_SPENDING_CAP = '3';
await editSpendingCap(driver, NEW_SPENDING_CAP);
@@ -130,22 +105,11 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
- async ({
- driver,
- contractRegistry,
- mockedEndpoint: mockedEndpoints,
- }: TestSuiteArguments) => {
+ async ({ driver, contractRegistry }: TestSuiteArguments) => {
await openDAppWithContract(driver, contractRegistry, smartContract);
await createERC20IncreaseAllowanceTransaction(driver);
- const events = await getEventPayloads(
- driver,
- mockedEndpoints as MockedEndpoint[],
- );
-
- console.log('here '.repeat(42), { mockedEndpoints, events });
-
const NEW_SPENDING_CAP = '3000';
await editSpendingCap(driver, NEW_SPENDING_CAP);
@@ -174,22 +138,11 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
- async ({
- driver,
- contractRegistry,
- mockedEndpoint: mockedEndpoints,
- }: TestSuiteArguments) => {
+ async ({ driver, contractRegistry }: TestSuiteArguments) => {
await openDAppWithContract(driver, contractRegistry, smartContract);
await createERC20IncreaseAllowanceTransaction(driver);
- const events = await getEventPayloads(
- driver,
- mockedEndpoints as MockedEndpoint[],
- );
-
- console.log('here '.repeat(42), { mockedEndpoints, events });
-
const NEW_SPENDING_CAP = '3000';
await editSpendingCap(driver, NEW_SPENDING_CAP);
@@ -238,7 +191,7 @@ async function createERC20IncreaseAllowanceTransaction(driver: Driver) {
await driver.clickElement('#increaseTokenAllowance');
}
-async function editSpendingCap(driver: Driver, newSpendingCap: string) {
+export async function editSpendingCap(driver: Driver, newSpendingCap: string) {
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.clickElement('[data-testid="edit-spending-cap-icon"');
diff --git a/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
index 72b494a67553..ebc8cf316a43 100644
--- a/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
+++ b/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
@@ -74,7 +74,7 @@ exports[` renders component for approve request 1`] = `
class="mm-box mm-text mm-text--body-md mm-text--text-align-center mm-box--padding-inline-2 mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-xl"
data-testid="simulation-token-value"
>
- 0
+ 1000
@@ -385,7 +385,7 @@ exports[`
renders component for approve request 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--color-inherit"
style="white-space: pre-wrap;"
>
- 0
+ 1000