Skip to content

Commit

Permalink
Merge pull request #127 from OasisDEX/enable-ajna-earn-adjust-lending…
Browse files Browse the repository at this point in the history
…-price

Enable Ajna Earn tests - Simulate lending price adjustment
  • Loading branch information
juan-langa authored Jan 17, 2024
2 parents 996e860 + fa7e528 commit c2aba41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
19 changes: 19 additions & 0 deletions src/pages/position/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ export class Setup {
}
}

@step
async showLendingPriceEditor({ pair }: { pair: string }) {
await this.page.getByText(`Or enter specific ${pair} Lending Price`).click();
}

@step
async updateLendingPrice({
collateralToken,
adjust,
}: {
collateralToken: string;
adjust: 'up' | 'down';
}) {
await this.page
.locator(`:has-text("Input ${collateralToken} Lending Price") + div > button`)
.nth(adjust === 'down' ? 0 : 1)
.click();
}

@step
async createSmartDeFiAccount() {
await this.page.getByRole('button', { name: 'Create Smart DeFi account' }).click();
Expand Down
24 changes: 13 additions & 11 deletions tests/withWallet/ajna/ethereum/ajnaEarnethereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,22 @@ test.describe('Ajna Ethereum Earn - Wallet connected', async () => {
});
});

// Slider changed for Ajna -> .moveSlide to be updated for AJNA
test.skip('It should allow to simulate Lending Price adjustment (Up) with slider in an Ajna Ethereum Earn position before opening it - Wallet connected @regression', async () => {
test('It should allow to simulate Lending Price adjustment (Up) in an Ajna Ethereum Earn position before opening it - Wallet connected @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12110',
});

// Set a low lending price as baseline to avoid test flakyness
await app.position.setup.moveSlider({ protocol: 'Ajna', value: 0.3 });
await app.position.setup.shouldHaveButtonDisabled('Create Smart DeFi account');
await app.position.setup.shouldHaveButtonEnabled('Create Smart DeFi account');

const initialLendingPrice = await app.position.setup.getLendingPrice();
const initialMaxLTV = await app.position.setup.getMaxLTV();

await app.position.setup.moveSlider({ protocol: 'Ajna', value: 0.7 });
await app.position.setup.showLendingPriceEditor({ pair: 'WSTETH/ETH' });
await app.position.setup.updateLendingPrice({
collateralToken: 'ETH',
adjust: 'up',
});

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

Expand All @@ -97,8 +96,7 @@ test.describe('Ajna Ethereum Earn - Wallet connected', async () => {
});
});

// Slider changed for Ajna -> .moveSlide to be updated for AJNA
test.skip('It should allow to simulate Lending Price adjustment (Down) with slider in an Ajna Ethereum Earn position before opening it @regression', async () => {
test('It should allow to simulate Lending Price adjustment (Down) in an Ajna Ethereum Earn position before opening it @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12109',
Expand All @@ -107,8 +105,12 @@ test.describe('Ajna Ethereum Earn - Wallet connected', async () => {
const initialLendingPrice = await app.position.setup.getLendingPrice();
const initialMaxLTV = await app.position.setup.getMaxLTV();

await app.position.setup.moveSlider({ protocol: 'Ajna', value: 0.2 });
await app.position.setup.updateLendingPrice({
collateralToken: 'ETH',
adjust: 'down',
});

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

Expand Down

0 comments on commit c2aba41

Please sign in to comment.