Skip to content

Commit

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

console.log(JSON.stringify(mockedRequests));

return (
await Promise.all(
mockedRequests.map(async (req) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,6 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts');
describe('Confirmation Redesign ERC20 Increase Allowance', function () {
const smartContract = SMART_CONTRACTS.HST;

async function mocks(server: Mockttp) {
return [await mocked4BytesIncreaseAllowance(server)];
}

async function mocked4BytesIncreaseAllowance(mockServer: Mockttp) {
return await mockServer
.forGet('https://www.4byte.directory/api/v1/signatures/')
.always()
.withQuery({ hex_signature: '0x39509351' })
.thenCallback(() => {
return {
statusCode: 200,
json: {
count: 1,
next: null,
previous: null,
results: [
{
id: 46002,
created_at: '2018-06-24T21:43:27.354648Z',
text_signature: 'increaseAllowance(address,uint256)',
hex_signature: '0x39509351',
bytes_signature: '9P“Q',
test: 'Priya',
},
],
},
};
});
}

describe('Submit an increase allowance transaction @no-mmi', function () {
it('Sends a type 0 transaction (Legacy) with a small spending cap', async function () {
await withFixtures(
Expand All @@ -71,32 +40,17 @@ 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[],
false,
);

console.log('here '.repeat(42), { mockedEndpoints, events });
await driver.delay(5000);

const NEW_SPENDING_CAP = '3';
await editSpendingCap(driver, NEW_SPENDING_CAP);

await scrollAndConfirmAndAssertConfirm(driver);

await assertChangedSpendingCap(driver, NEW_SPENDING_CAP);

await driver.delay(5000);
},
);
});
Expand Down Expand Up @@ -200,6 +154,37 @@ describe('Confirmation Redesign ERC20 Increase Allowance', function () {
);
});
});

async function mocks(server: Mockttp) {
return [await mocked4BytesIncreaseAllowance(server)];
}

async function mocked4BytesIncreaseAllowance(mockServer: Mockttp) {
return await mockServer
.forGet('https://www.4byte.directory/api/v1/signatures/')
.always()
.withQuery({ hex_signature: '0x39509351' })
.thenCallback(() => {
return {
statusCode: 200,
json: {
count: 1,
next: null,
previous: null,
results: [
{
id: 46002,
created_at: '2018-06-24T21:43:27.354648Z',
text_signature: 'increaseAllowance(address,uint256)',
hex_signature: '0x39509351',
bytes_signature: '9P“Q',
test: 'Priya',
},
],
},
};
});
}
});

async function createERC20IncreaseAllowanceTransaction(driver: Driver) {
Expand All @@ -209,9 +194,6 @@ async function createERC20IncreaseAllowanceTransaction(driver: Driver) {

async function editSpendingCap(driver: Driver, newSpendingCap: string) {
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.takeScreenshot('spendingCapDialog-before-wait');
await driver.delay(10000);
await driver.takeScreenshot('spendingCapDialog-after-wait');
await driver.clickElement('[data-testid="edit-spending-cap-icon"');

await driver.fill(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,11 @@ describe('<EditSpendingCapModal />', () => {
const isOpenEditSpendingCapModal = true;
const setIsOpenEditSpendingCapModal = () =>
console.log('setIsOpenEditSpendingCapModal');
const customSpendingCap = '10';
const setCustomSpendingCap = () => console.log('setCustomSpendingCap');

const { container } = renderWithConfirmContextProvider(
<EditSpendingCapModal
isOpenEditSpendingCapModal={isOpenEditSpendingCapModal}
setIsOpenEditSpendingCapModal={setIsOpenEditSpendingCapModal}
customSpendingCap={customSpendingCap}
setCustomSpendingCap={setCustomSpendingCap}
/>,
mockStore,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports[`<SpendingCap /> renders component 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--color-inherit"
style="white-space: pre-wrap;"
>
10
1000
</p>
<button
aria-label="Edit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ describe('<SpendingCap />', () => {

const setIsOpenEditSpendingCapModal = () =>
console.log('setIsOpenEditSpendingCapModal');
const customSpendingCap = '10';

const { container } = renderWithConfirmContextProvider(
<SpendingCap
setIsOpenEditSpendingCapModal={setIsOpenEditSpendingCapModal}
customSpendingCap={customSpendingCap}
/>,

mockStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export const SpendingCap = ({
decimals || '0',
);

console.log({ transactionMeta, decodedSpendingCap: spendingCap });

if (pending) {
return <Container isLoading />;
}
Expand Down

0 comments on commit 7fe33dd

Please sign in to comment.