Skip to content

Commit

Permalink
Merge pull request #618 from OasisDEX/daily-improvements-11-nov-3
Browse files Browse the repository at this point in the history
Daily improvements - 11 November
  • Loading branch information
juan-langa authored Nov 11, 2024
2 parents 943cda8 + 3824de3 commit 815f69d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 60 deletions.
14 changes: 14 additions & 0 deletions src/pages/position/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ export class Setup {
});
}

@step
async shouldHaveSpinningIconInButton(label: string) {
await expect(this.page.getByRole('button', { name: label }).locator('svg')).toBeVisible({
timeout: expectDefaultTimeout * 3,
});
}

@step
async shouldNotHaveSpinningIconInButton(label: string) {
await expect(this.page.getByRole('button', { name: label }).locator('svg')).not.toBeVisible({
timeout: expectDefaultTimeout * 3,
});
}

@step
async waitForComponentToBeStable() {
await expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
test.setTimeout(extremelyLongTestTimeout);

app = new App(page);
({ forkId } = await setup({ metamask, app, network: 'optimism' }));
({ forkId, walletAddress } = await setup({ metamask, app, network: 'optimism' }));
});

test.afterEach(async () => {
Expand All @@ -31,7 +31,7 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
}) => {
test.setTimeout(extremelyLongTestTimeout);

await app.page.goto('/optimism/aave/v3/multiply/eth-usdc');
await app.page.goto('/optimism/aave/v3/multiply/eth-usdc#setup');

await test.step('It should Open a position', async () => {
await app.page.waitForTimeout(1_000);
Expand Down
58 changes: 30 additions & 28 deletions tests/withWallet/ajna/base/ajnaEarnBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,27 @@ const test = testWithSynpress(metaMaskFixtures(baseSetup));
const { expect } = test;

test.describe('Ajna Base Earn - Wallet connected', async () => {
test.afterEach(async () => {
await app.page.close();
test.beforeEach(async ({ metamask, page }) => {
app = new App(page);
({ forkId, walletAddress } = await setup({ metamask, app, network: 'base' }));

await tenderly.setTokenBalance({
forkId,
network: 'base',
walletAddress,
token: 'USDC',
balance: '50000',
});
});

test.afterAll(async () => {
test.afterEach(async () => {
await app.page.close();
await tenderly.deleteFork(forkId);
});

test('It should open an Ajna Base Earn position @regression', async ({ metamask, page }) => {
test.setTimeout(extremelyLongTestTimeout);

await test.step('Test setup', async () => {
app = new App(page);
({ forkId, walletAddress } = await setup({ metamask, app, network: 'base' }));

await tenderly.setTokenBalance({
forkId,
network: 'base',
walletAddress,
token: 'USDC',
balance: '50000',
});
});

await app.position.openPage('/base/ajna/earn/ETH-USDC#setup');
await app.position.setup.acknowledgeAjnaInfo();

Expand All @@ -53,17 +50,22 @@ test.describe('Ajna Base Earn - Wallet connected', async () => {
protocol: 'Ajna',
});
});
});

test.describe('Ajna Base Earn - Wallet connected', async () => {
test.beforeEach(async ({ metamask, page }) => {
app = new App(page);
await setup({ metamask, app, network: 'base', withoutFork: true });
});

test('It should allow to simulate an Ajna Base Earn position before opening it', async ({
metamask,
page,
}) => {
test.afterEach(async () => {
await app.page.close();
});

test('It should allow to simulate an Ajna Base Earn position before opening it', async () => {
test.setTimeout(extremelyLongTestTimeout);

await test.step('Test setup', async () => {
app = new App(page);
await setup({ metamask, app, network: 'base', withoutFork: true });
});
await test.step('Test setup', async () => {});

await app.position.openPage('/base/ajna/earn/CBETH-ETH#setup');
await app.position.setup.acknowledgeAjnaInfo();
Expand Down Expand Up @@ -104,8 +106,8 @@ test.describe('Ajna Base Earn - Wallet connected', async () => {
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Confirm');
await app.position.setup.shouldHaveButtonEnabled('Confirm');
await app.position.setup.shouldHaveSpinningIconInButton('Create Smart DeFi account');
await app.position.setup.shouldNotHaveSpinningIconInButton('Create Smart DeFi account');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
Expand All @@ -128,8 +130,8 @@ test.describe('Ajna Base Earn - Wallet connected', async () => {
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Confirm');
await app.position.setup.shouldHaveButtonEnabled('Confirm');
await app.position.setup.shouldHaveSpinningIconInButton('Create Smart DeFi account');
await app.position.setup.shouldNotHaveSpinningIconInButton('Create Smart DeFi account');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
Expand Down
58 changes: 29 additions & 29 deletions tests/withWallet/ajna/optimism/ajnaEarnOptimism.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,27 @@ const test = testWithSynpress(metaMaskFixtures(optimismSetup));
const { expect } = test;

test.describe('Ajna Optimism Earn - Wallet connected', async () => {
test.afterEach(async () => {
await app.page.close();
test.beforeEach(async ({ metamask, page }) => {
app = new App(page);
({ forkId, walletAddress } = await setup({ metamask, app, network: 'optimism' }));

await tenderly.setTokenBalance({
forkId,
network: 'optimism',
walletAddress,
token: 'DAI',
balance: '100000',
});
});

test.afterAll(async () => {
test.afterEach(async () => {
await app.page.close();
await tenderly.deleteFork(forkId);
});

test('It should open an Ajna Optimism Earn position @regression', async ({ metamask, page }) => {
test.setTimeout(extremelyLongTestTimeout);

await test.step('Test setup', async () => {
app = new App(page);
({ forkId, walletAddress } = await setup({ metamask, app, network: 'optimism' }));

await tenderly.setTokenBalance({
forkId,
network: 'optimism',
walletAddress,
token: 'DAI',
balance: '100000',
});
});

await app.page.goto('/optimism/ajna/earn/OP-ETH#setup');
await app.position.setup.acknowledgeAjnaInfo();

Expand All @@ -54,17 +51,20 @@ test.describe('Ajna Optimism Earn - Wallet connected', async () => {
protocol: 'Ajna',
});
});
});

test('It should allow to simulate an Ajna Optimism Earn position before opening it', async ({
metamask,
page,
}) => {
test.setTimeout(veryLongTestTimeout);
test.describe('Ajna Optimism Earn - Wallet connected', async () => {
test.beforeEach(async ({ metamask, page }) => {
app = new App(page);
await setup({ metamask, app, network: 'base', withoutFork: true });
});

await test.step('Test setup', async () => {
app = new App(page);
await setup({ metamask, app, network: 'base', withoutFork: true });
});
test.afterEach(async () => {
await app.page.close();
});

test('It should allow to simulate an Ajna Optimism Earn position before opening it', async () => {
test.setTimeout(veryLongTestTimeout);

await app.page.goto('/optimism/ajna/earn/WBTC-DAI#setup');
await app.position.setup.acknowledgeAjnaInfo();
Expand Down Expand Up @@ -105,8 +105,8 @@ test.describe('Ajna Optimism Earn - Wallet connected', async () => {
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance');
await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance');
await app.position.setup.shouldHaveSpinningIconInButton('Create Smart DeFi account');
await app.position.setup.shouldNotHaveSpinningIconInButton('Create Smart DeFi account');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
Expand All @@ -129,8 +129,8 @@ test.describe('Ajna Optimism Earn - Wallet connected', async () => {
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance');
await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance');
await app.position.setup.shouldHaveSpinningIconInButton('Create Smart DeFi account');
await app.position.setup.shouldNotHaveSpinningIconInButton('Create Smart DeFi account');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
Expand Down
1 change: 0 additions & 1 deletion tests/withWallet/morphoBlue/base/morphoBlueEarn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ test.describe('Morpho Blue Base - Earn - Wallet connected', async () => {
app,
forkId,
deposit: { token: 'CBETH', amount: '10' },
protocol: 'Morpho Blue',
});
});

Expand Down

0 comments on commit 815f69d

Please sign in to comment.