Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Sep 5, 2024
1 parent 2c95417 commit ec9c7ad
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 9 deletions.
6 changes: 6 additions & 0 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,12 @@ async function getEventPayloads(driver, mockedEndpoints, hasRequest = true) {
mockedRequests.push(...(await mockedEndpoint.getSeenRequests()));
}

console.log({
mockedRequests,
body: mockedRequests[0].body,
getJson: mockedRequests[0].getJson,
});

return (
await Promise.all(
mockedRequests.map(async (req) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
import { MockttpServer } from 'mockttp';
import { tinyDelayMs, veryLargeDelayMs, WINDOW_TITLES } from '../../../helpers';
import {
getEventPayloads,
tinyDelayMs,
veryLargeDelayMs,
WINDOW_TITLES,
} from '../../../helpers';
import { Driver } from '../../../webdriver/driver';
import { scrollAndConfirmAndAssertConfirm } from '../helpers';
import {
openDAppWithContract,
TestSuiteArguments,
toggleAdvancedDetails,
} from './shared';
import { MockedEndpoint } from '../../../mock-e2e';

const {
defaultGanacheOptions,
Expand All @@ -20,8 +26,8 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts');
describe('Confirmation Redesign ERC20 Approve Component', function () {
const smartContract = SMART_CONTRACTS.HST;

describe('Submit an Approve transaction @no-mmi', function () {
it('Sends a type 0 transaction (Legacy)', async function () {
describe.only('Submit an Approve transaction @no-mmi', function () {
it.only('Sends a type 0 transaction (Legacy)', async function () {
await withFixtures(
{
dapp: true,
Expand All @@ -39,13 +45,24 @@ describe('Confirmation Redesign ERC20 Approve Component', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
async ({ driver, contractRegistry }: TestSuiteArguments) => {
async ({
driver,
contractRegistry,
mockedEndpoint: mockedEndpoints,
}: 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
import { MockttpServer } from 'mockttp';
import {
getEventPayloads,
largeDelayMs,
veryLargeDelayMs,
WINDOW_TITLES,
Expand All @@ -9,6 +10,7 @@ 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,
Expand Down Expand Up @@ -40,11 +42,22 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
async ({ driver, contractRegistry }: TestSuiteArguments) => {
async ({
driver,
contractRegistry,
mockedEndpoint: mockedEndpoints,
}: 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);

Expand Down Expand Up @@ -73,11 +86,22 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
async ({ driver, contractRegistry }: TestSuiteArguments) => {
async ({
driver,
contractRegistry,
mockedEndpoint: mockedEndpoints,
}: 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);

Expand Down Expand Up @@ -106,11 +130,22 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
async ({ driver, contractRegistry }: TestSuiteArguments) => {
async ({
driver,
contractRegistry,
mockedEndpoint: mockedEndpoints,
}: 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);

Expand Down Expand Up @@ -139,11 +174,22 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
testSpecificMock: mocks,
title: this.test?.fullTitle(),
},
async ({ driver, contractRegistry }: TestSuiteArguments) => {
async ({
driver,
contractRegistry,
mockedEndpoint: mockedEndpoints,
}: 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);

Expand All @@ -159,7 +205,8 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
export async function mocked4BytesIncreaseAllowance(mockServer: MockttpServer) {
return await mockServer
.forGet('https://www.4byte.directory/api/v1/signatures/')
.withQuery({ hex_signature: '0x39509351' })
.withExactQuery('?hex_signature=0x39509351')
.always()
.thenCallback(() => ({
statusCode: 200,
json: {
Expand Down

0 comments on commit ec9c7ad

Please sign in to comment.